python - iPython notebook - set ylim on subplot secondary y-axis -
I'm new to Python and I'm working in iPython Notebook.
I have to plot data in subplaces using secondary axes. I can set the ylim but it only affects the secondary Y-axis (on the right side). I can not find any way to control ylim on the primary y-axis (on the left side) There is a limit of [0,40], and the secondary y-axis has a limit of [0,100].
#import matlotlib.pylab as plt import numpy np import panda as PD import csv import string% pylab inline% matplotlib inline # first csv espr = pd.read_csv ( 'Out.csv') Read df_e = pd.DataFrame (espr) #READ in the second CSV summer = pd.read_csv ('heat.csv', encoding = 'ISO-885 9-1', less_mummy = Fail) The heat = heat [2:] df_h = pd.DataFrame (summer, dtype = 'float64') Df_h = df_h.reset_index (drop = True) # in the CRP = Temp = pd.read_csv ('temp.csv', encoding = 'ISO-8859-1', low emulation = falls) temp = temp [2:] df_t = Pd.D AteFrame (temp, dtype = 'float64') df_t = df_t.reset_index (drop = True) # CONCATENATE DATAFRAMES df_e = df_e [[Building: Time step (), 'Building: Area 01: Air Point: Temperature (OC) ',' Building: Area 05: Wind point: Temperature (OC) ']] df_h = df_h [[TIME', 'Tdb_amb']] df_t = df_t [[Taw_dirin ',' tweg_sys']] sim = Pd.concat [Df_h, df_t, df_e], axis = 1) # isolated figures for plotting = = [14160: 21600]
This is where I am walking in a wall, I set up Twin X to set properties for different axes Do read, but when I tried to apply it, it tells me that know what the Twins.
fig, axis = plt.subplots (nrows = 2, ncols = 1) fig.set_figheight (25) fig .set_figwidth (20) mar ['building: area 01: air point: temperature (OC) ']. Plot (ax = axes [0]) mar ['Building: Area 05: Wind point: Temperature (OC)'] plot (ax = axes [0]) mar ['tavg_diurn']. Plot (secondary_y = true, axis = axes [0]) mar ['tavg_seas']. Plot (secondary_y = true, ax = axes [0]) ylim ([0,100]) fig.tight_layout () Thanks in advance for any help.
OK if axes is an array of two axes so you do it Axes [0] .set_ylim (0, 40) axes [1] .set_ylim (0, 100)
or Using pyplot twinx () you can try:
axes [0] = ax2.twinx () axis [0] .set_ylim (0, 40) ax2 .set_ylim (0, 100)
Comments
Post a Comment