【问题标题】:Matplotlib - wider space between datesMatplotlib - 日期之间更宽的空间
【发布时间】:2014-05-29 16:42:52
【问题描述】:

我有一个以日期为 x 轴的图。但是我左右都有很多空间,我想在每个日期之间获得更宽的空间,以填充整个空间(宽度)。现在看起来像这样:

我的代码是:

ticks = np.arange(0, len(year_month), 1)
labels = year_month

mng = plt.get_current_fig_manager()
mng.window.state('zoomed')  #works fine on Windows

plt.xlabel('Date')
plt.xticks(ticks, labels, rotation='vertical')
plt.ylabel('Sentiment')
plt.legend()
plt.grid()
plt.show()

【问题讨论】:

  • @flebool 你可以发表你的评论作为答案...

标签: python matplotlib plot width axis-labels


【解决方案1】:

使用plt.xlim(xm,xM)xmxM 分别是您最旧和最新的日期。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 2019-06-01
    • 2017-06-04
    • 2023-03-26
    • 2017-12-10
    • 1970-01-01
    • 2019-12-19
    相关资源
    最近更新 更多