【问题标题】:Fill barchart with patterns [duplicate]用模式填充条形图[重复]
【发布时间】:2018-02-26 18:30:27
【问题描述】:

我目前正在绘制条形图。为了更易于阅读并在黑白打印后区分不同的条形,我想使用不同的图案绘制条形图,并且尽可能使用不同的颜色和类似于thisthis 的图案。使用 pandas 或 matplotlib 时这可能吗?如果是这样,是否有类似于调色板的图案调色板? 我当前的代码是这样的

df.transpose().plot.bar(width=0.8) 

【问题讨论】:

    标签: python pandas matplotlib


    【解决方案1】:

    Google 给出了答案 :) 尝试将 hatch='/' 传递给 bar()

    所有填充选项 (from here):['/' | '' | '|' | '-' | '+' | 'x' | 'o' | 'O' | '.' | '*']

    演示: https://matplotlib.org/examples/pylab_examples/hatch_demo.html

    【讨论】:

      猜你喜欢
      • 2018-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-24
      • 2016-01-15
      • 2015-07-13
      • 1970-01-01
      相关资源
      最近更新 更多