Ant
Ant

Reputation: 1143

How to set the y limit using plt.rcParams to zero. (Charting a Pandas df and saving image to disk)

My DataFrame is a time series. I'm using...

df.plot()

and it basically zooms in on the y axis but I would like the plot to show y values from 0 to my df's max value

I tried...

plt.ylim(0)

But it just plots a blank graph in addition to the graph I don't want.

I also tried...

.set_ylim(bottom=0)

on the end, and it plots but I can't get python to store this. It turns the plot into x, y coordinates somehow.

My current output

Just to be redundant about it... This y axis stops at 4. I would like it to go to 0 and have the who chart be not zoomed in like that so other graphs can be more easily compared to each other.

Upvotes: 0

Views: 1018

Answers (1)

Diziet Asahi
Diziet Asahi

Reputation: 40697

ylim() usually takes 2 arguments (bottom, top). However, if you only want to change one of the limits, you have to specify which using top= or bottom=

You could simply do:

df.plot(...)
plt.ylim(bottom=0)

Upvotes: 2

Related Questions