From 0c323e4a4ecc5304f075a97168f10294b0da41a9 Mon Sep 17 00:00:00 2001 From: Manuel Schlund <32543114+schlunma@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:37:20 +0200 Subject: [PATCH] Prevent overlapping time axis tick labels in monitoring recipe (#3682) --- .../diag_scripts/monitor/multi_datasets.py | 90 ++++++++++--------- .../monitor/recipe_monitor_with_refs.yml | 6 +- 2 files changed, 54 insertions(+), 42 deletions(-) diff --git a/esmvaltool/diag_scripts/monitor/multi_datasets.py b/esmvaltool/diag_scripts/monitor/multi_datasets.py index a760a312f6..c87fd26cac 100644 --- a/esmvaltool/diag_scripts/monitor/multi_datasets.py +++ b/esmvaltool/diag_scripts/monitor/multi_datasets.py @@ -138,12 +138,12 @@ pyplot_kwargs: dict, optional Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the datasets plotted in the - corresponding plot, e.g., ``{short_name}``, ``{exp}``. Facets like - ``{project}`` that vary between the different datasets will be transformed - to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot - of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + argument(s) for these functions (if values are dictionaries, these are + interpreted as keyword arguments; otherwise a single argument is assumed). + String arguments can include facets in curly brackets which will be derived + from the corresponding dataset, e.g., ``{project}``, ``{short_name}``, + ``{exp}``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: + '{short_name}'``, ``xlim: [0, 5]``. time_format: str, optional (default: None) :func:`~datetime.datetime.strftime` format string that is used to format the time axis using :class:`matplotlib.dates.DateFormatter`. If ``None``, @@ -171,12 +171,12 @@ pyplot_kwargs: dict, optional Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the datasets plotted in the - corresponding plot, e.g., ``{short_name}``, ``{exp}``. Facets like - ``{project}`` that vary between the different datasets will be transformed - to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot - of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + argument(s) for these functions (if values are dictionaries, these are + interpreted as keyword arguments; otherwise a single argument is assumed). + String arguments can include facets in curly brackets which will be derived + from the corresponding dataset, e.g., ``{project}``, ``{short_name}``, + ``{exp}``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: + '{short_name}'``, ``xlim: [0, 5]``. Configuration options for plot type ``map`` ------------------------------------------- @@ -247,10 +247,12 @@ pyplot_kwargs: dict, optional Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the corresponding dataset, e.g., - ``{project}``, ``{short_name}``, ``{exp}``. Examples: ``title: 'Awesome - Plot of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + argument(s) for these functions (if values are dictionaries, these are + interpreted as keyword arguments; otherwise a single argument is assumed). + String arguments can include facets in curly brackets which will be derived + from the corresponding dataset, e.g., ``{project}``, ``{short_name}``, + ``{exp}``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: + '{short_name}'``, ``xlim: [0, 5]``. rasterize: bool, optional (default: True) If ``True``, use rasterization_ for map plots to produce smaller files. This is only relevant for vector graphics (e.g., ``output_file_type: @@ -326,10 +328,12 @@ pyplot_kwargs: dict, optional Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the corresponding dataset, e.g., - ``{project}``, ``{short_name}``, ``{exp}``. Examples: ``title: 'Awesome - Plot of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + argument(s) for these functions (if values are dictionaries, these are + interpreted as keyword arguments; otherwise a single argument is assumed). + String arguments can include facets in curly brackets which will be derived + from the corresponding dataset, e.g., ``{project}``, ``{short_name}``, + ``{exp}``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: + '{short_name}'``, ``xlim: [0, 5]``. rasterize: bool, optional (default: True) If ``True``, use rasterization_ for profile plots to produce smaller files. This is only relevant for vector graphics (e.g., ``output_file_type: @@ -378,12 +382,12 @@ pyplot_kwargs: dict, optional Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the datasets plotted in the - corresponding plot, e.g., ``{short_name}``, ``{exp}``. Facets like - ``{project}`` that vary between the different datasets will be transformed - to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot - of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + argument(s) for these functions (if values are dictionaries, these are + interpreted as keyword arguments; otherwise a single argument is assumed). + String arguments can include facets in curly brackets which will be derived + from the corresponding dataset, e.g., ``{project}``, ``{short_name}``, + ``{exp}``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: + '{short_name}'``, ``xlim: [0, 5]``. show_y_minor_ticklabels: bool, optional (default: False) Show tick labels for the minor ticks on the Y axis. @@ -409,12 +413,12 @@ pyplot_kwargs: dict, optional Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the datasets plotted in the - corresponding plot, e.g., ``{short_name}``, ``{exp}``. Facets like - ``{project}`` that vary between the different datasets will be transformed - to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot - of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + argument(s) for these functions (if values are dictionaries, these are + interpreted as keyword arguments; otherwise a single argument is assumed). + String arguments can include facets in curly brackets which will be derived + from the corresponding dataset, e.g., ``{project}``, ``{short_name}``, + ``{exp}``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: + '{short_name}'``, ``xlim: [0, 5]``. Configuration options for plot type ``hovmoeller_z_vs_time`` ------------------------------------------------------------ @@ -476,10 +480,12 @@ pyplot_kwargs: dict, optional Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the corresponding dataset, e.g., - ``{project}``, ``{short_name}``, ``{exp}``. Examples: ``title: 'Awesome - Plot of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + argument(s) for these functions (if values are dictionaries, these are + interpreted as keyword arguments; otherwise a single argument is assumed). + String arguments can include facets in curly brackets which will be derived + from the corresponding dataset, e.g., ``{project}``, ``{short_name}``, + ``{exp}``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: + '{short_name}'``, ``xlim: [0, 5]``. rasterize: bool, optional (default: True) If ``True``, use rasterization_ for profile plots to produce smaller files. This is only relevant for vector graphics (e.g., ``output_file_type: @@ -559,10 +565,12 @@ pyplot_kwargs: dict, optional Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the corresponding dataset, e.g., - ``{project}``, ``{short_name}``, ``{exp}``. Examples: ``title: 'Awesome - Plot of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + argument(s) for these functions (if values are dictionaries, these are + interpreted as keyword arguments; otherwise a single argument is assumed). + String arguments can include facets in curly brackets which will be derived + from the corresponding dataset, e.g., ``{project}``, ``{short_name}``, + ``{exp}``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: + '{short_name}'``, ``xlim: [0, 5]``. rasterize: bool, optional (default: True) If ``True``, use rasterization_ for profile plots to produce smaller files. This is only relevant for vector graphics (e.g., ``output_file_type: @@ -1791,6 +1799,8 @@ def _process_pyplot_kwargs(self, plot_type, dataset): ) if arg is None: getattr(plt, func)() + elif isinstance(arg, dict): + getattr(plt, func)(**arg) else: getattr(plt, func)(arg) diff --git a/esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml b/esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml index 681277310c..48c5153287 100644 --- a/esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml +++ b/esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml @@ -225,7 +225,7 @@ diagnostics: ta: preprocessor: global_mean_extract_levels mip: Amon - timerange: '2000/2004' + timerange: '2000/2005' scripts: plot: <<: *plot_multi_dataset_default @@ -238,6 +238,8 @@ diagnostics: log_y: false pyplot_kwargs: ylim: [0, 20000] + xticks: + rotation: 25 plot_time_vs_lat_with_references: description: Plot Hovmoeller time vs. latitude including reference datasets. @@ -245,7 +247,7 @@ diagnostics: tas: mip: Amon preprocessor: zonal_mean_2d - timerange: '2000/2004' + timerange: '2000/2005' scripts: plot: <<: *plot_multi_dataset_default