繁体   English   中英

matplotlib中的“阴影”水平条

[英]“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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM