TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Effectively Using Matplotlib (2017)

144 pointsby jjwisemanover 5 years ago

11 comments

smabieover 5 years ago
Matplotlib belongs to the worst category of software: very powerful and very awful. Nothing makes any sense and it’s so profoundly unintuitive it almost feels like I’m being pranked. But, of course, use it I must.<p>Pandas also comes off as an unintuitive joke, but my displeasure with it has <i>mostly</i> worn off. Matplotlib however makes me feel angry pretty much everyday.
评论 #21553468 未加载
评论 #21553689 未加载
评论 #21553667 未加载
评论 #21553144 未加载
urschreiover 5 years ago
Matplotlib is verbose, and has had an inconsistent API in the past (v3 has improved this a lot), but if you need to produce publication-quality figures using Python, taking the time to get comfortable with it pays off. I&#x27;ve been using it to produce maps and data visualisations for years – when I finally figure out how to make something look good, I put the notebook on Github, both for my own reference, and for others: <a href="https:&#x2F;&#x2F;github.com&#x2F;urschrei&#x2F;Geopython" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;urschrei&#x2F;Geopython</a>
paultopiaover 5 years ago
This post is great---even just explaining the difference between figure and axis, and the multiple systems (and the wise recommendation to use the OO system), and all the rest is gold---that stuff took me days of beating my head against the wall and searching through the matplotlib documentation to sort out.<p>Honestly, for 99% of uses Seaborn is great, so long as you remember to use the latest version---for some reason, a lot of people seem to have 0.8.0 installed, and the api changed with 0.9.0.<p>For uses beyond what Seaborn can do, I think that the best strategy is just to figure out a personal plotting language and then wrap that up into a personal library so you never have to think about that again. That&#x27;s kind what I&#x27;ve done: I threw together a library to produce some basic figures that are suitable for printing,[1] and now I never have to think about those figures again.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;paultopia&#x2F;plottyprint" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;paultopia&#x2F;plottyprint</a>
blubover 5 years ago
Matplotlib is one of the most user-unfriendly libraries I&#x27;ve had the displeasure to use. The most effective thing to do is to not use it at all.<p>If you can get away with it use pandas&#x27; plot, seaborn, altair, etc.
评论 #21552454 未加载
评论 #21552009 未加载
评论 #21553066 未加载
评论 #21552968 未加载
jammygitover 5 years ago
I agree with the basic premise: matplotlib is sort of lousy to use, and annoying to learn, but it works and does everything you might need. There’s something to say about software that solves a problem
评论 #21552732 未加载
knolanover 5 years ago
I’m a long term Matlab user and I’ve been using Matplotlib more and more recently. This is partially out of frustration with recent changes to Matlab graphics and also a desire to use more open source tools.<p>Matlab plotting is extremely powerful and versatile. Sometimes the output could be nicer but the interactive figure hierarchy is great. Matplotlib on the other hand is, at least to me, a lot more clunky to work with. But it gets the job done and the output often looks nicer and solves my gripes with Matlab.
评论 #21554503 未加载
jackbrookesover 5 years ago
What is the state of the art in Python data visualisation compared to ggplot2 in R? Over the last few years I have gone exclusively with ggplot2 because it seems so intuitive and customisable.
评论 #21552540 未加载
评论 #21551945 未加载
评论 #21552040 未加载
评论 #21552016 未加载
评论 #21552589 未加载
kzrdudeover 5 years ago
Another crucial tip if you do a lot of custom drawing, is to use collections instead of calling draw functions per object. This radically speeds up drawing. For example using PolyCollection to draw a big bunch of polygons, then LineCollection, EllipseCollection etc.
jbay808over 5 years ago
I&#x27;ve learned to love matplotlib and its OO interface.<p>I just wish that its documentation examples would consistently provide the OO interface version of how to achieve each example, at least alongside the state-machine version.<p>It&#x27;s always frustrating to see an example image that shows exactly what I want to achieve, and then click on the code for it and it&#x27;s using the other interface, and I have to try to guess the equivalent OO commands. Which are always slightly different, like set_ylabel instead of ylabel...
thewhitetulipover 5 years ago
Isn&#x27;t Seaborn famous for this very reason? matplotlib is a bit difficult to write code in but seaborn makes it easy.
评论 #21553479 未加载
throwawayhhakdlover 5 years ago
I don’t mind matplotlib but I highly recommend trying to use seaborn over it for anything.<p>Specifically seaborn’s catplot (for categorical), lmplot, swarmplot, pairgrid, and facetgrid.<p>The seaborne gallery really has an extra level of expressiveness that you might not have considered as an amateur visualizer and you can make some very nice things.<p>Matplot lib runs underneath it so you’ll need to learn all of the adjustment functions: lim, figsize, ticks, etc. but I think it’s fine overall.<p>Charts are hard because there’s more depth than people realize and if the library wasn’t deep you’d be unable to express that depth.