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