i have 2 graphs both have same x-axis, different y-axis scalings.
the plot regular axes data trend line depicting decay while y semi-log scaling depicts accuracy of fit.
fig1 = plt.figure(figsize=(15,6)) ax1 = fig1.add_subplot(111) # plot of decay model ax1.plot(freqtime1,decaycount1, '.', color='mediumaquamarine') # plot of optimized fit ax1.plot(x1, y1m, '-k', label='fitting function: $f(t) = %.3f e^{%.3f\t} \ %+.3f$' % (ar1,kr1,br1)) ax1.set_xlabel('time (sec)') ax1.set_ylabel('count') ax1.set_title('run 1 of cesium-137 decay') # allows me change scales # ax1.set_yscale('log') ax1.legend(bbox_to_anchor=(1.0, 1.0), prop={'size':15}, fancybox=true, shadow=true)
now, i'm trying figure out implement both close examples supplied link http://matplotlib.org/examples/pylab_examples/subplots_demo.html
in particular, one
when looking @ code example, i'm bit confused on how implant 3 things:
1) scaling axes differently
2) keeping figure size same exponential decay graph having line graph have smaller y size , same x size.
for example:
3) keeping label of function appear in decay graph.
any appreciated.
look @ code , comments in it:
import matplotlib.pyplot plt import numpy np matplotlib import gridspec # simple data display in various forms x = np.linspace(0, 2 * np.pi, 400) y = np.sin(x ** 2) fig = plt.figure() # set height ratios sublots gs = gridspec.gridspec(2, 1, height_ratios=[2, 1]) # fisrt subplot ax0 = plt.subplot(gs[0]) # log scale axis y of first subplot ax0.set_yscale("log") line0, = ax0.plot(x, y, color='r') #the second subplot # shared axis x ax1 = plt.subplot(gs[1], sharex = ax0) line1, = ax1.plot(x, y, color='b', linestyle='--') plt.setp(ax0.get_xticklabels(), visible=false) # remove last tick label second subplot yticks = ax1.yaxis.get_major_ticks() yticks[-1].label1.set_visible(false) # put lened on first subplot ax0.legend((line0, line1), ('red line', 'blue line'), loc='lower left') # remove vertical gap between subplots plt.subplots_adjust(hspace=.0) plt.show()