使用以下代码:
import matplotlib
matplotlib.style.use('ggplot')
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({ 'celltype':["foo","bar","qux","woz"], 's1':[5,9,1,7], 's2':[12,90,13,87]})
df = df[["celltype","s1","s2"]]
df.set_index(["celltype"],inplace=True)
df.plot(kind='bar',alpha=0.75)
plt.xlabel("")
我做了这个情节:
如何将x轴刻度标签旋转到0度?
我尝试添加它,但是没有用:
plt.set_xticklabels(df.index,rotation=90)
传递参数rot=0
以旋转xticks:
import matplotlib
matplotlib.style.use('ggplot')
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({ 'celltype':["foo","bar","qux","woz"], 's1':[5,9,1,7], 's2':[12,90,13,87]})
df = df[["celltype","s1","s2"]]
df.set_index(["celltype"],inplace=True)
df.plot(kind='bar',alpha=0.75, rot=0)
plt.xlabel("")
plt.show()
产量图:
有没有办法将此设置为所有其他图的默认值?
@Mitja不确定,可以编辑matplotlibrc文件以设置默认值matplotlib.org/users / ...,但是我找不到x轴旋转的设置,我不是matplotlib专家,我所能找到的只是修改当前图