def single_plot(data, x, y, axes=None, beta=None, cbar_label='', cmap=plt.get_cmap('RdBu'), vmin=None, vmax=None, phase_speeds=True, manual_locations=False, **kwargs): """ Plot a single frame Time-Distance Diagram on physical axes. This function uses mpl NonUniformImage to plot a image using x and y arrays, it will also optionally over plot in contours beta lines. Parameters ---------- data: np.ndarray The 2D image to plot x: np.ndarray The x coordinates y: np.ndarray The y coordinates axes: matplotlib axes instance [*optional*] The axes to plot the data on, if None, use plt.gca(). beta: np.ndarray [*optional*] The array to contour over the top, default to none. cbar_label: string [*optional*] The title label for the colour bar, default to none. cmap: A matplotlib colour map instance [*optional*] The colourmap to use, default to 'RdBu' vmin: float [*optional*] The min scaling for the image, default to the image limits. vmax: float [*optional*] The max scaling for the image, default to the image limits. phase_speeds : bool Add phase speed lines to the plot manual_locations : bool Array for clabel locations. Returns ------- None """ if axes is None: axes = plt.gca() x = x[:xxlim] data = data[:,:xxlim] im = NonUniformImage(axes,interpolation='nearest', extent=[x.min(),x.max(),y.min(),y.max()],rasterized=False) im.set_cmap(cmap) if vmin is None and vmax is None: lim = np.max([np.nanmax(data), np.abs(np.nanmin(data))]) im.set_clim(vmax=lim,vmin=-lim) else: im.set_clim(vmax=vmax,vmin=vmin) im.set_data(x,y,data) im.set_interpolation('nearest') axes.images.append(im) axes.set_xlim(x.min(),x.max()) axes.set_ylim(y.min(),y.max()) cax0 = make_axes_locatable(axes).append_axes("right", size="5%", pad=0.05) cbar0 = plt.colorbar(im, cax=cax0, ticks=mpl.ticker.MaxNLocator(7)) cbar0.set_label(cbar_label) cbar0.solids.set_edgecolor("face") kwergs = {'levels': [1., 1/3., 1/5., 1/10., 1/20.]} kwergs.update(kwargs) if beta is not None: ct = axes.contour(x,y,beta[:,:xxlim],colors=['k'], **kwergs) plt.clabel(ct,fontsize=14,inline_spacing=3, manual=manual_locations, fmt=mpl.ticker.FuncFormatter(betaswap)) axes.set_xlabel("Time [s]") axes.set_ylabel("Height [Mm]")