我想使用反向光谱颜色图
,
https://matplotlib.org/examples/color/colormaps_reference.html
用于线图。
这对于十六进制图来说效果很好::
color_map = plt.cm.Spectral_r
image = plt.hexbin(x,y,cmap=color_map)
但是当我这样做的时候
ax1.plot(x,y, cmp=color_map)
这给了我::
AttributeError: Unknown property cmap
注意,我只想设置 colormap
并让 matplotliob
完成剩下的工作;即我不想在 .plot 命令中使用 color=' argument
。
最佳答案
您可以看看这个解决方案 - 第三个变体就是您想要的:
https://stackoverflow.com/a/57227821/5972778
您需要提前知道要绘制多少条线,否则它不知道如何从范围中选择颜色。
关于python - 使用 matplotlib 线图的颜色图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46296422/