Xtick标签不会旋转?

2024-06-17 13:16:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我不能让我的x记号标签旋转,目前他们整体

我试过(代码中显示的,要使用rotation参数,我试过使用plt.setp公司尝试在第一个绘图参数内旋转。如果我只有一个轴,那么它会完美地绘制,因为某些原因,是次轴导致了问题

df_summary['AV_PRICE'] = np.random.randint(30, 150, size=len(df_summary))
plt.figure
df_summary.plot(kind='bar',x='BMCODE_type',y = 'AV_DURATION',xticks=[])
df_summary['AV_PRICE'].plot(secondary_y=True, 
legend='TRUE',style='g',ax=None, mark_right=False,xticks=[])
loc = range(len(df_summary))
plt.xticks(loc,df_summary['BMCODE_type'],rotation='vertical')
我希望标签垂直,而不是水平,任何想法都太好了!你知道吗


Tags: df参数lenplottypeplt标签summary
1条回答
网友
1楼 · 发布于 2024-06-17 13:16:33

我知道已经晚了8个月,但是。。。你知道吗

打印次轴时使用rot参数并将其设置为90:

df_summary['AV_PRICE'].plot(secondary_y=True, legend='TRUE', style='g',
                            ax=None, mark_right=False,xticks=[], rot=90)

相关问题 更多 >