user97662
user97662

Reputation: 960

How do I set ylim for subplots using Pandas dataframe?

I have more than thee columns for data frame. I can set the bottom graph using ax=plt.gca(), but how do I set the limit for other subplots?

Below is the code I use for the plotting.

SomeDataFrame.plot(subplots=True, style=style, title='%s' % macID.upper(), grid=True, legend=True,)
ax = plt.gca()
ax.ylim=([lowlimit, highlimit])

plt.show()

Upvotes: 3

Views: 4564

Answers (1)

Robin Roth
Robin Roth

Reputation: 1329

SomeDataFrame.plot() returns a list of the subplots it created. Using this return value you can access and manipulate them.

mysubplots = SomeDataFrame.plot(subplots=True, style=style, title='%s' % macID.upper(), grid=True, legend=True,)
firstplot = mysubplots[0]
firstplot.set_ylim=([lowlimit, highlimit])
secondplot = mysubplots[1]
secondplot.set_ylim=([lotherowlimit, otherhighlimit])

plt.show()

Upvotes: 3

Related Questions