Live data from Hacker News

Gnuplotlib: A gnuplot-based plotting backend for NumPy

github.com

51–60 of 69 posts

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#51

Earlier quoted context omitted.

Matplotlib is what is wrong with matplotlib.. Broadly, the problem is that its syntax was meant to reflect that of Matlab, which, I guess, makes it intuitive for Matlab users. For the rest of us, it's mostly unintuitive and inconsistent.

Can you give an example of its inconsistency? I would be genuinely interested what are the inconsistency from a Python-perspective. I am former Matlab/Octave user. To me the julia interface of matplotlib is actually quite nice to use, but unfortunately the installation is a bit brittle.

Somewhere you can use c="k" for colour but sometimes you cannot, you must use color="k".

Some settings only exposed to figure class but not the ax class. And when you are doing stuff towards ax class, you must write

ax.set_ylim(0,3)

instead of

ax.ylim(0,3)

Matplotlib.pyplot is known for its nonsensical api.

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#52
post #24
post #3

What's wrong with matplotlib? I might be living under a rock...

from matplotlib import pyplot as plt WTF? Broken from right there. What's a plt? "o" key broken? Why didn't they just call it pyplot? Why not just import pyplot pyplot.plot(lambda x: math.sin(x)) pyplot.plot(x=[0,1,2],y=[0,2,4])

It's a convention of the math-heavy python libraries, numpy and pandas also often get imported as np and pd.

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#53
post #40

Earlier quoted context omitted.

Matplotlib isn't very friendly to casual users. For even the simplest possible plot, I have to create a subplot and axis. Sometimes I'd like to just plot a function. I don't want to initialize arrays for that. It's easy to forget that I have to `import matplotlib.pyplot` I don't need to plot things often, but whenever I use matplotlib, I always have to spend a few minutes to look up how to use it.

> For even the simplest possible plot, I have to create a subplot and axis. So? Can't that be abstracted away once in a custom lib, of the 3-4 plots you use 99% of the time, and be done with it? In which case, you just need to pass in your data and labels, in a specific format, and that's it.

"that can be abstracted away in a custom lib"

Yeah, and that's really not helpful for sharing code or doing exploratory charting. It's never, ever as simple as just "being done with it".

vega-lite-api is my charting library of choice these days. Much simpler than gnuplot, d3, matplotlib, etc.

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#54

I might have missed the memo where Gnuplot has a better api than matplot ;) Seriously though, there have been many attempts to make a "better matplotlib" and yet it's still going strong - mostly because when you really get into scientific plotting and need print quality plots or embed plots in an GUI with very specific parameters it's hard to beat. Sometimes you just need to place a label in a specific spot and that'…

Have there been many attempts to make a "better matplotlib"? Enlighten me, I have searched for them but never found something which seems to actually try to be "matplotlib but better".

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#55
post #54

I might have missed the memo where Gnuplot has a better api than matplot ;) Seriously though, there have been many attempts to make a "better matplotlib" and yet it's still going strong - mostly because when you really get into scientific plotting and need print quality plots or embed plots in an GUI with very specific parameters it's hard to beat. Sometimes you just need to place a label in a specific spot and that'…

Have there been many attempts to make a "better matplotlib"? Enlighten me, I have searched for them but never found something which seems to actually try to be "matplotlib but better".

You might be right that there aren't many examples of projects saying "matplotlib but better", but many python plotting libraries are sold with something like "you won't need matplotlib anymore".

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#56

Earlier quoted context omitted.

I always find it easier to produce publication-quality figures using gnuplot (but not with its defaults settings, mind you) than with Matplotlib. Check out http://gnuplotting.org/ Also, it's hard to beat gnuplot's speed refreshing a live scatter plot with many thousands of points using the x11 terminal.

I'm using gnuplot for plotting too (the actual gnuplot application not a library that uses gnuplot as its backend). And I usually keep computation and plotting separate. Computation produces data files, and a gnuplot script generates plots. This separation of computation and plotting allows updating charts later if needed, collected data can be reused in other plots, and additional data analysis can be performed and…

Somewhat agree but sometimes there is need to change/filter the data that goes into making the chart which is only realized after plotting it. Combining data and the figures into one "pipeline" makes it easy to iterate especially with exploratory data analysis. Regardless, this comment made me think about my general workflow which is usually combined. Appreciate this comment.

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#57
post #16
post #13

By far and away the best python plotting library is plotnine, a python clone of ggplot maintained by Hassan Kibirige from Uganda. By the estimation of one esteemed colleague "it obviously pays back the time investment in less than a couple of days". I agree.

I see the potential long term but that api is unintuitive at best. It almost seems obstructively terse. (ggplot(mtcars, aes("wt", "mpg", color="factor(gear)")) + geom_point() + stat_smooth(method="lm") + facet_wrap("~gear")) From https://github.com/has2k1/plotnine , their front page examples. I get that it's ripping off the ggplot api, but why would they not alias "aes" to something more meaningful? It stands for "ae…

As someone who makes plots every now and then with breaks of several months in between, I have found the ggplot syntax surprisingly intuitive and easy to remember even after a long break. Importantly, the basic syntax can be used to compose quite complicated graphs, although it does have its limits.

It's also quite nice to be able to use the same interface in both R and Python, although it is obvious that it was originally developed for R.

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#58

I might have missed the memo where Gnuplot has a better api than matplot ;) Seriously though, there have been many attempts to make a "better matplotlib" and yet it's still going strong - mostly because when you really get into scientific plotting and need print quality plots or embed plots in an GUI with very specific parameters it's hard to beat. Sometimes you just need to place a label in a specific spot and that'…

And LLMs have made it even better.

There is so much matplotlib and plotly code on the web, that nothing else comes close to the effortless plotting of matplotlib/plotly.

I almost never have to write the styling myself. LLMs understand matplotlibs complex, but well specified docs really really well.

This points to a larger trend. If you want your language or hard-to-learn tool to get adoption. Then you better have an LLM that does 90% of the work for newcomers.

It's the '*a language is only as good as its idee*' phenomenon that every Java user is surely aware of; but 2024 version.

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#59

Earlier quoted context omitted.

Just curious....can you tell me what that means? I was actually looking at gnuplot earlier, but it always intimidates me. Edit: you responded fast with your edit, but can you explain the full command -verbose? :)

The command is equivalent to the more verbose: plot 'data.dat' using 1:3 with points pointtype 7 linecolor 3 title 'Interesting measurements'

Thank you!

Re: Gnuplotlib: A gnuplot-based plotting backend for NumPy

#60

I don't mind matplotlib at all but I just find it annoying in one of my most important use cases which is to update the plot during a long calculation. You gave to call fig.canvas.draw but it doesn't always work and sometimes plt.pause works but sometimes it only partially updates the display and you have to call it multiple times. (At least this in is my experience with TkAgg backend.) Meanwhile you can't interact w…

Can't be solved by writting output in a file and reading that file in parrallel? I'm a noob, it's honnest question.

Absolutely yes, but you'd have to design that for each application you develop. I'd love an out of the box solution. Then maybe skip the file and use pipes or sockets.
Post reply on HN