Pandas: bar plot xtick frequency

前端 未结 1 1463
谎友^
谎友^ 2020-12-02 21:18

I want to create a simple bar chart for pandas DataFrame object. However, the xtick on the chart appears to be too granular, whereas if I change the plot to line chart, xtic

相关标签:
1条回答
  • You can reduce the number of thicks by setting one every n ticks, doing something like:

    n = 10
    
    ax = locks.plot(kind='bar', y='SUM')
    ticks = ax.xaxis.get_ticklocs()
    ticklabels = [l.get_text() for l in ax.xaxis.get_ticklabels()]
    ax.xaxis.set_ticks(ticks[::n])
    ax.xaxis.set_ticklabels(ticklabels[::n])
    
    ax.figure.show()
    
    0 讨论(0)
提交回复
热议问题