It works for me. Each scatter () function call gets its own color bar, since each scatter () color is normalized to its own data. What version of matplotlib are you using?
import pylab as plt
import numpy as np
x = np.linspace(0, 1, 100)
y = x**2
z = y
z_masked = np.ma.masked_where(z > 0.5, z)
plt.scatter(x, y, c=z, s=15, edgecolors='none')
plt.colorbar()
plt.scatter(x+1, y, c=z_masked, s=15, edgecolors='none')
plt.colorbar()
plt.show()
source
share