def contourf(self, data, gpfcmap=None, cbar=False, cbardict=None, ip=1, vline=None, vlinedict=None, **kwargs): cbardict = cbardict or {} vlinedict = vlinedict or {} if gpfcmap: kwargs = merge_dict(kwargs, gpf.cmap(gpfcmap)) unit = kwargs.pop('unit', None) xx, yy, data = self.transform_data(data, ip) kwargs.update(transform=self.ax.projection) c = self.ax.contourf(xx, yy, data, **kwargs) if cbar: if 'ticks' not in cbardict: levels = kwargs['levels'] step = len(levels) // 40 + 1 cbardict.update(ticks=levels[::step]) if 'extend' in kwargs: cbardict.update(extend=kwargs.pop('extend'), extendfrac=0.02) self.colorbar(c, unit=unit, **cbardict) if vline is not None: if 'color' not in vlinedict: vlinedict.update(colors='w') if 'lw' not in vlinedict: vlinedict.update(linewidths=0.6) else: vlinedict.update(linewidths=vlinedict.pop('lw')) vlinedict.update(transform=self.ax.projection) self.ax.contour(xx, yy, data, levels=[vline], **vlinedict) return c
def pcolormesh(self, data, gpfcmap=None, cbar=False, cbardict=dict(), ip=1, **kwargs): if gpfcmap: import matplotlib.colors as mclr gpfdict = gpf.cmap(gpfcmap) cmap = gpfdict.pop('cmap') levels = gpfdict.pop('levels') norm = mclr.BoundaryNorm(levels, ncolors=cmap.N, clip=True) kwargs.update(cmap=cmap, norm=norm) x, y, data = self.interpolation(data, ip) ret = self.ax.pcolormesh(x, y, data, **kwargs) if cbar: if 'ticks' not in cbardict: levels = gpfdict['levels'] step = len(levels) // 40 + 1 cbardict.update(ticks=levels[::step]) cbardict.update(size='2%', pad='1%') if 'extend' in gpfdict: cbardict.update(extend=gpfdict.pop('extend'), extendfrac=0.02) self.colorbar(ret, unit=gpfdict.pop('unit', None), **cbardict) return ret
def contourf(self, data, gpfcmap=None, cbar=False, cbardict=dict(), ip=1, vline=None, vlinedict=dict(), **kwargs): if gpfcmap: kwargs = merge_dict(kwargs, gpf.cmap(gpfcmap)) x, y, data = self.interpolation(data, ip) c = self.ax.contourf(x, y, data, **kwargs) if cbar: if 'ticks' not in cbardict: levels = kwargs['levels'] step = len(levels) // 40 + 1 cbardict.update(ticks=levels[::step]) if 'extend' in kwargs: cbardict.update(extend=kwargs.pop('extend'), extendfrac=0.02) self.colorbar(c, unit=kwargs.pop('unit', None), **cbardict) if vline is not None: if 'color' not in vlinedict: vlinedict.update(colors='w') if 'lw' not in vlinedict: vlinedict.update(linewidths=0.6) else: vlinedict.update(linewidths=vlinedict.pop('lw')) self.ax.contour(x, y, data, levels=[vline], **vlinedict) return c
def imshow(self, im, gpfcmap=None, extent=None, **kwargs): kwargs.update(transform=ccrs.PlateCarree(), interpolation='nearest') if extent is None: kwargs.update(extent=self.map_georange[2:]+self.map_georange[:2]) if gpfcmap: cmapdict = gpf.cmap(gpfcmap) levels = cmapdict['levels'] vmin = levels.min() vmax = levels.max() kwargs.update(cmap=cmapdict['cmap'], vmin=vmin, vmax=vmax) ret = self.ax.imshow(im, **kwargs) return ret