I'm trying to make 2 scatter plots where the colors of each point

corresponds to the value of a 1d array.

I want to do this so that the colors used in the 2 plots are comparable.

That is, in plot 1 a violet dot means the same value as on plot 2.

I tried the following code. Here values2 is clearly different than values1.

But it appears that the plots are colored with the same colors. And the

colorbar scales are different. What I want is to have the colorbar scales

be the same, and the colors on the plot are different.

So for example, if point #1 on plot 1 has a value of 0.4, and point #1 on

plot 2 has a value of 0.5, the colors used to represent given values on the

2 plots are the same. I believe that without colorbar, just using scatter

with specific c=value, I do get this result. But adding colorbar I think

changes all the colors.

Any suggestions?

import numpy as np

pts = np.random.uniform (0, 1, 100) + 1j*np.random.uniform(0, 1, 100)

values1 = np.random.uniform(0, 1, 100)

#values2 = np.random.uniform(0.2, 1, 100)

values2 = values1 * 0.8 + 0.2

import matplotlib.pyplot as plt

for value in (values1, values2):

fig, ax = plt.subplots(subplot_kw={'aspect': 'equal'})

cmap=plt.get_cmap('plasma')

blah = ax.scatter (pts.real, pts.imag, c=value, s=10)

blah.set_array (value)

fig.colorbar (blah)

plt.show()