9 ms·
Gnuplotlib: A gnuplot-based plotting backend for NumPy
- techwizrd 3y agoI've found Lets-Plots [0] to my least painful plotting option for Python so far. I'm so used to the grammar of graphics from ggplot, especially compared to plotting in matplotlib or seaborn. 0: https://lets-plot.org/ https://lets-plot.org/
- alexhutcheson 3y agoVega-Altair is pretty great as well. It uses a grammar of graphics that’s slightly different from ggplot, but has most of the same advantages. https://altair-viz.github.io/ https://altair-viz.github.io/
- unnah 3y agoInteresting. It seems the major difference with plotnine is that lets-plot is implemented in Kotlin and the Python package uses a Python-Kotlin bridge. Both lets-plot and plotnine are available under the MIT license. It looks like lets-plot does not implement the ggplot2 theme interface yet, unlike plotnine which is 99.99% compatible with ggplot2. On the other hand lets-plot also includes additional geospatial functionality on top of basic ggplot2 compatibility.
- alshan200 3y agoLets-plot does implement theme and more - flavors (i.e. color profiles) take a look: https://lets-plot.org/pages/charts.html#presentation-options-icon-presentation-options https://lets-plot.org/pages/charts.html#presentation-options...
- unnah 3y agoOk, thanks - not sure how I missed that. I guess the conclusion is that we now have two pretty much complete reimplementations of ggplot2 available in Python.
- no-mana 3y agoWhat's wrong with matplotlib? I might be living under a rock...
- deleted 3y ago[deleted]
- alanbernstein 3y agoI think matplotlib feels natural to people who use(d) Matlab, but not necessarily to others.
- rwxrwxrwx 3y agoI 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/ 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.
- a-nikolaev 3y agoI'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 charts can be augmented. So I personally don't see many advantages from integrating chart generation into computational pipeline itself (except for computation monitoring or maybe when user response is needed to direct computation). Because of that, libraries that encourage charts generation from a computed array instead of dumping that data into persisted files feels like an anti-pattern to me.
- steve_gh 3y agoCompletely aeree. I keen computation steps (which create csv files) separate from charting steps. I use make to orchestrate pipelines. I also keep everything under source control, and insert git commit ids into every chart. This ensures that all the analysis and charts can be linked directly to the code used to produce them.
- ISL 3y agoDoes it implement the greedy matching/parsing of gnuplot? Doesn't look like it? pl 'data.dat' u 1:3 w p pt 7 lc 3 tit 'Interesting measurements' flows from my mind like breathing. I miss that brevity and speed so much when exploring datasets quickly in other languages.... It's not nearly as maintainable as more-verbose and well-specified languages, but it's far more readable than regex :). Edit to add: simply plotting a two-column data file in Gnuplot is as simple as: pl 'data.dat' the above plots the third column against the first column with blue circular dots and applies annotated text to the key/legend, as I prefer to do when exploring data for the first time...
- 7thaccount 3y agoJust 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? :)
- rwxrwxrwx 3y agoThe command is equivalent to the more verbose: plot 'data.dat' using 1:3 with points pointtype 7 linecolor 3 title 'Interesting measurements'
- 7thaccount 3y agoThank you!
- __mharrison__ 3y agoPandas has the best plotting for NumPy... and matplotlib for that matter.
- trws 3y agoIt’s good, but it’s even better with plotnine (formerly ggplot, the python port of ggplot2).
- nmca 3y agoBy 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.
- eyegor 3y agoI 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 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 "aesthetic mapping". My problem with all the popular plotting libraries in python is they seem designed for researchers slapping together a paper and produce code that's awful to maintain.
- blt 3y agodo you feel that about Seaborn even? it can be too "on the rails" for some applications, but if the rails meet your needs, the plotting calls look clean and maintainable to me.
- fn-mote 3y ago> [...] why would they not alias "aes" to something more meaningful? This criticism doesn't do anything for me. Is an alias for a 3 letter function name really going to improve readability / usability? It's the same API. Take it up with Hadley Wickham. I think having one interface that is the same (ok, "mostly the same") for R and Python is a blessing for people who work with both. I don't graph with Python much, but every time I have to plot in Python I sigh and ask myself if it would be easier to just import the data into R.
- coldtea 3y ago>Is an alias for a 3 letter function name really going to improve readability / usability? In this case, absolutely. Plus it shows the attention to detail, or lack thereof, across the whole API.
- uoaei 3y agoJust a comment for the repo owners: insert images for each code example!
- dima55 3y agoThe docs link to the "guide" right at the top. This has basic usage examples and images: https://github.com/dkogan/gnuplotlib/blob/master/guide/guide.org https://github.com/dkogan/gnuplotlib/blob/master/guide/guide...
- uoaei 3y agoThe landing page (readme, in the case of GitHub repos) is way too important. Even a one-click barrier to an examples page obscures the information unacceptably. UX principles also apply to documentation.
- dima55 3y agoYep. There's a reason for the way I did it, but clearly I need to change it. Thanks for looking.
- kelsolaar 3y agoLooks great, minor API usability note: I don't know if there is an official convention but when naming an object that has the potential of overriding a builtin, rather than prepending with an underscore, e.g. `_with`, one does append to it: `with_`. The former is used and recognised for unused variables. > _with is a curve option that indicates how this dataset should be plotted. It’s _with and not with because the latter is a built-in keyword in Python. [1] - [1] https://github.com/dkogan/gnuplotlib/blob/master/guide/guide.org https://github.com/dkogan/gnuplotlib/blob/master/guide/guide...
- blt 3y agoThe HN post title should probably not include "non-painful" given that the README never uses that phrase or compares against other plotting libraries.
- rrr_oh_man 3y agoWhy?
- mat_epice 3y agoHN rules say: “… please use the original title, unless it is misleading or linkbait; don't editorialize.” Therefore, the title should be “gnuplot for numpy.”
- rrr_oh_man 3y agoI understand, thanks for the explanation. It makes a whole lot of sense.
- dredmorbius 3y agoRight. Note that there may be times when titles may be substituted, usually for reasons of length, de-clickbating or de-sensationalising, etc. In which case the preferred option is to omit nonessential words or find an alternative, clearer, phrase within the article text itself. But editorialising, even with relatively innocuous phrases such as "non-painful" is strongly frowned upon.
- dredmorbius 3y agoEmail such suggestions to HN mods at <hn@ycombinator.com>. I've done so in this case.
- radarsat1 3y agoI 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 with it. I would love a version of matplotlib which lives in a separate process and gets updated via nonblocking communication.
- logtempo 3y agoCan't be solved by writting output in a file and reading that file in parrallel? I'm a noob, it's honnest question.
- radarsat1 3y agoAbsolutely 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.
- mangecoeur 3y agoI 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's where a lot of alternatives fall down. That and the multiple very mature backends and library integrations. P.S. I also highly recommend using the object base API. There's a lot of learning material around the web that still uses the old MatLab inspired plotting api which has a plot of gotchas, the object based one is pretty clean.
- toth 3y agoI think matplotlib's main strength is its breadth and power. It really lets you do exactly what you want if you spend enough time fiddling and digging through the documentation. All this versatility comes at the expense of ease of use. It could certainly do a better job of making the simple common use cases more straightforward. gnuplot arguably has similar power and versatility and it does make the simple stuff easier. One thing that matplotlib is IMO bad at is interactive plots. They are very slow, and the controls are not intuitive. 99% of the time you just want to zoom and pan and those should be default actions. gnuplotlib looks interesting and I will have a look, but these days most of the plots I do are in jupyter notebooks and I really want inline interactive plots so I don't think I will use it much. FWIW, what I use currently is plotly - the interactivity is very good (way better than matplotlib's) and plotly.express is very easy to use for the simple use cases.
- mort96 3y agoHave 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".
- SiempreViernes 3y agoYou 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".
- inasio 3y agoI find it weird that the README for a fancy plotting library doesn't have a single plot in it, other than some ASCII art
- medo-bear 3y agoHaving just compared this to a Common Lisp library that does the same thing [0], given Python's prominance in numerical computing, Im actually surprised that the latter is better. [0] http://guicho271828.github.io/eazy-gnuplot/ http://guicho271828.github.io/eazy-gnuplot/
- ayhanfuat 3y agoThis seems way more painful than plotting with matplotlib.
- mjburgess 3y agoI'd imagine an issue with most plotting APIs is that they're declarative, and specified in terms of a semi-mathematical domain -- rather than imperative and specified as graphics operations. Since they're graphics libraries, that would make their operation more obvious. eg., pseudocode, def plotLinear(data, options): drawCanvas(options); drawAxes(options); drawGrid(options); drawPoints(data); drawLine(calcRegressionLine(data)); drawLabel(options);