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

165 comments sorted by

View all comments

Show parent comment

1

u/ziggomatic_17 Aug 16 '21
import numpy as np
import pandas as pd
from plotnine import ggplot, aes, geom_histogram

data = np.randnormal(0, 0.5, 1000)
data = pd.DataFrame(data, columns=["value"])

(ggplot(dataframe, aes(x='value')) +
 geom_histogram())

I think this is more concise. The whole plotting code is basically one line because all of the boilerplate is no longer required.

2

u/[deleted] Aug 16 '21

Who was so petty as to downvote both of us?

Looks good, I'll play with plotnine.

1

u/johnbarnshack Sep 09 '21

All the boilerplate is no longer required - except of course putting everything into pandas. It just shifts the problem.