Python Matplotlib无法旋转XTICK
我不熟悉用python创建图形。 我的x轴刻度垂直显示有问题: 这是我的密码:Python Matplotlib无法旋转XTICK,python,matplotlib,graph,Python,Matplotlib,Graph,我不熟悉用python创建图形。 我的x轴刻度垂直显示有问题: 这是我的密码: Counts = {"Hate":hate, "Non-hate":noHate} graph = pd.Series(Counts) plt.rcParams['figure.figsize'] = (6,6) plt.rcParams['font.size'] = (14) plt.xticks(rotation=20) graph.plot.bar(yticks=[hate,noHate],color=[
Counts = {"Hate":hate, "Non-hate":noHate}
graph = pd.Series(Counts)
plt.rcParams['figure.figsize'] = (6,6)
plt.rcParams['font.size'] = (14)
plt.xticks(rotation=20)
graph.plot.bar(yticks=[hate,noHate],color=['tab:red', 'tab:green'])
如您所见,我尝试过使用plt.xticksrotation,但没有成功。
我使用数字20只是为了测试,我想水平显示标签。有什么想法吗
注意:我还尝试了plt.xticksrotation='vertical'和horizontal以实现此目的。graph.plot.bar有一个用于此目的的参数rot,请参阅:
这回答了你的问题吗?请尝试plt.xticksrotation=20以放置在graph.plot.bar之后。
import pandas as pd
import matplotlib as plt
Counts = {"Hate":hate, "Non-hate":noHate}
graph = pd.Series(Counts)
plt.rcParams['figure.figsize'] = (6,6)
plt.rcParams['font.size'] = (14)
graph.plot.bar(yticks=[hate,noHate],color=['tab:red', 'tab:green'], rot=20)