0

I have data

used_at                2014      2015
address                                                                                                  
auto.ru             9122342   6923367
am.ru                413071    183402
avito.ru           84503151  87688571
avtomarket.ru        106849     95927
cars.mail.ru/sale    211456    167278 

and i need to print graph with rotation
address . I print

ax = graph_by_duration.plot.bar(width=0.5, ax=axes[0])
ax.set_xticklabels(graph_by_duration, rotation=40)

but it doesn't work. How can I do it?

Suever
  • 64,497
  • 14
  • 82
  • 101
NineWasps
  • 2,081
  • 8
  • 28
  • 45
  • Possible duplicate of [Rotate axis text in python matplotlib](http://stackoverflow.com/questions/10998621/rotate-axis-text-in-python-matplotlib) – Fabio Lamanna Mar 19 '16 at 22:05
  • 2
    If you want to ask a new question **go ask a new question**. Do not completely change your question and uncheck the accepted answer. – Suever Apr 13 '16 at 11:27

1 Answers1

1

The reason that this is failing is because set_xticklabels expects a list of strings as it's first input and you are passing a DataFrame. One option is to call plt.xticks() prior to plotting.

import matplotlib.pyplot as plt

plt.xticks(rotation=40)
ax = graph_by_duration.plot.bar(width=0.5, ax=axes[0])

The other option is to set the rotation on the existing labels by first fetching all labels.

for label in ax.get_xticklabels():
    label.set_rotation(40)  
Suever
  • 64,497
  • 14
  • 82
  • 101