Skip to content Skip to sidebar Skip to footer

Pandas Plot Split Long Xtickslabels

For a csv like this: Quartile,KeyArea Q2,Earth with long name with long name with long name Q1,Earth with long name with long name Q1,Fire with long name with long name ,Fire with

Solution 1:

You can simply rename your plotted dataframe indexes

>>>from textwrap import wrap>>>pivoted_df.rename(index=lambda l: '\n'.join(wrap(l, 15))).plot.bar(stacked=True, rot=90)>>>plt.subplots_adjust(bottom=.4)>>>plt.show()

enter image description here

Post a Comment for "Pandas Plot Split Long Xtickslabels"