你必须将一系列颜色从seaborn调色板转换成
matplolib(thx至@RafaelLopes,建议变更):
import seaborn as snsimport matplotlib.pylab as pltimport numpy as npfrom matplotlib.colors import ListedColormap# construct cmapflatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]my_cmap = ListedColormap(sns.color_palette(flatui).as_hex())N = 500data1 = np.random.randn(N)data2 = np.random.randn(N)colors = np.linspace(0,1,N)plt.scatter(data1, data2, c=colors, cmap=my_cmap)plt.colorbar()plt.show()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)