[英]“shaded” horizontal bars in matplotlib
我正在使用像這樣的條形圖http://matplotlib.org/examples/pylab_examples/barchart_demo2.html
而且我想改變條形圖的樣子,例如給條形圖看一些三維效果。 我想到的是這樣的: http : //tinyurl.com/oczlafw
只是,我不知道從哪里開始。 也許沿着酒吧重復相同的圖像?
感謝AC的幫助
Matplotlib用戶列表中的這篇文章顯示了如何在條形圖中使用顏色漸變。 這可能與您想要的類似。 下面我將其改編為水平條。 你也可以看看這個以柱狀圖的形式使用圖像的例子。
from pylab import figure, show, np, cm, hold
def gbar(ax, x, y, height=0.5, left=0):
X = [[.7, .7],[.6,.6]]
for right,bottom in zip(x, y):
top = bottom+height
print bottom
print top
print ''
ax.imshow(X, interpolation='bicubic', cmap=cm.Blues,
extent=(left, right, bottom, top), alpha=1)
fig = figure()
xmin, xmax = xlim = 0,10
ymin, ymax = ylim = 0,1
ax = fig.add_subplot(111, xlim=xlim, ylim=ylim,
autoscale_on=False)
hold(True)
X = [[.6, .6],[.7,.7]]
N = 10
y = np.arange(N)+0.25
x = 10*np.random.rand(N)
gbar(ax, x, y)
ax.set_aspect('normal')
ax.set_ylim([0,10])
show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.