geocat.viz.NCL_Plot¶
- class geocat.viz.NCL_Plot(class_specific_kwargs_set, class_specific_kwarg_defaults, *args, **kwargs)¶
Parent class to create figure, axes, set NCL style with constructors to add colorbar, add titles, and show plot.Set up figure and axes with the specified style. Calls _set_up_fig if there is not a figure already created, _set_axes to create and style the axes, and _set_lim_ticks to constrain the axes. Adds geographic features to figure.
- Keyword Arguments
add_colorbar (
bool
) – Whether a colorbar is added to the figure. Default True.coastline_on (
bool
) – Whether to show coastlines in figure. Default False, unless a projection is specified.cb_draw_edges (
bool
) – Whether to draw edges on the colorbar. Default True.cb_orientation (
str
) – Placement of the colorbar. Default “horizontal”. Other option is “vertical”.cb_pad (
float
) – Padding between colorbar and figure. Default 0.11.cb_shrink (
float
) – Percent shrinkage of colorbar. Default 0.75.cb_tick_labels (
list
ornumpy.ndarray
) – Labels for colorbar ticks.cb_tick_label_size (
int
) – Font size for colorbar tick labels.cb_ticks (
list
ornumpy.ndarray
) – Ticks for colorbar.cmap (
str
orcmaps.colormap.Colormap
) – Colormap or colormap name for figure. Default ‘plasma’h (
float
) – Height of figure in inches. Default 8. To be passed into figsize when creating figure.individual_cb (
bool
) – Whether to draw individual colorbars for each subplot. Default False.label_font_size (
int
) – Fontsize for x and y axis labels. Default 16.lakes_on (
bool
) – Whether to show lakes in figure. Default False.land_on (
bool
) – Whether to show land in figure. Default False.left_title (
str
) – Title for top left subtitle.left_title_fontsize (
int
) – Font size for top left subtitle. Default 18.line_color (
str
orSequence
) – String of color name or sequence of colors. Default ‘black’.line_style (
str
) – Style of lines. Options: {None, ‘solid’, ‘dashed’, ‘dashdot’, ‘dotted’}, default None.line_width (
float
) – Width of lines. Default 0.4.main_title (
str
) – Title of figure.main_title_fontsize (
int
) – Font size for title of figure. Default 18.mappable (
cartopy.mpl.contour.GeoContourSet
) – The matplotlib.cm.ScalarMappable object that the colorbar represents. Mandatory when first creating colorbar, but not for subsequent calls.overlay (
contourf.Contour
) – Reference figure that the object will be created based on. For example, when overlaying plots or creating subplots, the overlay would be the name of the first plot.projection (
str
) – Cartopy map projection. See Cartopy documentation for full list.raxis (
bool
) – Whether to add right hand axis. Default False, unless type is ‘press_height’.raxis_label (
str
) – Label of right hand axisraxis_scale (
str
) – Scale of right hand axis.raxis_tick_label_fontsize (
float
) – Font size of tick labels on right hand axis.raxis_ticks (
list
ornumpy.ndarray
) – Ticks for right hand axis.right_title (
str
) – Title for top right subtitle.right_title_fontsize (
int
) – Font size for top right subtitle. Default 18.set_extent (
list
) – Extent [xmin, xmax, ymin, ymax] of figure to be shown.subplot (
list
) – List [number of rows, number of columns, position] to be passed into plt.subplot().tick_label_fontsize (
int
) – Font size of x and y axis ticks. Default 16.type (
str
) – Type of figure. Currently supports ‘press_height’ for Pressure/Height diagrams.X (
xarray.DataArray
ornumpy.ndarray
) – Data for x axis.w (
float
) – Weidth of the figure. Default 10. To be passed into figsize.xlabel (
str
) – Label for the x axis.xlim (
list
) – List [xmin, xmax] to set the limit of the x axis.xscale (
str
) – Scale of x axis. Currently supports “log”.tick_label_fontsize – Font size of x and y axis ticks. Default 16.
xtick_labels (
list
ornumpy.ndarray
) – List or array of tick labels for the x axis.xticks (
list
ornumpy.ndarray
) – List or array of tick values for the x axis.Y (
xarray.DataArray
ornumpy.ndarray
) – Data for y axis.ylabel (
str
) – Label for the y axis.ylim (
list
) – List [ymin, ymax] to set the limit of the y axis.yscale (
str
) – Scale of y axis. Currently supports “log”.ytick_labels (
list
ornumpy.ndarray
) – List or array of tick labels for the y axis.yticks (
list
ornumpy.ndarray
) – List or array of tick values for the y axis.
Methods
__init__
(class_specific_kwargs_set, ...)Sets up args and kwargs for figure.
add_colorbar
([mappable, cb_orientation, ...])Add colorbar to figure.
add_titles
([main_title, ...])Add titles to figure.
Get matplotlib object.
savefig
(filepath)Save figure.
show
()Display the plot.
show_coastline
([scale, lw, ec])Add coastlines to figure.
show_lakes
([scale, lw, ec, fc])Add lakes to figure.
show_land
([scale, fc])Add land to figure.
- add_colorbar(mappable=None, cb_orientation='horizontal', cb_shrink=0.8, cb_pad=0.075, cb_draw_edges=True, cb_ticks=None, cb_tick_labels=None, cb_tick_label_size=None)¶
Add colorbar to figure. If figure is a subplot, uses gridspec to add a cax to the appropriate place on the figure.
- Keyword Arguments
cb_draw_edges (
bool
) – Whether to draw edges on the colorbar. Default True.cb_orientation (
str
) – Placement of the colorbar. Default “horizontal”. Other option is “vertical”.cb_pad (
float
) – Padding between colorbar and figure. Default 0.11.cb_shrink (
float
) – Percent shrinkage of colorbar. Default 0.75.cb_tick_labels (
list
ornumpy.ndarray
) – Labels for colorbar ticks.cb_tick_label_size (
int
) – Font size for colorbar tick labels.cb_ticks (
list
ornumpy.ndarray
) – Ticks for colorbar.mappable (
cartopy.mpl.contour.GeoContourSet
) – The matplotlib.cm.ScalarMappable object that the colorbar represents. Mandatory when first creating colorbar, but not for subsequent calls.
- add_titles(main_title=None, main_title_fontsize=18, left_title=None, left_title_fontsize=18, right_title=None, right_title_fontsize=18, xlabel=None, ylabel=None, label_font_size=16)¶
Add titles to figure. If inputted dataset is an xarray file (or netCDF converted to xarray), will attempt to pull titles and labels from the datafile.
- Keyword Arguments
label_font_size (
int
) – Fontsize for x and y axis labels. Default 16.left_title (
str
) – Title for top left subtitle.left_title_fontsize (
int
) – Font size for top left subtitle. Default 18.main_title (
str
) – Title of figure.main_title_fontsize (
int
) – Font size for title of figure. Default 18.right_title (
str
) – Title for top right subtitle.right_title_fontsize (
int
) – Font size for top right subtitle. Default 18.xlabel (
str
) – Label for the x axis.ylabel (
str
) – Label for the y axis.
- get_mpl_obj()¶
Get matplotlib object.
- savefig(filepath)¶
Save figure.
- show()¶
Display the plot.
- show_coastline(scale='110m', lw=0.5, ec='black')¶
Add coastlines to figure.
- show_lakes(scale='110m', lw=0.5, ec='black', fc='None')¶
Add lakes to figure.