Live data from Hacker News

Matplotlib

matplotlib.org

21–30 of 44 posts

Re: Matplotlib

#21
post #19
post #17

Earlier quoted context omitted.

By which you mean these I think? 1. the pyplot API (the old one, that is designed to mimic MATLAB - it has functions like plot() and xlabel()). 2. The Axes API - fig, ax = plt.subplots(); then call ax.plot(), ax.set_xlabel() and so on One should always prefer the Axes way of doing it, it's refactorable and uses less hidden global state.

generally when i'm using matplotlib instead of d3 it's because i'm less concerned about things like refactorability and hidden global state than about getting some data points on the screen in as few keystrokes as possible; %pylab inline and the pyplot api are far superior for that i wish the axes api didn't exist

And when I use matplotlib it's to clean up some non-default tweaks to seaborn plots. Refactorability here means that it's easy to go from one plot into one that's split into facets (multiple subplots etc.)

Re: Matplotlib

#22
post #18

Pgfplots produces highest quality plots that I have seen.

How is this relevant? Pgfplots isn't even a matplotlib competitor really, they're completely different in terms of use cases and ecosystems.

Re: Matplotlib

#23
post #21
post #19

Earlier quoted context omitted.

generally when i'm using matplotlib instead of d3 it's because i'm less concerned about things like refactorability and hidden global state than about getting some data points on the screen in as few keystrokes as possible; %pylab inline and the pyplot api are far superior for that i wish the axes api didn't exist

And when I use matplotlib it's to clean up some non-default tweaks to seaborn plots. Refactorability here means that it's easy to go from one plot into one that's split into facets (multiple subplots etc.)

true, the subplot api is especially painful because i have to edit each line of code i copy-paste to give it a different subplot number

Re: Matplotlib

#24
Bokeh has a much more sensible API, and it generates an interactive HTML plot by default.

Unfortunately it's missing quite a few specialized plots from matplotlib, in particular the popular histogram plot is strangely difficult to draw.

Re: Matplotlib

#25
post #8

Matplotlib is amazing and nice to have when you need it but can be way too complicated for the average user and visualization. Most users' needs, I think, would be better served by something like Plotly Express or other higher-level dataviz packages (for visualizations-thru-code) and Tableau, PowerBI, and Excel (for interactive WYSIWYG dataviz).

People don't seem to understand that matplotlib is the lower-level backend/API and not really intended to be a visualization interface for the average user. It's a power tool. Matplotlib's users are other python developers making more high-level visualization libraries, like seaborn, pandas (df.plot()), plotly, ggplot (the python port/version). If you know the matplotlib API, then you can directly modify figures from seaborn, etc.

Re: Matplotlib

#26
I always wondered how different Matplotlib would have been if John Hunter didn’t die so young. His passing was right near the boom of Python too.

Re: Matplotlib

#27
post #17

It's a great library. I only wish that it didn't have two completely different, incompatible interfaces to muddy the documentation, examples, and SO answer threads.

By which you mean these I think? 1. the pyplot API (the old one, that is designed to mimic MATLAB - it has functions like plot() and xlabel()). 2. The Axes API - fig, ax = plt.subplots(); then call ax.plot(), ax.set_xlabel() and so on One should always prefer the Axes way of doing it, it's refactorable and uses less hidden global state.

> One should always prefer the Axes way of doing it, it's refactorable and uses less hidden global state.

I fully agree, but half the time you're looking up how to do something, you find methods documented using the other approach, with slightly different method names that don't even have an alias in the axes API. In fact those are usually the ones you find, because people answering SO questions seem to prefer the brevity.

Re: Matplotlib

#28
post #4

By far my favorite feature of matplotlib is that it produces readable and accessible plots by default. Font sizes and linewidths are not too small, the default color palette is colorblind-friendly, and the default colormaps are perceptually uniform. Other software (for example Matlab and Mathematica) have absolutely terrible defaults and require a lot of fiddling to get the plots right.

> the default color palette is colorblind-friendly

No, it very much isn't. The second and third colors, the orange and the green, look extremely similar to protanopes (red deficiency). Fortunately, there's a plan to fix this for Matplotlib 4.0.

Re: Matplotlib

#30
post #24

Bokeh has a much more sensible API, and it generates an interactive HTML plot by default. Unfortunately it's missing quite a few specialized plots from matplotlib, in particular the popular histogram plot is strangely difficult to draw.

Bokeh requires a lot more typing to do the same thing. Also, for interactive work, I often want the GUI, not a webpage with the plot on it.
Post reply on HN