Ski*_*mag 5 python colors matplotlib
如何在 matplotlib 中创建一些渐变颜色,然后将axisbg我的子图的参数设置为此?
f = plt.figure()
ax = f.add_subplot(111, axisbg='green')
Run Code Online (Sandbox Code Playgroud)
这不使用axisbg参数,但可能会执行您想要的操作。
有一个 matplotlib 渐变示例:http://matplotlib.sourceforge.net/examples/pylab_examples/gradient_bar.html。我自己尝试过,这个简化版本给了我一个绿白渐变背景(由于某种原因,在交互式 python shell 中执行此操作时,我需要调用draw()才能显示图像):
import matplotlib.pyplot as mplt
fig = mplt.figure()
ax = fig.add_subplot(111)
mplt.plot([1,2,3],[1,2,1])
plotlim = mplt.xlim() + mplt.ylim()
ax.imshow([[0,0],[1,1]], cmap=mplt.cm.Greens, interpolation='bicubic', extent=plotlim)
mplt.draw()
Run Code Online (Sandbox Code Playgroud)
为不同的渐变选择另一个颜色图。无需'bicubic'插值也可以工作,但这样会更丑陋。