Rotate tick labels for seaborn barplot

前端 未结 5 1274
再見小時候
再見小時候 2021-01-30 20:20

I am trying to display a chart with rotated x-axis labels, but the chart is not displaying.

import seaborn as sns
%matplotlib inline

yellow=\'#FFB11E\'
by_schoo         


        
5条回答
  •  花落未央
    2021-01-30 21:07

    You need a different method call, namely .set_rotation for each ticklables. Since you already have the ticklabels, just change their rotations:

    for item in by_school.get_xticklabels():
        item.set_rotation(45)
    

    barplot returns a matplotlib.axes object (as of seaborn 0.6.0), therefore you have to rotate the labels this way. In other cases, when the method returns a FacetGrid object, refer to Rotate label text in seaborn factorplot

提交回复
热议问题