figures ======= .. py:module:: figures Classes ------- .. autoapisummary:: figures.Figure Functions --------- .. autoapisummary:: figures.resize_figure_to_fit_axes Module Contents --------------- .. py:class:: Figure(rows=None, columns=None, size=None, domain=None, crs=None, **kwargs) The overall canvas onto which subplots are drawn. A Figure is a container for one or more Subplots, each of which can contain one or more Layers. The Figure is responsible for managing the layout of Subplots and Layers, as well as providing methods for adding common elements like legends and titles. :param rows: The number of rows in the figure. :type rows: int, optional :param columns: The number of columns in the figure. :type columns: int, optional :param size: The size of the figure in inches. This can be a list or tuple of two floats representing the width and height of the figure. :type size: list, optional :param domain: The domain of the data being plotted. This is used to set the extent and projection of the map. :type domain: earthkit.geo.Domain, optional :param kwargs: Additional keyword arguments to pass to matplotlib.gridspec.GridSpec. :type kwargs: dict, optional .. py:method:: add_map(row=None, column=None, domain=None, crs=None, **kwargs) Add a map to the figure. :param row: The row in which to place the subplot. :type row: int, optional :param column: The column in which to place the subplot. :type column: int, optional :param domain: The domain of the data being plotted. This is used to set the extent and projection of the map. :type domain: earthkit.geo.Domain, optional :param kwargs: Additional keyword arguments to pass to the Map constructor. :type kwargs: dict, optional .. py:method:: add_subplot(row=None, column=None, **kwargs) Add a subplot to the figure. :param row: The row in which to place the subplot. :type row: int, optional :param column: The column in which to place the subplot. :type column: int, optional :param kwargs: Additional keyword arguments to pass to the Subplot constructor. :type kwargs: dict, optional .. py:method:: administrative_areas(*args, **kwargs) Add administrative areas to every `Map` subplot in the figure. :param Accepts the same arguments as `Map.administrative_areas`.: .. py:method:: apply_to_subplots() Decorator to apply a method to all subplots in the figure. .. py:method:: block(*args, **kwargs) .. py:method:: borders(*args, **kwargs) Add borders to every `Map` subplot in the figure. :param Accepts the same arguments as `Map.borders`.: .. py:method:: coastlines(*args, **kwargs) Add coastlines to every `Map` subplot in the figure. :param Accepts the same arguments as `Map.coastlines`.: .. py:attribute:: columns :value: None .. py:method:: contour(*args, **kwargs) .. py:method:: contourf(*args, **kwargs) .. py:method:: countries(*args, **kwargs) Add countries to every `Map` subplot in the figure. :param Accepts the same arguments as `Map.countries`.: .. py:method:: defer_subplot() .. py:method:: defer_until_setup() .. py:method:: distinct_legend_layers(subplots=None) Get a list of layers with distinct styles. :param subplots: If provided, only these subplots will be considered when identifying unique styles. :type subplots: list, optional .. py:attribute:: fig :value: None .. py:method:: format_string(string, unique=True, grouped=True) .. py:method:: gridlines(*args, sharex=True, sharey=True, **kwargs) Add gridlines to every `Map` subplot in the figure. :param sharex: If True, only the bottom row of subplots will have x-axis gridlines. :type sharex: bool, optional :param sharey: If True, only the leftmost column of subplots will have y-axis gridlines. :type sharey: bool, optional :param kwargs: Additional keyword arguments to pass to the `Map.gridlines` method. :type kwargs: dict, optional .. py:method:: gridpoints(*args, **kwargs) .. py:attribute:: gridspec :value: None .. py:method:: iterate_subplots() Decorator to iterate simultaneously over data and subplots. .. py:method:: land(*args, **kwargs) Add land polygons to every `Map` subplot in the figure. :param Accepts the same arguments as `Map.land`.: .. py:method:: legend(*args, subplots=None, location=None, **kwargs) Add legends to the figure. :param subplots: If provided, only these subplots will have legends. :type subplots: list, optional :param location: The location of the legend. If a list, each item is the location for the corresponding subplot. :type location: str or list, optional :param kwargs: Additional keyword arguments to pass to the Subplot legend method. :type kwargs: dict, optional .. py:method:: pcolormesh(*args, **kwargs) .. py:method:: plot(*args, **kwargs) .. py:method:: quickplot(*args, **kwargs) .. py:method:: resize() .. py:attribute:: rows :value: None .. py:method:: save(*args, bbox_inches='tight', **kwargs) Save the figure to a file. :param fname: The file to which to save the figure. :type fname: str or file-like object :param bbox_inches: The bounding box in inches to use when saving the figure. :type bbox_inches: str, optional :param kwargs: Additional keyword arguments to pass to matplotlib.pyplot.savefig. :type kwargs: dict, optional .. py:method:: setup() Decorator to set up the figure before calling a method. .. py:method:: show(*args, **kwargs) Display the figure. .. py:method:: standard_layers(*args, **kwargs) Add quick layers to every `Map` subplot in the figure. :param Accepts the same arguments as `Map.quick_layers`.: .. py:method:: stock_img(*args, **kwargs) Add a stock image to every `Map` subplot in the figure. :param Accepts the same arguments as `Map.stock_img`.: .. py:method:: subplot_titles(*args, **kwargs) Set the titles of all subplots. :param label: The text to use in the title. This text can include format keys surrounded by `{}` curly brackets, which will extract metadata from your plotted data layers. :type label: str, optional :param unique: If True, format keys which are uniform across subplots/layers will produce a single result. For example, if all data layers have the same `variable_name`, only one variable name will appear in the title. If False, each format key will evaluate to a list of values found across subplots/layers. :type unique: bool, optional :param kwargs: Additional keyword arguments to pass to the matplotlib.pyplot.title method. :type kwargs: dict, optional .. py:attribute:: subplots :value: [] .. py:method:: title(label=None, unique=True, grouped=True, y=None, **kwargs) Add a top-level title to the chart. :param label: The text to use in the title. This text can include format keys surrounded by `{}` curly brackets, which will extract metadata from your plotted data layers. :type label: str, optional :param unique: If True, format keys which are uniform across subplots/layers will produce a single result. For example, if all data layers have the same `variable_name`, only one variable name will appear in the title. If False, each format key will evaluate to a list of values found across subplots/layers. :type unique: bool, optional :param grouped: If True, a single title will be generated to represent all data layers, with each format key evaluating to a list where layers differ - e.g. `"{variable} at {time}"` might be evaluated to `"temperature and wind at 2023-01-01 00:00". If False, the title will be duplicated by the number of subplots/ layers - e.g. `"{variable} at {time}"` might be evaluated to `"temperature at 2023-01-01 00:00 and wind at 2023-01-01 00:00". :type grouped: bool, optional :param kwargs: Keyword argument to matplotlib.pyplot.suptitle (see https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.suptitle.html#matplotlib-pyplot-suptitle ). :type kwargs: dict, optional .. py:method:: urban_areas(*args, **kwargs) Add urban areas to every `Map` subplot in the figure. :param Accepts the same arguments as `Map.urban_areas`.: .. py:function:: resize_figure_to_fit_axes(fig) Adjust the size of a Matplotlib figure so that it fits its axes perfectly. Parameters: - fig: A Matplotlib Figure object.