Rotate xtick labels in seaborn boxplot?

前端 未结 1 642
你的背包
你的背包 2021-01-31 16:07

I have a question that is basically the same as a question back from 2014 (see here). However, my script still throws an error.

Here is what I do: I have a pandas datafr

相关标签:
1条回答
  • 2021-01-31 16:58

    The question you link to uses a factorplot. A factorplot returns its own class which has a method called set_xticklabels(rotation). This is different from the set_xticklabels method of the matplotlib Axes.

    In the linked question's answers there are also other options which you may use

    ax = sns.boxplot(x='categories', y='oxygen', hue='target', data=df)
    ax.set_xticklabels(ax.get_xticklabels(),rotation=30)
    

    or

    ax = sns.boxplot(x='categories', y='oxygen', hue='target', data=df)
    plt.setp(ax.get_xticklabels(), rotation=45)
    
    0 讨论(0)
提交回复
热议问题