1

I would like to fix label problems in a seaborn graph, I have more than 30 items in the x axis. How to reduce the label dimension or may be rotate the graph?

enter image description here

import seaborn as sns
g = sns.factorplot(x="target", data=df3, kind="count",
                   palette="BuPu", size=6, aspect=1.5)
IanS
  • 15,771
  • 9
  • 60
  • 84
progster
  • 877
  • 3
  • 15
  • 27
  • Are you after `plt.xticks(rotation=90)`? (where `import matplotlib.pylab as plt`) – IanS Jan 10 '17 at 16:45
  • You can also try: `g.set(xticks=np.arange(0, N, 3))` to show only every third label. – IanS Jan 10 '17 at 16:47
  • I have added both import matplotlib.pylab as plt and the other statement (plt.xticks(rotation=90) but nothing changes....may os it in any particular order? – progster Jan 10 '17 at 16:58
  • What environment do you work in? – IanS Jan 10 '17 at 17:03

1 Answers1

2

This will work if executed in a single cell in Jupyter:

g = sns.factorplot(x="target", data=df3, kind="count",
                   palette="BuPu", size=6, aspect=1.5)
g.set(xticks=np.arange(0, 40, 3))  # or however many you have
plt.xticks(rotation=90);

It will also work if executed as one block in Spyder.

IanS
  • 15,771
  • 9
  • 60
  • 84