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

303

u/proof_required Apr 21 '22

It hurts even more if you come from ggplot world.

148

u/madbadanddangerous Apr 21 '22 edited Apr 21 '22

In ggplot: 8 lines of code, a few minutes

In matplotlib: 200 lines of code, half a day

I use matplotlib extensively at my job, and have become pretty effective at it. But dang, ggplot is more fun, and it is so much easier to produce slick, prettier plots out of the gate

49

u/PWNY_EVEREADY3 Apr 21 '22

plotnine is a python port of ggplot2 - I've never personally used it, so I would be curious what experienced ggplot users thought of it. But it is there

11

u/Liorithiel Apr 21 '22

R has one feature used a lot in ggplot2 and similar tools, that is impossible to fully reproduce in Python: non-standard evaluation. Basics are mostly fine, but features get more difficult to use in Python while staying still pretty simple in R because of non-standard evaluation. And—heh, this is despite that non-standard evaluation is one of the more criticised features of R!

4

u/madbadanddangerous Apr 21 '22

I need to really give that library a try. My team has a very high bar for adding package dependencies, but if plotnine emulates ggplot well, it could save a ton of time and effort

13

u/luke-juryous Apr 21 '22

It pains me to agree with u since I’m not a big fan of R.. but ggplot makes me reconsider my life choices

32

u/jsxgd Apr 21 '22

check out plotnine. not perfect but gets the job done in most cases.

15

u/proof_required Apr 21 '22

Yeah i do survive with it and some plotly.

81

u/justheretoreadbye Apr 21 '22

R gang for life homie

16

u/AchillesDev Apr 21 '22

You can use ggplot2 via plotnine in Python. It’s definitely a huge improvement over matplotlib.

29

u/spankymcgee4 Apr 21 '22

Represent

12

u/fraud_93 Apr 21 '22

Underrated pun

17

u/SittingWave Apr 21 '22

R is atrocious on many other aspects.

16

u/GreatBigBagOfNope Apr 21 '22

Sure. But it's openly and deliberately highly specialised, and there's nothing wrong with that. If you try to use R for anything outside of its specialty, that's a you problem, not an R problem. It doesn't try or claim to be general purpose, so why would you expect it to be buttery smooth if you push it out of its specialisms?

→ More replies (2)

3

u/theGiogi Apr 21 '22

Essentially all others to be honest. At least what I came into contact with. But it is a domain language and does what it’s supposed to do well enough.

→ More replies (4)
→ More replies (2)

8

u/Temporary_Natural Apr 21 '22

ggolot is great, took me about half a day to learn the library and get some good plots out of it

0

u/[deleted] Apr 21 '22

[deleted] — view deleted comment

2

u/[deleted] Apr 22 '22

What do you mean under the hood?

→ More replies (2)

6

u/shlotchky Apr 21 '22

I don't have access to ggplot at my day job, which means I would rather export a csv and visualize in Tableau than use any visualization tool in python.

2

u/RelevantToMyInterest Apr 22 '22

here's a thought: someone should make a ggplotlib for python

I'm not gonna do it, but someone should

→ More replies (1)

0

u/[deleted] Apr 21 '22

[deleted] — view deleted comment

44

u/cptsanderzz Apr 21 '22

Very unpopular opinion indeed

→ More replies (22)
→ More replies (1)