Jeyhun Karimov Jeyhun Karimov - 2 months ago 18
Python Question

Stacked Lines in Pandas

I want to draw stacked lines in

pandas Dataframe
.
So, currently I draw one line:

df.plot.line(x='xvals',y='yvals')


in which
xvals
column contains
x
values, and
yvals
contains
y
values.

How can I add another line in the same graph?

Answer

Keep the returned Axes object and pass to ax argument:

ax = df.plot.line(x='xvals',y='yvals')
df.plot.line(x='xvals2',y='yvals2', ax=ax)
Comments