matplotlib中的“着色”水平条

2024-09-30 04:28:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我用的是这种条形图 http://matplotlib.org/examples/pylab_examples/barchart_demo2.html

我想改变条形图的外观,例如,给这些条形图一些三维的外观。 我的想法是这样的: http://tinyurl.com/oczlafw

只是,我不知道从哪里开始。也许在吧台上重复同样的画面?在

谢谢你的帮助 空调


Tags: orgcomhttpmatplotlibhtmlexamples外观条形图
1条回答
网友
1楼 · 发布于 2024-09-30 04:28:06

Matplotlib用户列表上的post演示了如何在条形图中使用颜色渐变。这可能和你想要的相似。下面我把它改编成单杠。您还可以看看在条形图中使用图像的this示例。在

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()

horizontal bar chart with gradient colors

相关问题 更多 >

    热门问题