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$ 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$ 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$ Commented Apr 18, 2018 at 14:00
  • $\begingroup$ df.plot.area() returns the matplotlib axis object, just call ax.plot(my_data) $\endgroup$ 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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.