5
$\begingroup$

In pandas I can set the date as index, and then run df.plot() to see a line chart. How do I make that line chart stacked as in the picture below?

enter image description here

$\endgroup$
1
  • $\begingroup$ Add your sample df $\endgroup$
    – Aditya
    Commented Apr 18, 2018 at 12:49

1 Answer 1

7
$\begingroup$

You can simply use

df.plot.area()

Found here after a quick google search.

$\endgroup$
3
  • $\begingroup$ Np. The keyword you may have left out was “area”, but honestly I’m not sure how I remembered that’s what these plots are called. $\endgroup$
    – kbrose
    Commented Apr 18, 2018 at 13:51
  • $\begingroup$ Do you know how I would do if I would add a group D to that plot from python-graph-gallery, and group D should not be stacked i.e. just a regular line? $\endgroup$
    – jacob
    Commented Apr 18, 2018 at 14:00
  • $\begingroup$ df.plot.area() returns the matplotlib axis object, just call ax.plot(my_data) $\endgroup$
    – kbrose
    Commented Apr 18, 2018 at 15:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.