subplots ======== .. py:module:: subplots Attributes ---------- .. autoapisummary:: subplots.DEFAULT_FORMATS subplots.TARGET_DENSITY subplots.ZERO_FORMATS Classes ------- .. autoapisummary:: subplots.Subplot Functions --------- .. autoapisummary:: subplots.thin_array Module Contents --------------- .. py:data:: DEFAULT_FORMATS :value: ['%Y', '%b', '%-d', '%H:%M', '%H:%M', '%S.%f'] .. py:class:: Subplot(row=0, column=0, figure=None, **kwargs) A single plot within a Figure. A Subplot is a container for one or more Layers, each of which is a plot of a single data source. :param row: The row index of the subplot in the Figure. :type row: int, optional :param column: The column index of the subplot in the Figure. :type column: int, optional :param figure: The Figure to which the subplot belongs. :type figure: Figure, optional :param \*\*kwargs: Additional keyword arguments to pass to the matplotlib Axes constructor. .. py:property:: ax The underlying matplotlib Axes object. .. py:method:: bar(*args, **kwargs) Plot a bar chart on the Subplot. :param data: The data to plot. If None, x and y must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the bar chart. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.bar`. .. py:method:: barbs(*args, **kwargs) Plot wind barbs on the Subplot. :param data: The data to plot. If None, x, y, u, and v must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param u: The u values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type u: str, list, numpy.ndarray, or xarray.DataArray, optional :param v: The v values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type v: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the wind barbs. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.barbs`. .. py:method:: block(*args, **kwargs) .. py:method:: coastlines(*args, **kwargs) :abstractmethod: .. py:attribute:: column :value: 0 .. py:method:: contour(*args, **kwargs) Plot a contour plot on the Subplot. :param data: The data to plot. If None, x, y, and z must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param z: The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type z: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the contour plot. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.contour`. .. py:method:: contourf(*args, **kwargs) Plot a filled contour plot on the Subplot. :param data: The data to plot. If None, x, y, and z must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param z: The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type z: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the filled contour plot. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.contourf`. .. py:property:: distinct_legend_layers Layers on this subplot which have a unique `Style`. .. py:attribute:: domain :value: None .. py:method:: envelope(data_1, data_2=0, alpha=0.4, **kwargs) .. py:property:: fig The underlying matplotlib Figure object. .. py:property:: figure .. py:method:: format_string(string, unique=True, grouped=True) Format a string with metadata from the Subplot. :param string: The string to format. This can contain metadata keys in curly braces, e.g. "{variable_name}". :type string: str :param unique: Whether to use unique metadata values from each Layer. If False, metadata values from all Layers are combined. :type unique: bool, optional :param grouped: Whether to group metadata values from all Layers into a single string. If False, metadata values from each Layer are listed separately. :type grouped: bool, optional .. py:attribute:: grid_cells .. py:method:: gridlines(*args, **kwargs) :abstractmethod: .. py:method:: hsv_composite(*args) .. py:method:: isolines(*args, **kwargs) .. py:method:: labels(data=None, label=None, x=None, y=None, **kwargs) .. py:attribute:: layers :value: [] .. py:method:: legend(style=None, location=None, **kwargs) Add a legend to the Subplot. :param style: The Style to use for the legend. If None (default), a legend is created for each Layer with a unique Style. If a single Style is provided, a single legend is created based on that Style. :type style: Style, optional :param location: The location of the legend(s). Must be a valid matplotlib location (see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html). :type location: str or tuple, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.legend`. .. py:method:: line(*args, **kwargs) Plot a line on the Subplot. :param data: The data to plot. If None, x and y must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the line. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.plot`. .. py:method:: pcolormesh(*args, **kwargs) Plot a pcolormesh on the Subplot. :param data: The data to plot. If None, x, y, and z must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param z: The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type z: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the pcolormesh. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.pcolormesh`. .. py:method:: plot(data, style=None, units=None, **kwargs) .. py:method:: plot_2D(extract_domain=False) .. py:method:: plot_3D(extract_domain=False) .. py:method:: plot_box() .. py:method:: plot_vector() .. py:method:: quantiles(data, quantiles=[0, 1], dim=None, alpha=0.15, **kwargs) .. py:method:: quickplot(data, style=None, units=None, **kwargs) .. py:method:: quiver(*args, **kwargs) Plot arrows on the Subplot. :param data: The data to plot. If None, x, y, u, and v must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param u: The u values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type u: str, list, numpy.ndarray, or xarray.DataArray, optional :param v: The v values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type v: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the quiver plot. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.quiver`. .. py:method:: rgb_composite(*args) .. py:attribute:: row :value: 0 .. py:method:: save(*args, **kwargs) Save the plot to a file. .. py:method:: scatter(*args, **kwargs) Plot a scatter plot on the Subplot. :param data: The data to plot. If None, x and y must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the scatter plot. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.scatter`. .. py:method:: set_major_xticks(frequency=None, format=None, highlight=None, highlight_color='red', **kwargs) .. py:method:: set_minor_xticks(frequency=None, format=None, **kwargs) .. py:method:: show() Display the plot. .. py:method:: title(label=None, unique=True, wrap=True, capitalize=True, **kwargs) Add a title to the plot. :param label: The title text. If None, a default template is used. The template can contain metadata keys in curly braces, e.g. "{variable_name}". :type label: str, optional :param unique: Whether to use unique metadata values from each Layer. If False, metadata values from all Layers are combined. :type unique: bool, optional :param wrap: Whether to wrap the title text. Default is True. :type wrap: bool, optional :param capitalize: Whether to capitalize the first letter of the title. Default is True. :type capitalize: bool, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.title`. .. py:method:: tricontour(*args, **kwargs) Plot a tricontour plot on the Subplot. :param data: The data to plot. If None, x, y, and z must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param z: The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type z: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the tricontour plot. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.tricontour`. .. py:method:: tricontourf(*args, **kwargs) Plot a filled tricontour plot on the Subplot. :param data: The data to plot. If None, x, y, and z must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param z: The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type z: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the filled tricontour plot. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.tricontourf`. .. py:method:: tripcolor(*args, **kwargs) Plot a tripcolor plot on the Subplot. :param data: The data to plot. If None, x, y, and z must be provided. :type data: list, numpy.ndarray, xarray.DataArray, or earthkit.data.core.Base, optional :param x: The x values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type x: str, list, numpy.ndarray, or xarray.DataArray, optional :param y: The y values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type y: str, list, numpy.ndarray, or xarray.DataArray, optional :param z: The z values to plot. If data is provided, this is assumed to be the name of a coordinate in the data. If None, data must be provided. :type z: str, list, numpy.ndarray, or xarray.DataArray, optional :param style: The Style to use for the tripcolor plot. If None, a Style is automatically generated based on the data. :type style: earthkit.plots.styles.Style, optional :param \*\*kwargs: Additional keyword arguments to pass to `matplotlib.pyplot.tripcolor`. .. py:data:: TARGET_DENSITY :value: 40 .. py:data:: ZERO_FORMATS :value: ['%Y', '%b', '%-d', '%H:%M', '%H:%M', '%S.%f'] .. py:function:: thin_array(array, every=2) Reduce the size of an array by taking every `every`th element. :param array: The array to thin. :type array: numpy.ndarray :param every: The number of elements to skip. :type every: int, optional