[Matplotlib-users] Declarative interface to matplotlib

Ryan May rmay31 at gmail.com
Sun Aug 23 15:30:50 EDT 2020


Hi,

The MetPy project has worked on a declarative, matplotlib-based plotting
interface:

  https://unidata.github.io/MetPy/latest/examples/index.html#plotting
  https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.html
  https://unidata.github.io/python-training/gallery/declarative_500_hpa/

This focuses, though, on domain-specific applications in meteorology and
atmospheric science, leveraging the traitlets library. The interface was
also designed to facilitate transition away from a legacy, declarative-like
plotting tool.

Not claiming by any means we have the interface perfect. We spent a lot of
time trying to come up with new names for Figure and Axes in this interface
since we did not want to collide with matplotlib's own classes. Honestly,
the basic interface is pretty trivial to create (at least using traitlets).
The challenge is to handle state update and invalidation properly when
trying to support interactive use cases (especially when all of the classes
are thin wrappers around matplotlib state).

Ryan

On Sun, Aug 23, 2020 at 11:39 AM Ram Rachum <ram at rachum.com> wrote:

> Hi everyone,
>
> I'd like to ask you a general question, as someone who isn't very
> experienced with matplotlib.
>
> I noticed that matplotlib is very imperative, in contrast to declarative.
> For example, I wanted to show an `imshow` plot with a colorbar, so I needed
> to first create the plot, then run `plt.colorbar()`, then show the plot. In
> more complicated plots, you could be doing 10+ actions one after another to
> create a plot.
>
> I would find a declarative interface to be much more elegant, i.e. one
> call to create the plot and lots of keyword arguments, some of them nested,
> to specify all the options. Of course, matplotlib being a very mature
> project, the current interface must be maintained forever. But, do you know
> of any such declarative interface to matplotlib? Either as part of the
> library, or a separate library that uses matplotlib?
>
> If such a thing doesn't exist, what would you think about adding one?
>
>
> Thanks,
> Ram.
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>


-- 
Ryan May
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20200823/518e0c8f/attachment.html>


More information about the Matplotlib-users mailing list