Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Matplotlib无法旋转XTICK_Python_Matplotlib_Graph - Fatal编程技术网

Python Matplotlib无法旋转XTICK

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=[

我不熟悉用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=['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)