【问题标题】:Adjusting labels for a pandas bar graph;调整熊猫条形图的标签;
【发布时间】:2021-04-17 18:36:30
【问题描述】:
出于好奇,如何从 PD 标签中调整图形标签?enter image description here
#Create bar charts to show outliers:
fig, ax = plt.subplots()
a1['Word #'].value_counts().plot(ax=ax, kind='bar', x='Word #', y='Frequency')
我试图给它贴上不同的标签,但我不认为它工作正常。感谢您的帮助!
【问题讨论】:
标签:
python
pandas
graph
charts
label
【解决方案1】:
你试过xlabel()和ylabel()吗?
#Create bar charts to show outliers:
fig, ax = plt.subplots()
a1['Word #'].value_counts().plot(ax=ax, kind='bar', x='Word #', y='Frequency')
plt.xlabel("Label what you want")
plt.ylabel("Label what you want")
plt.show()
或
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')
plt.show()
这对于您的示例也可能更好:
lt.xticks(rotation=90)