3
如何在matplotlib中创建一些渐变色,然后将子图的参数axisbg
设置为此?子图背景渐变色
f = plt.figure()
ax = f.add_subplot(111, axisbg='green')
如何在matplotlib中创建一些渐变色,然后将子图的参数axisbg
设置为此?子图背景渐变色
f = plt.figure()
ax = f.add_subplot(111, axisbg='green')
这不使用axisbg
参数,但可以做你想做的。
有一个matplotlib梯度示例:http://matplotlib.sourceforge.net/examples/pylab_examples/gradient_bar.html。 我没有尝试过自己,(在交互式Python外壳我需要调用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()
为不同的渐变选择另一个颜色表。 也可以插入'bicubic'
插值,但是那很丑。
woha,就像Excel一样!图中的背景!这通常会干扰用户看到数据本身。请避开它! (虽然,从技术上讲,这个问题很有趣,这是从downvote救了你......) – Oz123
这不是我的怀疑,它只是任务。如果客户想要图表背景并且我不能把他带过来,那么... –
有时候客户会问愚蠢的事情,作为一名专业人士,您应该强烈建议他们不要这样做! – Oz123