Jason Yang
Jason Yang

Reputation: 584

How to avoid some xticks are auto-hidden in pandas?

I have a dataframe which contains 18 rows and 4 columns. Now I would to plot it and use its index as xticks, so I do the following:

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

enter image description here

It turns out that some xticks are hidden automatically: there should be 18 xticks, but only 9 of them are shown (seems to be hidden automatically).

How can I show all the 18 xticks?

Upvotes: 1

Views: 1391

Answers (1)

Bob Haffner
Bob Haffner

Reputation: 8493

You should be able to do this in dataframe.plot()

dfVariableImportance.plot(xticks=dfVariableImportance.index)

Upvotes: 1

Related Questions