5 ms·
Python Chart Examples
- holtzy 2y agoThere are countless stunning charts available on the web, many of which are crafted using programming languages like R. Tired of hearing doubts about matplotlib's capabilities, I've curated and translated a collection of impressive charts using Python and matplotlib. Explore them all with detailed tutorials and reproducible code at: https://python-graph-gallery.com/best-python-chart-examples/ https://python-graph-gallery.com/best-python-chart-examples/
- nerdponx 2y agoWhat's weird is that I don't think I've ever heard any serious practitioner doubt its capabilities. The main complaints I hear are just annoyance with pyplot.
- RugnirViking 2y agoCan I suggest changing the title here to the article title? "Best Python Chart Examples" It's a little less accusatory and I think a nicer representation of what it is
- dang 2y agoI've changed it now. (Submitted title was "Yes, Python and Matplotlib can make pretty charts"). (I took out "Best" though because that word doesn't matter and will provoke tedious objections about how no, these are not the best examples.)
- Kalanos 2y agoFor interactive charts, simple APIs, multi-language compatibility, and interactive apps (Dash) https://plotly.com/python/ https://plotly.com/python/
- uniqueuid 2y agoWow, these actually impressed me. I've made a few matplotlib charts myself, but typically R/ggplot is significantly nicer and easier. My takeaway is that matplotlib may be a good alternative for specific cases where you need much more control.
- gms7777 2y agoI agree that R/ggplot is often more straightforward, but the main reason I (and most colleagues I've worked with) tend to use matplotlib is just a preference for python over R in general (to each their own though, that's not a debate I'm looking to start). If I'm doing data analysis in python already, it's a pain to export out just to plot in R. That said, it's definitely a steep learning curve, especially because it's something people usually learn on the fly instead of having any kind of formal instruction. I do think seaborn has really helped boost ease of entry wrt plotting in python at least.
- pithon 2y agoThese look fantastic. If there's one thing I'd really like to automate with AI instead of hand coding, though, it would be making charts!
- anshumankmr 2y agoSee this: https://github.com/microsoft/lida https://github.com/microsoft/lida It isn't great but it works for simple stuff well enough.
- holtzy 2y agoThere aren't so many polished matplotlib charts out there. So I'm not even sure if chatGPT would be good at it.
- emblaegh 2y agoI’m particularly proud of this[1] figure I made using matplotlib for my PhD thesis. And yes, this is a single mpl figure and those are all individual axes. You do not want to see the source code. [1] https://ibb.co/TLLBg37 https://ibb.co/TLLBg37
- currycurry16 2y agoActually I am interested in the code. Did you use TikZ?
- emblaegh 2y agoNope, just plain matplotlib. The code was huge mess written under insane pressure, but I’m sure I kept it somewhere in my backups.
- jeroenjanssens 2y agoI also thought it was made with TikZ (which is a compliment). I used TikZ for my thesis: https://jeroenjanssens.com/phd/ https://jeroenjanssens.com/phd/ and same thing here, the code is a mess.
- LettuceSand12 2y agoWent down this road recently and I ended up deciding to work with holoviz instead: https://holoviz.org/ https://holoviz.org/ Having some level of abstraction on top of matplotlib is necessary if you don’t want to spend time tweaking every little thing.
- nerdponx 2y agoI recently started using Holoviews/Hvplot/Geoviews/Datashader for some big-ish data viz, and it's been mostly positive, but with some notable annoyances. The performance on big data is excellent. But I spent maybe two hours trying to figure out how to draw a damn regression line over my plot and I couldn't. Also hv.extension() seemed to break plain Matplotlib, whenever I tried to generate a plot after calling that function, I got an error about a non-interactive backend when trying to view a plot interactively, even when I selected an interactive backend explicitly.
- holtzy 2y agoThat's the thing with wrapper libraries: amazing at the beginning, but quickly becoming frustrating.
- kookamamie 2y agoThe article is so full of ads that it's hard to see what's what.
- magnio 2y agoThe problem with matplotlib has never been its capability. I consider its rendering backend and resulting image quality to be top-notch, and there are a billion options for you to customize. That second part is the biggest problem with matplotlib: the imperative API cloned from Matlab is just terrible. The vast majority of matplotlib examples are rife with global states and overriding behavior (ever have to set font size twice to force it?) At first I thought that it's a bit clunky due to my inexperience, but no, the API is just that bad. See https://ryxcommar.com/2020/04/11/why-you-hate-matplotlib/ https://ryxcommar.com/2020/04/11/why-you-hate-matplotlib/ Now, I mean no hate to matplotlib, which is still a solid library. I appreciate their commitment to backward compatibility by keeping all those baggage, and I don't want them to yank them out, given that seaborn already mitigates most of the API problems, and Altair already brings enlightenment to Python plotting. Now if only seaborn works with polars natively ...
- nerdponx 2y agoThe object-oriented API and its documentation have improved markedly over the years, I encourage you to give it a try. Most of the official documentation examples use it now. Yes, there are lots of examples out there using the pyplot interface still, but there is enough information on the OO API now that you can get by. Personally I think pyplot is still a perfectly fine interface for just banging out quick data visualization without too much effort, but I find myself very quickly switching to the OO interface as soon as I want a little bit of control over what's going on. There are still some lingering issues, like the interface discrepancy between scatter and other plotting methods, and the difficulty of making a nicely-formatted color bar. But it's really coming a long way since I started using it in ~2015, And in that time I've actually come to prefer it over both base R and ggplot2, which is what I started with originally. I have much stronger complaints about Seaborn and he will never find me recommending it to anyone.
- magnio 2y ago> The object-oriented API and its documentation have improved markedly over the years, I encourage you to give it a try. Most of the official documentation examples use it now. Yes, there are lots of examples out there using the pyplot interface still, but there is enough information on the OO API now that you can get by. I agree. I used seaborn and matplotlib recently, and I was pleasantly surprised at both how much more consistent the API is and how much more comprehensive the documentation is. I dreaded using it at first but quickly became more accustomed. > I have much stronger complaints about Seaborn and he will never find me recommending it to anyone. Interesting, what are your pain points? For me, most of the time I start with seaborn, then modify the underlying matplotlib figure and axes for more customization; only rarely do I start with plt.subplots(). This gives me nice default styles while still allowing me to bend it to my will.
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- deleted 2y ago[deleted]
- aweb 2y agoWow, these examples are amazing! I've used matplotlib in the past and was disappointed by the final look of the generated charts, nice to know there's hope and I can make them look good the next time I need it :D
- dylanzhangdev 2y agothis site has so to much ads.