Live data from Hacker News

Matplotlib

matplotlib.org

31–40 of 44 posts

Re: Matplotlib

#31
post #16

Earlier quoted context omitted.

Ditto. Awfully convoluted compared to, say, R.

odd how it's still the de facto standard python library for plots despite much better libraries like ggplot or plotly

Plotly might just be one of the libraries that manages to make documentation less readable than matplotlib. API reference consists of 90% autogenerated doc trash 90 pages long.

Re: Matplotlib

#32
post #18

Pgfplots produces highest quality plots that I have seen.

I find Pgfplots quite hacky since TeX is really not made for handling data (it doesn't even support floating-point arithmetic). A much cleaner solution is to enable LaTeX text rendering in Matplotlib (https://matplotlib.org/stable/users/explain/text/usetex.html). In this way, TeX is used for what it is good at (text rendering), and everything else is handled by Matplotlib.

Re: Matplotlib

#33

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.

The old API was meant to mimic MATLAB. It's in the name -- the "mat" in "matplotlib" refers to MATLAB. And yes, those of us who were brought up on MATLAB gravitated toward it in the early days because it was so familiar. For better or worse, MATLAB was and still a popular in academia (less so these days, but still being used especially in control engineering).

MATLAB's plotting is not the best, but it's familiar to MATLAB legacy folks, who made up many of the early folks who moved over to Numpy, Matplotlib, SciPy. It was a bridge.

Re: Matplotlib

#34
post #32
post #18

Pgfplots produces highest quality plots that I have seen.

I find Pgfplots quite hacky since TeX is really not made for handling data (it doesn't even support floating-point arithmetic). A much cleaner solution is to enable LaTeX text rendering in Matplotlib ( https://matplotlib.org/stable/users/explain/text/usetex.html ). In this way, TeX is used for what it is good at (text rendering), and everything else is handled by Matplotlib.

Or use Matplotlib's PGF backend. You can even import a preamble so the notation macros from your paper are usable in the legend, axes labels, etc.

Re: Matplotlib

#35
post #32
post #18

Pgfplots produces highest quality plots that I have seen.

I find Pgfplots quite hacky since TeX is really not made for handling data (it doesn't even support floating-point arithmetic). A much cleaner solution is to enable LaTeX text rendering in Matplotlib ( https://matplotlib.org/stable/users/explain/text/usetex.html ). In this way, TeX is used for what it is good at (text rendering), and everything else is handled by Matplotlib.

The idea is to process it all in Python and export the final data points to text files to be plotted by pgfplots. Then you can import the pgfplots code directly in the latex document or slide, and adjust it there. It will all be latex in one document, and you will have full control over the plot and its annotation. With Tikz, you can superimpose diagrams.

Re: Matplotlib

#36
post #20
post #18

Pgfplots produces highest quality plots that I have seen.

can you provide some links to examples so we can see what you mean

See examples in the PGFPlots manual:

https://ctan.org/pkg/pgfplots

However, examples from pgfplots and matplotlib should be considered in a paper, together with the effort in preparing and revising the figures.

Re: Matplotlib

#37
post #23
post #21

Earlier quoted context omitted.

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

[deleted]

Re: Matplotlib

#38
Matplotlib is a fantastic library even if I don’t love the API.

The name and API come from MATLAB, and once you realize that it makes more sense. It was originally meant to replicate the plotting functionality in python to be familiar to MATLAB users. IMO this is what makes it feel non-pythonic, but it was never really a python API in the first place.

Re: Matplotlib

#39
post #7

What about it? Are you trying to point to something specific?

I haven’t used matplotlib in a while (also because I wasn’t fluid with it) and now am using it regularly in Code Interpreter w/ GPT-4. Now I’m thinking there must be many more libraries that are now “in reach” for me for casual use which weren’t just a few weeks ago.

Same, I just had the problem of wanting to display crosstabs between n raters which calls for a gridview of heatmaps. It was a 15min GPT job rather than struggling for 2 hours on my own. I got to worry about the salient parts of the problem than the minutia of matplotlib.

Re: Matplotlib

#40

Matplotlib is a fantastic library even if I don’t love the API. The name and API come from MATLAB, and once you realize that it makes more sense. It was originally meant to replicate the plotting functionality in python to be familiar to MATLAB users. IMO this is what makes it feel non-pythonic, but it was never really a python API in the first place.

Exactly! Typing "import matplotlib" at the python REPL instantly gave you the capability of Matlab without the requirement of a commercial license. If I recall correctly, matplotlib was built after Matlab increased the prices for its commercial license for academics.

Between matplotlib and pandas I believe we have a sufficient explanation as to how python became the language of choice for data analysis.

Post reply on HN