【问题标题】:"shaded" horizontal bars in matplotlibmatplotlib 中的“阴影”水平条
【发布时间】:2013-10-28 16:52:37
【问题描述】:

我正在使用这样的条形图 http://matplotlib.org/examples/pylab_examples/barchart_demo2.html

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

只是,我不知道从哪里开始。也许在条形图上重复相同的图像?

感谢您的帮助 交流

【问题讨论】:

    标签: python matplotlib plot bar-chart


    【解决方案1】:

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

    【讨论】:

    • @aleciccia 您可以通过点击左侧的箭头来接受答案...
    猜你喜欢
    • 1970-01-01
    • 2019-09-13
    • 2020-12-26
    • 2013-05-15
    • 1970-01-01
    • 1970-01-01
    • 2020-08-17
    • 2016-07-14
    • 1970-01-01
    相关资源
    最近更新 更多