Skip to content

Importing a matplotlib figure as a subfigure #71

Open

Description

@wolke-wanderer

Is your feature request related to a problem? Please describe.

I've made a figure in matplotlib of a combination of some timeseries that I would like to plot alongside some maps generated with metview. Is there a way to directly import a matplotlib figure as a subplot in mv.mvl_regular_layout or mv.plot_superpage? (Or alternatively to export objects that matplotlib can natively work with?)

Describe the solution you'd like

A way to export from mv.plot as matplotlib fig, axs objects

Describe alternatives you've considered

Remaking the entire plot within existing metview functions, but this is cumbersome and package lock-in.

Additional context

No response

Organisation

KNMI

Activity

  1. iainrussell commented on Aug 18, 2025

    @iainrussell
    Member

    Hi @wolke-wanderer, I guess there are two ways that could work, although neither is completely efficient.

    1. if you can export your matplotlib plot to a PNG file, then you should be able to import it into your Metview plot using the mimport() function https://metview.readthedocs.io/en/latest/gen_files/icon_functions/mimport.html. This is something that can be plotted onto a page.
    2. depending on exactly how you have your layout defined, you can export any Metview plot to PNG (or PDF/SVG) and then import this into matplotlib. See https://metview.readthedocs.io/en/latest/gen_files/toc/plot.html#graphical-output along with any Gallery example, e.g. https://metview.readthedocs.io/en/latest/gen_files/gallery/contour9.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions