0

I have a pivot table (i.e):

City                   Atlanta     New York   Chicago
Region name              Slow        Grid       Fathe

2010-01                  1            2          3
2010-02                  3            15         23   
...                                   ...
2016-01                  12           1          0 

when I try to plot some values with the following:

pivot.ix['2016-01'].plot(kind='barh', 
                        figsize=(7, 10), 
                        width=0.8, 
                        fontsize=10, 
                        colormap='autumn')

I get the following graph: enter image description here

How to change the code to plot this graph ascendingly?

1 Answer 1

3

Adding .sort_values() in between the pivot.ix[] and the .plot() calls will sort the Series returned by .ix[] before it's plotted and should give you the result you want.

pivot.ix['2016-01'].sort_values().plot(kind='barh', 
                                       figsize=(7, 10), 
                                       width=0.8, 
                                       fontsize=10, 
                                       colormap='autumn')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.