<html><head></head><body>Maybe I missed something, but wouldn’t just fixing vmin and vmax in the scatter do the job?<br><br>Regards,<br>Bruno<br><br><div class="gmail_quote">Le 28 mars 2019 16:56:32 GMT+01:00, Neal Becker <ndbecker2@gmail.com> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">I'm trying to make 2 scatter plots where the colors of each point <br>corresponds to the value of a 1d array.<br><br>I want to do this so that the colors used in the 2 plots are comparable.  <br>That is, in plot 1 a violet dot means the same value as on plot 2.<br><br>I tried the following code.  Here values2 is clearly different than values1.  <br>But it appears that the plots are colored with the same colors.  And the <br>colorbar scales are different.  What I want is to have the colorbar scales <br>be the same, and the colors on the plot are different.<br><br>So for example, if point #1 on plot 1 has a value of 0.4, and point #1 on <br>plot 2 has a value of 0.5, the colors used to represent given values on the <br>2 plots are the same.  I believe that without colorbar, just using scatter <br>with specific c=value, I do get this result.  But adding colorbar I think <br>changes all the colors.<br><br>Any suggestions?<br><br><br>import numpy as np<br>pts = np.random.uniform (0, 1, 100) + 1j*np.random.uniform(0, 1, 100)<br>values1 = np.random.uniform(0, 1, 100)<br>#values2 = np.random.uniform(0.2, 1, 100)<br>values2 = values1 * 0.8 + 0.2<br><br>import matplotlib.pyplot as plt<br>for value in (values1, values2):<br>    fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'})<br>    cmap=plt.get_cmap('plasma')<br>    blah = ax.scatter (pts.real, pts.imag, c=value, s=10)<br>    blah.set_array (value)<br>    fig.colorbar (blah)<br>plt.show()<hr>Matplotlib-users mailing list<br>Matplotlib-users@python.org<br><a href="https://mail.python.org/mailman/listinfo/matplotlib-users">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br></pre></blockquote></div></body></html>