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/ogrinfo Oct 04 '21

I said it would be a while! Just looking at it now and I can't see how I can change to using Figure. We are actually using pandas to create the figure, calling DataFrame.plot. The only calls to plt are to set the font size then save the figure.

I've got an open SO question about it here. I've since changed the first line, so font size is set with a context manager, but I'm still having the image size problem.

with plt.style.context({'font.size': font_size}):
    ax = df.plot.bar(...)
    # etc
    plt.savefig(path, bbox_inches='tight')