【问题标题】:How to avoid some xticks are auto-hidden in pandas?如何避免某些 xticks 在 pandas 中自动隐藏?
【发布时间】:2015-01-27 20:42:09
【问题描述】:

我有一个包含 18 行和 4 列的数据框。现在我要绘制它并将其索引用作 xticks,所以我执行以下操作:

ax0 = dfVariableImportance.plot()
ax0.set_xticklabels(dfVariableImportance.index.tolist(), rotation='vertical', visible=True)
plt.show()

原来有些xticks是自动隐藏的:应该有18个xticks,但只显示了9个(好像是自动隐藏的)。

如何显示所有 18 个 xticks?

【问题讨论】:

    标签: python matplotlib pandas


    【解决方案1】:

    你应该可以在 dataframe.plot() 中做到这一点

    dfVariableImportance.plot(xticks=dfVariableImportance.index)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-12
      • 2021-10-23
      • 1970-01-01
      相关资源
      最近更新 更多