【问题标题】:Getting the colour of bar chart matplotlib获取条形图matplotlib的颜色
【发布时间】:2013-02-04 15:53:10
【问题描述】:

我在 matplotlib 中构建了一个条形图,并将其嵌入到 wxpython 中。 目前我已经能够通过使用event.artist.get_bbox().get_points() 获得积分。我想获得特定栏的颜色。任何帮助将不胜感激。

【问题讨论】:

    标签: python matplotlib wxpython


    【解决方案1】:

    你只想要一个 rgba 元组吗?

    如果是这样,请使用event.artist.get_facecolor()

    作为一个简单的例子(看到你似乎正在处理选择事件......):

    import matplotlib.pyplot as plt
    
    def on_pick(event):
        print event.artist.get_facecolor()
    
    fig, ax = plt.subplots()
    bars = ax.bar(range(10), range(10), picker=5)
    
    fig.canvas.mpl_connect('pick_event', on_pick)
    
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 2020-10-07
      • 2019-06-11
      • 2015-10-12
      • 1970-01-01
      • 2016-11-15
      • 1970-01-01
      • 2020-08-10
      • 2015-09-27
      • 1970-01-01
      相关资源
      最近更新 更多