enstools.plot.contour¶
- enstools.plot.contour(variable, lon=None, lat=None, **kwargs)¶
Create a plot from an xarray variable that includes coordinates.
- Parameters:
- variablexarray.DataArray
the data to plot.
- lonxarray.DataArray or np.ndarray or str
longitude coordinate or name of longitude coordinate. The name may only be used for xarray variables.
- latxarray.DataArray or np.ndarray or str
latitude coordinate or name of longitude coordinate. The name may only be used for xarray variables.
- Other optional keyword arguments:
- **kwargs
- figure: matplotlib.figure.Figure
If provided, this figure instance will be used (and returned), otherwise a new figure will be created.
- axes: matplotlib.axes.Axes
If provided, this axes instance will be used (e.g., of overplotting), otherwise a new axes object will be created.
- subplot_args: tuple
Arguments passed on to add_subplot. These arguments are used only if no axes is provided.
- subplot_kwargs: dict
Keyword arguments passed on to add_subplot. These arguments are used only if no axes is provided.
- filled: [True | False]
If True a filled contour is plotted, which is the default
- colorbar: [True | False | “empty”]
If True, a colorbar is created. Default=True. Use empty to reserve space for the colorbar without actually creating it. This is usefull for multipanel plots, where one panel has a colorbar and another not.
- levels: np.ndarray
If provided, these levels are used, otherwise the levels are automatically selected.
- levels_center_on_zerobool
If true, automatically selected levels are centered around zero.
- gridlines: [True | False]
If True, coordinate grid lines are drawn. Default=False
- gridline_labes: [True | False]
Whether or not to label the grid lines. The default is not to label them.
- coastlines: [True | False | ‘110m’ | ‘50m’ | ‘10m’]
If True, coordinate grid lines are drawn. Default=True
- coastlines_kwargs: dict
dictionary with arguments passed on to ax.coastlines()
- borders: [True | False | ‘110m’ | ‘50m’ | ‘10m’]
If True, coordinate grid lines are drawn. Default=False
- projection: [ cartopy.crs.Projection]
If not None, the Projection object is used to create the plot
- rotated_pole: [xarray.DataArray | dict]
Information about the rotated pole. This can either be the CF-standard rotated_pole variable from an input file, or alternatively a dictionary with the keys grid_north_pole_latitude and grid_north_pole_longitude.
- All other arguments are forwarded to the matplotlib contour or contourf function.
- Returns:
- tuple
(Figure, Axes) of the new plot is returned. The returned values may be reused in subsequent calls to plot functions.
Examples
>>> fig, ax = enstools.plot.contour(data["TOT_PREC"][0, :, :], coastlines="50m")
24h ICON forecast for precipitation read from a grib2 file. Have a look at the script examples/example_plot_icon_01.py for more details.¶
>>> fig, ax1 = enstools.plot.contour(data["PMSL"][0, :] / 100.0, gridlines=True, subplot_args=(121,)) >>> fig, ax2 = enstools.plot.contour(data["TOT_PREC"][0, :], figure=fig, subplot_args=(122,))
24h ICON forecast for mean sea level pressure (left) and precipitation (right). The data was read from grib2 files on the native ICON grid and plotted without interpolation onto a regular grid. Have a look at the script examples/example_plot_icon_02.py¶