def plotter(z, t, r, **kwargs): xinches = len(t)/float(dpi)*pixelaspect yinches = len(r)/float(dpi) figsize = (xinches + 1.5, yinches + 1) fig = plt.figure(figsize=figsize) ax = plt.subplot(111) el.make_axes_fixed(ax, xinches, yinches) img = el.rtiplot(z, t, r, ax=ax, csize=0.0625, cpad=0.05, **kwargs) plt.tight_layout(0.1) return fig
def plot_block(z, t, r, dpi, pixelaspect=1, **kwargs): tlen = len(t) rlen = len(r) xinches = float(tlen)/dpi yinches = float(rlen)/dpi*pixelaspect # approximate size for figure # (doesn't matter if saving with tight bbox) fig = plt.figure(figsize=(xinches + .225 + 1.2, yinches + 2.25)) # size for between upper and lower plots # we will add sizes for labels and titles later h = [axes_grid1.Size.Fixed(xinches/5)]*5 v = [axes_grid1.Size.Fixed(yinches)] gs = matplotlib.gridspec.GridSpec(1, 1, left=0.085, bottom=0.0875, right=1, top=1) div = axes_grid1.SubplotDivider(fig, gs[0], horizontal=h, vertical=v) loc0 = div.new_locator(nx=0, ny=0) loc1 = div.new_locator(nx=1, ny=0) loc2 = div.new_locator(nx=2, ny=0) loc3 = div.new_locator(nx=3, ny=0) loc4 = div.new_locator(nx=4, ny=0) ax0 = fig.add_axes(loc0(None, None), label='ax0') ax1 = fig.add_axes(loc1(None, None), label='ax1', sharey=ax0) ax2 = fig.add_axes(loc2(None, None), label='ax2', sharey=ax0) ax3 = fig.add_axes(loc3(None, None), label='ax3', sharey=ax0) ax4 = fig.add_axes(loc4(None, None), label='ax4', sharey=ax0) # turn off unwanted (duplicate) tick labels plt.setp(ax1.get_yticklabels(), visible=False) plt.setp(ax2.get_yticklabels(), visible=False) plt.setp(ax3.get_yticklabels(), visible=False) plt.setp(ax4.get_yticklabels(), visible=False) # locate the axes in the divider ax0.set_axes_locator(loc0) ax1.set_axes_locator(loc1) ax2.set_axes_locator(loc2) ax3.set_axes_locator(loc3) ax4.set_axes_locator(loc4) # also have to override get_subplotspec after setting locator # so tight_layout works ax0.get_subplotspec = loc0.get_subplotspec ax1.get_subplotspec = loc1.get_subplotspec ax2.get_subplotspec = loc2.get_subplotspec ax3.get_subplotspec = loc3.get_subplotspec ax4.get_subplotspec = loc4.get_subplotspec # plot the frequency shift # plot the images img0 = el.rtiplot(z[0::5, :], t[0::5], r/1e3, title='Barker 13', ylabel='Range (km)', ax=ax0, cbar=False, xbins=5, ybins=6, exact_ticks=False, interpolation='none', **kwargs) img1 = el.rtiplot(z[1::5, :], t[1::5], r/1e3, title='MSL', ax=ax1, cbar=False, xbins=5, ybins=6, exact_ticks=False, interpolation='none', **kwargs) img2 = el.rtiplot(z[2::5, :], t[2::5], r/1e3, title='Uncoded', ax=ax2, cbar=False, xbins=5, ybins=6, exact_ticks=False, interpolation='none', **kwargs) img3 = el.rtiplot(z[3::5, :], t[3::5], r/1e3, title='LFM', ax=ax3, cbar=False, xbins=5, ybins=6, exact_ticks=False, interpolation='none', **kwargs) img4 = el.rtiplot(z[4::5, :], t[4::5], r/1e3, title='PSRND', clabel='SNR (dB)', ax=ax4, xbins=5, ybins=6, cbins=6, exact_ticks=False, interpolation='none', **kwargs) # erase all but one xlabel on plots for separate codes so they don't overlap ax0.set_xlabel('') ax1.set_xlabel('') ax3.set_xlabel('') ax4.set_xlabel('') # tight layout #gs.tight_layout(fig) plt.draw() return fig