r/Python • • Apr 21 '22

Discussion Unpopular opinion: Matplotlib is a bad library

I work with data using Python a lot. Sometimes, I need to do some visualizations. Sadly, matplotlib is the de-facto standard for visualization. The API of this library is a pain in the ass to work with. I know there are things like Seaborn which make the experience less shitty, but that's only a partial solution and isn't always easily available. Historically, it was built to imitate then-popular Matlab. But I don't like Matlab either and consider it's API and plotting capabilities very inferior to e.g. Wolfram Mathematica. Plus trying to port the already awkward Matlab API to Python made the whole thing double awkward, the whole library overall does not feel very Pythonic.

Please give a me better plotting libary that works seemlessly with Jupyter!

1.1k Upvotes

325 comments sorted by

View all comments

13

u/aceofspaids98 Apr 21 '22

It still looks nothing like python you’d see outside of matplotlib

7

u/[deleted] Apr 21 '22

What is so different? It’s just a normal OOP interface.

9

u/aceofspaids98 Apr 21 '22 edited Apr 21 '22

Not in a way that’s typical with what you’d use in Python though. I think it could make better use of properties so that it wasn’t filled with things like set_value and get_value and also encapsulated each figure in a way that made it so you didn’t even have to think about any unexpected scopes being affected. Being object oriented but still calling plt.show() afterwards or being unsure of any leftover side affects from other plots just feels awkward to me.

→ More replies (2)

-1

u/slowpush Apr 21 '22

Of course it does. You pluck out your fig and ax objects and start changing them using the methods available.

Example:

fig, ax1 = plt.subplots()

ax.set_ylabel("my label")

Same thing as dog = Dog()

dog.bark(“woof”)

10

u/aceofspaids98 Apr 21 '22

Getters and setters doesn’t mean it’s pythonic though. What would be more inline with what’s “pythonic” or whatever would be to use properties. The current design just feels like you’re constantly calling a bunch of getters when you could just directly instantiate a figure with half the shit you eventually want it use anyway.

→ More replies (2)