def plot_3d_scatter(self, fig, ax, x, y, z, title='', xlabel='', ylabel='', zlabel='', title_font={}, axis_font={}, tick_font={}): if not title_font: title_font = title_font_default if not axis_font: axis_font = axis_font_default cmap = plt.cm.jet h = plt.scatter(x, y, c=z, cmap=cmap) ax.set_aspect(1./ax.get_data_ratio()) # make axes square cbar = plt.colorbar(h, orientation='vertical', aspect=30, shrink=0.9) if xlabel: ax.set_xlabel(xlabel.replace("_", " "), labelpad=10, **axis_font) if ylabel: ax.set_ylabel(ylabel.replace("_", " "), labelpad=10, **axis_font) if zlabel: cbar.ax.set_ylabel(zlabel.replace("_", " "), labelpad=10, **axis_font) if tick_font: ax.tick_params(**tick_font) if title: ax.set_title(title.replace("_", " "), **title_font) ax.grid(True) plt.tight_layout()
def plot_stacked_time_series(self, fig, ax, x, y, z, title='', ylabel='', cbar_title='', title_font={}, axis_font={}, tick_font = {}, **kwargs): if not title_font: title_font = title_font_default if not axis_font: axis_font = axis_font_default z = np.ma.array(z, mask=np.isnan(z)) h = plt.pcolormesh(x, y, z, shading='gouraud', **kwargs) # h = plt.pcolormesh(x, y, z, **kwargs) if ylabel: ax.set_ylabel(ylabel.replace("_", " "), **axis_font) if title: ax.set_title(title.replace("_", " "), **title_font) plt.axis([x.min(), x.max(), y.min(), y.max()]) ax.xaxis_date() date_list = mdates.num2date(x) self.get_time_label(ax, date_list) fig.autofmt_xdate() ax.invert_yaxis() cbar = plt.colorbar(h) if cbar_title: cbar.ax.set_ylabel(cbar_title, **axis_font) ax.grid(True) if tick_font: ax.tick_params(**tick_font) plt.tight_layout()
def plot_stacked_time_series_image(self, fig, ax, x, y, z, title='', ylabel='', cbar_title='', title_font={}, axis_font={}, tick_font = {}, **kwargs): ''' This plot is a stacked time series that uses NonUniformImage with regualrly spaced ydata from a linear interpolation. Designed to support FRF ADCP data. ''' if not title_font: title_font = title_font_default if not axis_font: axis_font = axis_font_default # z = np.ma.array(z, mask=np.isnan(z)) h = NonUniformImage(ax, interpolation='bilinear', extent=(min(x), max(x), min(y), max(y)), cmap=plt.cm.jet) h.set_data(x, y, z) ax.images.append(h) ax.set_xlim(min(x), max(x)) ax.set_ylim(min(y), max(y)) # h = plt.pcolormesh(x, y, z, shading='gouraud', **kwargs) # h = plt.pcolormesh(x, y, z, **kwargs) if ylabel: ax.set_ylabel(ylabel, **axis_font) if title: ax.set_title(title, **title_font) # plt.axis('tight') ax.xaxis_date() date_list = mdates.num2date(x) self.get_time_label(ax, date_list) fig.autofmt_xdate() # if invert: ax.invert_yaxis() cbar = plt.colorbar(h) if cbar_title: cbar.ax.set_ylabel(cbar_title, **axis_font) ax.grid(True) if tick_font: ax.tick_params(**tick_font)
def plot_3d_scatter(self, fig, ax, x, y, z, title='', xlabel='', ylabel='', zlabel='', title_font={}, axis_font={}, tick_font={}): if not title_font: title_font = title_font_default if not axis_font: axis_font = axis_font_default cmap = plt.cm.jet h = plt.scatter(x, y, c=z, cmap=cmap) ax.set_aspect(1. / ax.get_data_ratio()) # make axes square cbar = plt.colorbar(h, orientation='vertical', aspect=30, shrink=0.9) if xlabel: ax.set_xlabel(xlabel.replace("_", " "), labelpad=10, **axis_font) if ylabel: ax.set_ylabel(ylabel.replace("_", " "), labelpad=10, **axis_font) if zlabel: cbar.ax.set_ylabel(zlabel.replace("_", " "), labelpad=10, **axis_font) if tick_font: ax.tick_params(**tick_font) if title: ax.set_title(title.replace("_", " "), **title_font) ax.grid(True) plt.tight_layout()
def plot_stacked_time_series(self, fig, ax, x, y, z, title='', ylabel='', cbar_title='', title_font={}, axis_font={}, tick_font={}, **kwargs): if not title_font: title_font = title_font_default if not axis_font: axis_font = axis_font_default z = np.ma.array(z, mask=np.isnan(z)) h = plt.pcolormesh(x, y, z, shading='gouraud', **kwargs) # h = plt.pcolormesh(x, y, z, **kwargs) if ylabel: ax.set_ylabel(ylabel.replace("_", " "), **axis_font) if title: ax.set_title(title.replace("_", " "), **title_font) plt.axis([x.min(), x.max(), y.min(), y.max()]) ax.xaxis_date() date_list = mdates.num2date(x) self.get_time_label(ax, date_list) fig.autofmt_xdate() ax.invert_yaxis() cbar = plt.colorbar(h) if cbar_title: cbar.ax.set_ylabel(cbar_title) ax.grid(True) if tick_font: ax.tick_params(**tick_font) plt.tight_layout()
yellorred = brewer2mpl.get_map('YlOrRd','Sequential',9).mpl_colormap p = ax1.pcolormesh(alphas2,phis2,eps.T,cmap=yellorred, rasterized=True) ax1.axis([alphas2.min(),alphas2.max(),phis2.min(),phis2.max()]) #xticks = np.arange(alphas.min(),alphas.max(),0.5) #xlabels = np.arange(alphas.min(),alphas.max(),0.5)-alphas.min() #yticks = np.arange(phis.min(),phis.max(),0.5) #ylabels = np.arange(phis.min(),phis.max(),0.5)-phis.min() #plt.xticks(xticks,xlabels,axes=ax1) #plt.yticks(yticks,ylabels,axes=ax1) cb = plt.colorbar(p, ax=ax1) cb.set_ticks(np.array([0.3,0.4,0.5])) cb.set_ticklabels(np.array([0.3,0.4,0.5])) ax1.set_xlabel(r'$\alpha$') ax1.set_ylabel(r'$\phi$') ax1.set_title(r'MMSE ($\epsilon$)') l1,= ppl.plot( alphas, eps[:,10], label=r'$\phi = '+ str(phis[10]-0.001) + r'$',ax=ax2) ppl.plot( alphas[np.argmin(eps[:,10])], np.min(eps[:,10]), 'o',color=l1.get_color(),ax=ax2) l2, = ppl.plot( alphas, eps[:,20], label=r'$\phi = '+ str(phis[20]-0.001) + r'$',ax=ax2) ppl.plot( alphas[np.argmin(eps[:,20])] , np.min(eps[:,20]), 'o',color=l2.get_color(),ax=ax2) l3, = ppl.plot( alphas, eps[:,30], label=r'$\phi = '+ str(phis[30]-0.001) + r'$',ax=ax2) ppl.plot( alphas[np.argmin(eps[:,30])] , np.min(eps[:,30]), 'o',color=l3.get_color(),ax=ax2) l4, = ppl.plot( alphas, eps[:,40], label=r'$\phi = '+ str(phis[40]-0.001) + r'$',ax=ax2) ppl.plot( alphas[np.argmin(eps[:,40])] , np.min(eps[:,40]), 'o',color=l4.get_color(),ax=ax2)
dalpha = alphas[1]-alphas[0] dthetas2,alphas2 = np.meshgrid(np.arange(dthetas.min(),dthetas.max()+0.5*ddtheta,ddtheta)-ddtheta/2, np.arange(alphas.min(),alphas.max()+0.5*dalpha,dalpha)-dalpha/2) p1 = ax2.pcolormesh(dthetas2,alphas2,dense_eps.T,cmap=yellorred,rasterized=True) ax2.axis([dthetas2.min(),dthetas2.max(),alphas2.min(),alphas2.max()]) p2 = ax3.pcolormesh(dthetas2,alphas2,sparse_eps.T,cmap=yellorred,rasterized=True) ax3.axis([dthetas2.min(),dthetas2.max(),alphas2.min(),alphas2.max()]) p3 = ax4.pcolormesh(dthetas2,alphas2,particle_eps.T,cmap=yellorred,rasterized=True) ax4.axis([dthetas2.min(),dthetas2.max(),alphas2.min(),alphas2.max()]) ticks = np.array([mintotal,(mintotal+maxtotal)/2,maxtotal]) ticklabels = np.round(ticks,decimals=2) cb1 = plt.colorbar(p1,ax=ax2) cb1.set_ticks(ticks) cb1.set_ticklabels(ticklabels) cb2 = plt.colorbar(p2,ax=ax3) cb2.set_ticks(ticks) cb2.set_ticklabels(ticklabels) cb3 = plt.colorbar(p3,ax=ax4) cb3.set_ticks(ticks) cb3.set_ticklabels(ticklabels) ax4.set_xlabel(r'$\Delta\theta$') ax4.set_ylabel(r'$\alpha$') ax3.set_ylabel(r'$\alpha$') ax2.set_ylabel(r'$\alpha$') ax3.axes.get_xaxis().set_ticks([])