Skip to content

Commit

Permalink
Prevent overlapping time axis tick labels in monitoring recipe (#3682)
Browse files Browse the repository at this point in the history
  • Loading branch information
schlunma authored Jun 25, 2024
1 parent b946c9b commit 0c323e4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 42 deletions.
90 changes: 50 additions & 40 deletions esmvaltool/diag_scripts/monitor/multi_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``,
Expand Down Expand Up @@ -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``
-------------------------------------------
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -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``
------------------------------------------------------------
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -238,14 +238,16 @@ 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.
variables:
tas:
mip: Amon
preprocessor: zonal_mean_2d
timerange: '2000/2004'
timerange: '2000/2005'
scripts:
plot:
<<: *plot_multi_dataset_default
Expand Down

0 comments on commit 0c323e4

Please sign in to comment.