Issue with Matplotlib scatterplot and Color maps
问题 I am working on a project that involves applying colormaps to scatterplots generated in matplotlib. My code works as expected, unless the scatterplot being generated has exactly four points. This is illustrated in the following code: import numpy as np import matplotlib.pyplot as plt cmap = plt.get_cmap('rainbow_r') z = np.arange(20) plt.close() plt.figure(figsize=[8,6]) for i in range(1,11): x = np.arange(i) y = np.zeros(i) + i plt.scatter(x, y, c=cmap(i / 10), edgecolor='k', label=i, s=200)