plot_maps

plot_maps(*args, layout=None, view=None, area=None, use_eccharts=False, title_font_size=0.4, legend_font_size=0.35, frame=-1, animate='auto')

New in metview-python version 1.8.0

High level function with automatic styling to generate map-based plots.

Parameters
  • layout (str) – specifies the grid layout as “RxC” where R is the number of rows while C is the number of columns. E.g. “2x1” means 2 rows and 1 column. If it is not set the layout is automatically guessed from the input arguments.

  • view (geoview()) – specifies the map view as a geoview(). If area is also specified the projection in the view is changed to cylindrical (but the map style is kept). See make_geoview() on how to build a view with predefined areas and map styles.

  • area (str or list) – specifies the map area. It can be either a named built-in area or a list in the format of [S, W, N, E]. When area is a list a cylindrical map projection is used.

  • use_eccharts (bool) – when it is True the automatic styling mechanism is bypassed and an mcont() object with the ecCharts style and legend enabled is applied to all input Fieldset data.

  • title_font_size (number) – specifies the font size in cm for the plot title

  • legend_font_size (number) – specifies the font size in cm for the plot legend

  • frame (number) – specifies which animation frames should be plotted, -1 means all the frames will be plotted

  • animate (str or bool) – controls the plotting of multiple animation frames

plot_maps() is a convenience function allowing to plot data in a simple way using predefined settings.

Data

The data and the corresponding styles are defined by the positional arguments (*args). In the argument list a data object can be followed by any number of visual definitions, which define the plotting style for the given data. If no style is specified for a data object the style will be automatically generated using the currently loaded style configuration.

Automatic data styling

The automatic styling is only available for Fieldset and Track data.

For a Fieldset the assumption is that it only contains fields of the same parameter. The automatic styling is therefore only checks the first two fields to infer if it is scalar or vector data and what the parameter is. The style (mcont() or mwind() in this case) is then selected from the current style configuration. If no style configuration is loaded the built-in style is used, which for most of the parameters is equivalent to the ecCharts style.

If use_eccharts is True the above mentioned automatic styling mechanism is bypassed and an mcont() object with the ecCharts style and legend enabled is applied to all the Fieldset data. This can be useful when a Fieldset contains multiple parameters. Please note that the following plot_maps() calls are equivalent:

import metview as mv
g = mv.read("my.grib")

c = mv.mcont(contour_automatic_settings="ecmwf", legend="on")
mv.plot_maps(g, c)

mv.plot_maps(g, use_eccharts=True)

Layout

The positional arguments (*args) must either contain non-list values or all of them must be list. In the latter case each list is supposed to describe a sup-plot. The actual grid-layout is then automatically guessed unless layout directly prescribes it. The following example demonstrates the various layout options:

import metview as mv

# grib data with t, z and msl
g = mv.read("my.grib")
t = g["t500"]
z = g["z500"]
msl = g["msl"]

# overlay - single map
mv.plot_maps(t, z)

# two maps - guessed layout (1x2)
mv.plot_maps([t], [z])

# two maps - prescribed 2x1 layout
mv.plot_maps([t], [z], layout="2x1")

# two maps - overlay, prescribed 2x1 layout
mv.plot_maps([msl], [t,z], layout="2x1")

Limitations

While the data and map view styles can be fully customised, the title and legend are automatically built and no control is offered over them.

Notebooks using metview.plot_maps