83 points · by belter · 5y ago · 26 comments
It makes, by example, a pretty strong argument for not allowing multiple ways of doing something.
I often use the imperative API as it’s less typing often, and I do a lot of throwaway plotting code. But some functionality only exists in the OO interface. Then it’s an easy trip to gca().my_oo_function() and you recovered the imperative version.
fig, ax = plt.subplots()
then make calls on the Figure and Axes objects.See bokeh (in python) and makie, gadfly, plots, and AlgebraOfGraphics (in julia) for yet more styles of making high level plots. But again, matplotlib targets users needing more control and less statistics (people build stats and other libraries on top of matplotlib though).
Matplotlib is the best I can find for this, despite the sometimes clunky interface. GNUplot is also good, but its easier to have a native python library.
One more thing I'll say that had heavily biased me, I started off with Matlab, and I find that matplotlib is the closest to Matlab plotting, which is a lot of why I like it.
For a ggplot grammar-of-graphics style library in Python, I really like Altair: https://altair-viz.github.io/
I wouldn’t even consider the two to have different purposes. Let alone “drastically” different. Drastically different api’s? Definitely. But purpose? No way.
I claim it's worlds better.
I'm mostly using Altair instead these days since my data is mostly tabular, but Matplotlib still maintains a position in my toolbox and helps me when I need some dirty (or creative) visualization that is tricky with Altair.
And to be honest, I occasionally miss Matplotlib's dense API when I'm fed up with the verbosity Altair has. Yes Altair code is more readable, I agree with the proposition, but being quick and dirty can be lovely sometimes.
I wrote up a blogpost about my findings on how to generate monochrome plots. I haven’t really used matplotlibs since my thesis days, but it’s kinda funny to see what my thoughts back then were on the interface.
I found the OO interface a necessary evil and that you have to mix interfaces to get full control of your plots.
Maybe things have been ironed out in the past 5 years? Reading the comments here it seems like the sentiment is that the OO interface is considered the sane, true interface.
http://olsgaard.dk/monochrome-black-white-plots-in-matplotli...
I haven’t used matplotlib since! (over 2 years)