r/Python • • Aug 16 '21
Discussion Anyone else despises Matplotlib?
Every time I need to use mpl for a project I die a little inside. The API feels like using a completely different language, I simply can't make a basic plot without having to re-google stuff as everything feels anti intuitive.
Plus, the output bothers me too. Interactive plots feel extremely awkward, and its just wonky
EDIT: Despises working with matplotlib*. I'm thankful such a powerful library exists, and I get that for scientific papers and stuff like that it's great, but damn isn't it painful to use
711
Upvotes
View all comments
Show parent comment
2
u/DrShts Aug 16 '21
My simple example was just for demonstration purposes.
I think using
plt.plotand similar are discouraged because it works by keeping a hidden global state that is modified every time you callplt.something. This is why in a setting beyond a simple one-off plot the OO interface of matplotlib is usually recommended. And for a library that uses matplotlib having a hidden global state is pretty bad anyway.But what I actually wanted to point out was that even in articles / tutorials about using the OO interface of matplotlib (just look at the first results when searching for "matplotlib object oriented") the structure is always
while it's really rare that
matplotlib.figure.Figureis mentioned. This is strange to me because by using the OO way you're trying to shed all these unnecessary global state / GUI wrappers but then still usepltto create the figure (which calls the GUI wrappers) while there is a perfect alternative without that overhead in the form ofmatplotlib.figure.Figure.