29
用下面的代码:如何大熊猫旋转x轴刻度标签barplot
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)
有没有一种方法可以将此设置为所有其他图的默认值? – Mitja
@Mitja不确定,可以编辑matplotlibrc文件来设置默认值https://matplotlib.org/users/customizing.html#customizing-with-matplotlibrc-files,但我找不到x轴的设置旋转,我不是一个matplotlib专家,所有我能找到的是修改这个当前情节 – EdChum