With the following code:
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("")
I made this plot:
How can I rotate the x-axis tick labels to 0 degrees?
I tried adding this but did not work:
plt.set_xticklabels(df.index,rotation=90)
Pass param rot=0
to rotate the 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()
yields plot:
Is there a way to set this as a default for all further plots?
@Mitja not sure, it's possible to edit the matplotlibrc file to set the defaults matplotlib.org/users/… but I can't find a setting for x-axis rotation, I'm not a matplotlib expert, all I could find was modifying this for the current plot