5 ms·
matplotlib is an example of unnecessarily complex and confusing "organic" API. That's why there is so much resentment to use it; trivial things need non-trivial
by bitL 9y ago
matplotlib is an example of unnecessarily complex and confusing "organic" API. That's why there is so much resentment to use it; trivial things need non-trivial internal understanding and confusing boilerplates.
- gaius 9y agomatplotlib is an example of unnecessarily complex and confusing "organic" API It is designed to be familiar to people who already know MATLAB, and it does that quite well. So it is not "unnecessary", it's like that for a reason. I agree tho' that someone who has never touched MATLAB might want to plot directly from Pandas, or maybe use Seaborn.
- rspeer 9y agoThe problem is that both Pandas and Seaborn are customized by passing their kwargs onto matplotlib, or by giving you back matplotlib axes objects. You have to break through the abstraction pretty much immediately. You can't really put the finishing touches on your graphs without also knowing matplotlib.
- avian 9y agoI didn't have any significant MATLAB background when I started using matplotlib and I found it a joy to use. I think "organic" part of the API is very well integrated and completely optional in most places. For instance, you can use the matlabish shortcut "subplot(111)" or you can spell out the parameters in a pythonic way as "subplot(nrows=1, ncols=1, plot_number=1)".
- omginternets 9y ago>It is designed to be familiar to people who already know MATLAB Yes, and this was a mistake. Other than logical-indexing, there's one is better off forgetting _everything_ about MATLAB.
- kinkrtyavimoodh 9y agoI am fairly comfortable with doing basic matrix work in MATLAB and I am fairly comfortable using Python, but I have found matplotlib to be quite hard to get the hang of. Esp when you add it to pandas which is also slightly idiosyncratic in its own way, and then all of these are different from numpy, which is a mess of its own.
- bicubic 9y agoI agree with your sentiment, but at the same time I've yet to see anyone do it better. The other popular tools like d3 have the same problems, I think some of it may just be an intrinsic cost with expressive visualization frameworks.
- _delirium 9y agoI personally like the design of ggplot2. Not necessarily a design everyone will love, but it's pretty consistent and systematic in its design around the "grammar of graphics". Works especially well if you buy into the entire Hadley Wickham ecosystem of R packages: ggplot2, dplyr, reshape2.
- philh 9y agoI really like ggplot2, but I'm not sure it really competes with matplotlib or d3. It feels like, if it doesn't already support the thing you want, implementing it in ggplot is a lot harder than in mpl or d3. For specific examples, I've looked idly at doing chord diagrams and trees in ggplot. Chord diagrams don't seem to exist, you can do them with another R package but I don't think it interacts with ggplot. There's a ggtree library that does interact with ggplot, but in kind of a weird way that I wouldn't describe as "you can now draw trees with ggplot". (I haven't explored too closely. This was in the context of "I want to write a ggplot for python, and I'm curious whether supporting chord diagrams and trees at some point in the future is plausible".)
- bicubic 9y agoSpot on. ggplot2 is much nicer than matplotlib and d3 as long as you stay on the beaten path; which is wide enough to accommodate the majority of use cases. But the second you step off that beaten path, it's hell. It just looks like there's a fundamental tradeoff between visualization expressiveness and API complexity. Btw, Seaborn is a framework on top of matplotlib that replicates the semantics of ggplot2 if that's what you're after.
- 9y ago
- dom0 9y agoOn the one hand, yes, if you're looking at the API design and the docs from a "clean slate" perspective, then they are clearly not very good. [1] On the other hand, matplotlib is ridiculously powerful as an embedded plotting library; the limiting factor there is definitely not flexibility, but rather performance, which limits applicability to larger data sets -- you can work around that in many ways, or use something different. (I wrote more than one application-specific OpenGL plot renderer). Performance also limits interactive use, especially on non-desktop devices. [1] Disclaimer: Very few technical docs I've seen for "modern" software are of convincing quality. Most are poor or don't exist in the first place. Further Disclaimer: I don't know how to do better and write docs I'd consider at best "meh-ok". People able to write technical texts well seem to be incredibly rare (likely an educational gap; besides 08/15 standard English courses I've never seen lectures or courses on technical writing at an university).
- Sean1708 9y ago> Very few technical docs I've seen for "modern" software are of convincing quality. There's a reason Technical Writer[0] is a profession in of itself, this stuff is much harder than people give it credit for. [0]: https://en.wikipedia.org/wiki/Technical_writer https://en.wikipedia.org/wiki/Technical_writer