Install Yaxis in Matplotlib using Pandas

Using Pandas to build in the I-Python Notebook, I have several graphs, and since Matplotlib solves the Y axis, it sets them differently, and we need to compare this data using the same range. I tried several options: (I suppose I will need to apply restrictions for each plot .. but since I can’t get one job ... From the Matplotlib document it seems that I need to install ylim, but can't draw the syntax to to do this.

df2250.plot(); plt.ylim((100000,500000)) <<<< if I insert the ; I get int not callable and if I leave it out I get invalid syntax. anyhow, neither is right... df2260.plot() df5.plot() 
+8
matplotlib pandas ipython-notebook
source share
1 answer

Pandas plot () returns the axis, you can use it to set ylim on it.

 ax1 = df2250.plot() ax2 = df2260.plot() ax3 = df5.plot() ax1.set_ylim(100000,500000) ax2.set_ylim(100000,500000) etc... 

You can also transfer axes to the Pandas plot, so it can be placed on the same axis, for example:

 ax1 = df2250.plot() df2260.plot(ax=ax1) etc... 

If you need a lot of different graphs, defining axes on forehand and inside the same shape may be the solution that gives you the most control:

 fig, axs = plt.subplots(1,3,figsize=(10,4), subplot_kw={'ylim': (100000,500000)}) df2260.plot(ax=axs[0]) df2260.plot(ax=axs[1]) etc... 
+23
source share

All Articles