Python Scatter Plot with Colorbar and Legend Issues
问题 I'm working with a pretty simple example. I create three scatter plots on the same set of axes, and each data set I plot has a different associated colormap. However, the legend does not look as I'd want it to; why is this? import numpy as np import matplotlib.pyplot as plt t = np.linspace(0,10,100) x = np.random.rand(100,3) y = np.random.rand(100,3) colmaps = ['Blues', 'Greys', 'Reds'] for i in range(3): plt.scatter(x[:,i], y[:,i], c=t, cmap=colmaps[i], label=i) plt.legend() plt.show() This