8 ms·
Lets-Plot: An open-source plotting library for statistical data
- ramraj07 3y agoWhy though? Who was desparately looking for one more plotting library??
- larperdoodle 3y agoI think it's for use in their new Kotlin Notebooks
- data-ottawa 3y agoIt does statistical plots and isn’t matplotlib based which is a great start. I find Plotly finicky, Altair doesn’t have great ergonomics, and bokeh is the same imperative style as matplotlib (plus is kinda heavy weight). Seaborn is good but you’re still playing with a leaky abstraction on matplotlib which can make things hard to compose and you can’t get interactivity. So me, I’m asking for this. I’ve tried building my own because I want good interactive charts with fast native ergonomics. Ggplot just lets you focus on what you want to plot and throw a data frame into it, which is what this appears to do.
- patrick451 3y ago> It does statistical plots and isn’t matplotlib based which is a great start. What? Matplotlib has the best, intuitive interface among the competition. Every other plotting library I have tried either leads to ridiculously verbose code or is too opinionated to be useful.
- Reventlov 3y agoThis comment is surprising. Can you remember how to do 3d scatter plots, for example, without looking at the manual ? IIRC, that's an example of a shitty interface from matplotlib, while plotly is better on this regard.
- heywhatupboys 3y ago> What? Matplotlib has the best, intuitive interface among the competition. Every other plotting library I have tried either leads to ridiculously verbose code or is too opinionated to be useful. What??? Have you ever used ggplot?? I know we all have opinions, but yikes, just look at the tutorials!
- ImaCake 3y agoThe parent comment may find matplotlib approachable because they are a programmer already. A lot of science people are not programmers. So when they have to choose between matplotlib, where you will need to understand OOP, and ggplot, where you can get away with not knowing what a class is, its pretty clear which one is more accessible.
- pama 3y agoIt’s not the programming. Every default in matplotlib is poor. You have to write about ten times more lines of code to get something clean with legible fonts and minimal, understandable aesthetics. Very few people bother and then you get presentations full of ugly, time-wasting plots. Ggplot2 makes it harder to obfuscate your intent and very easy to experiment with different aesthetics and fix up the style of your plot. Yes it is opinionated, because, thankfully, there exist a good set of useful ideas for communicating data analyses.
- ImaCake 3y agoMmmm, ggplot has better defaults but I am still impressed by how bad the plots some people produce are. Absolutely agree on ggplot's ease of use, but that is partly a consequence of not needing to know how to program to use it.
- data-ottawa 3y agoThe matplotlib defaults are poor, but you can import the style class from matplotlib and apply decent defaults > from matplotlib import style > style.use([…]) I’m on vacation away from a computer so hopefully that snippet is close enough that you can Google it.
- unnah 3y agoHave you tried plotnine? It's a faithful port of ggplot to python. It's built on top of matplotlib, so no interactivity, but I have not noticed any problems with leaky abstraction.
- a-dub 3y agomatplotlib supports interactivity if you use the qt backends.
- data-ottawa 3y agoDo those work in a notebook interface? Usually I don’t control the server my code is running on, I’m only exposed to a Google Collab style jupyter notebook.
- a-dub 3y agono, unfortunately not. it's been a while since i've looked but i think mpld3 and plotly were the best bets when i last was trying to make use of notebooks. i've personally never been a big fan of the horizontal breaks in the editor that notebook experiences provide. more recent versions of jupyter have added a side-by-side mode which is kind of an improvement but it still doesn't go where i'd fully want, which would be a full blown editor pane with a full blown document pane that sit side by side and are linked by user placed anchors with plots that can be popped out and floated.
- rolisz 3y agoEveryone. All the alternatives have some big disadvantages, so more competition is good.
- ivansavz 3y agoWow nice, it's based on ggplot2-like grammar-of-graphics language. See examples here: https://lets-plot.org/pages/charts.html https://lets-plot.org/pages/charts.html The data plots look pretty nice: https://lets-plot.org/pages/charts.html#discrete-icon-discrete https://lets-plot.org/pages/charts.html#discrete-icon-discre... And so do the distribution plots: https://lets-plot.org/pages/charts.html#visualization-of-distribution-icon-visualization-of-distribution https://lets-plot.org/pages/charts.html#visualization-of-dis... How does this project compare to `plotnine`, which is the ggplot2-like plotting library in Python?
- billfruit 3y agoIs ggplot2 generic enough that it allows one to create any graph one wants, or is it opinionated in how or what graphs can be made? However the best thing about this library may be that it is available for Kotlin.
- wing-_-nuts 3y ago>However the best thing about this library may be that it is available for Kotlin. What? How's that? It's written in python. Does kotlin have python interop?
- 411111111111111 3y agoIt's linked in the description https://github.com/JetBrains/lets-plot-kotlin https://github.com/JetBrains/lets-plot-kotlin
- wodenokoto 3y agoGgplot is opinionated, but mostly in its api. From memory the only thing you can’t do in base ggplot is have to y-axis, but there are plenty of libraries available that expands the types of plots available (eg gggraph for plotting network graphs)
- smodo 3y ago
- techwizrd 3y agoThis seems quite similar to plotnine [0], which also provides a grammar of graphics interface for Python. That said, I love ggplot and I can't wait to use this in my research! I hope we can port/re-implement ggthemes, scientificplots [1], and other ggplot libraries for lets-plot. 0: https://plotnine.readthedocs.io/en/stable/ https://plotnine.readthedocs.io/en/stable/ 1: https://github.com/garrettj403/SciencePlots https://github.com/garrettj403/SciencePlots
- renewiltord 3y agoOh very cool!
- vsskanth 3y agoWonder how this compares to vega plotting library
- domoritz 3y agoVega like ggplot (which this is very close to) build on the grammar of graphics but differ in the targets they support (Vega is using web technologies), language design details (e.g., Vega and ggplot use different terminology for the graphical elements and the encodings), and supported features (Vega has a reactive dataflow and support for building custom interactions). There is a lot more to be said but that’s a start for how they compare.
- acomjean 3y agoOr even ggplot2 for R. We use vegalite for our web based graphing tools and really like it. https://vega.github.io/vega-lite/ https://vega.github.io/vega-lite/ A lot or are scientists use R and ggplot2. This looks more similar to the thus but with a python twist. https://ggplot2.tidyverse.org/ https://ggplot2.tidyverse.org/
- gfaure 3y agoI hope with every fibre of my being that this eventually replaces matplotlib and pyplot.
- Enginerrrd 3y agoI can clearly see they've tried, and perhaps succeeded, in solving some of the frustrations of those tools. However, what on earth kind of behind the scenes object oriented abstract bastardization have they done wherein you modify the instance of the ggplot class by ADDING stuff to it with a + sign!? Like, when you're trying to toggle one of the flags that would get passed to the class object, why not just do it the way every other class in almost every python library i've ever used does? I find that horrifying. And I think it is just begging to get some bizarre errors, and I think that
- data-ottawa 3y agoIt’s a port of the R ggplot2 api which works the same way. This wouldn’t be a surprise to most R and statistical computing users.
- mathisfun123 3y agodef __add__(self, other): self += other return self Simple
- heywhatupboys 3y agowhat is the alternative? python doesn't have a pipe operator do you want to do plot(density(colorify(labelaxis(logscale .... )))))))
- atombender 3y agoPython doesn't have a built-in pipe operator, but that doesn't mean you can't do it. The pipe [1] library is popular. is_even = where(lambda x: x % 2 == 0) sum(fib() | is_even | take_while(lambda x: x < 4000000) The Apache Beam SDK for Python is another example. It has its own pipe expressions (|, >>, |>, etc.). [1] https://github.com/JulienPalard/Pipe https://github.com/JulienPalard/Pipe
- elisbce 3y agoThe biggest issue I had with plot libraries is that they don't work out of the box for millions of data points. Last time I was doing a data science project, I tried all of the major plotting libraries and none of them works well beyond a few million data points. I want a graph that I can visualize and zoom in/out in real-time and that became the hard part of the project. Only one product claims to be able to handle it using GPUs in the cloud and it needs a paid subscription and uploading your data into the cloud. I don't want yet another library, but some library that works really well and can utilize local GPU for plotting.
- dcre 3y agoThat doesn’t sound like it should be that bad. Are you only looking at Python libraries?
- mrcartmeneses 3y agoI too want the moon on a stick, for free
- quickthrower2 3y agoSo no criticising open source code then?
- montecarl 3y agoThis one does! https://github.com/wwwtyro/candygraph https://github.com/wwwtyro/candygraph Scroll down into the examples for some plots with lots of points: https://wwwtyro.github.io/candygraph/examples/dist/ https://wwwtyro.github.io/candygraph/examples/dist/
- satvikpendem 3y agoPlotly works pretty well (which I suspect you're alluding to) and it works completely offline, no need to upload any data to their cloud.
- patrick451 3y ago
- nothrowaways 3y ago[flagged]
- jdnier 3y agoIs their a Python-centric tutorial or guide on how to construct plots in this grammar of graphics way? Or do you need to read the ggplot2 book and translate R examples to Python?
- jdnier 3y agoVega-Altair seems to have some introductory documentation and a tutorial for their flavor. https://vega.github.io/vega/docs/ https://vega.github.io/vega/docs/
- mushoo 3y agoThats really cool! Does it reimplement ggplot2 in python? pygg is a lightweight library that transpiles ggplot syntax in python into R ggplot2 code. Downside is that it is not interactive and executes in R; upside is it run hadley’s ggplot inplementation in R. https://github.com/sirrice/pygg https://github.com/sirrice/pygg
- ianlevesque 3y agoIt's all Kotlin Multiplatform with a thin Python wrapper. That's pretty amazing.
- esafak 3y agoIt would be amazing if you could use it for all Compose Multiplatform targets. Right now I see it supports Kotlin/JS and JVM: https://github.com/JetBrains/lets-plot-kotlin#in-jvm-js https://github.com/JetBrains/lets-plot-kotlin#in-jvm-js
- gokuldas011011 3y agoIt has a Kotlin API as well, so Yes!
- quasarj 3y agoIs there a way to export them to a raster format? or are they only usable as HTML?
- ImaCake 3y agoI mean if it's vectorised then you can make a raster by screenshotting it? Looks like they support PNG at least: https://lets-plot.org/pages/api/lets_plot.ggsave.html?highlight=raster https://lets-plot.org/pages/api/lets_plot.ggsave.html?highli...
- pkkm 3y agoYes. ggsave(plot, "plot.png")
- jpe90 3y agoSince this is Kotlin there's not really a sane way to call this from Clojure, right?
- kaba0 3y agoMost of Kotlin should map quite well to Java primitives, AFAIK. But I’m sure some bridge/wrapper will soon surface if it is truly great - the Clojure ecosystem is a niche, but surprisingly it always has high quality wrappers for anything I might touch :D
- tasubotadas 3y agoAny good charting libraries for react? I've tried react-chart-js, Rechart and they all just... suck. Non-intuitive use, problems scaling in element containers. Settled on nivo for now but it doesn't support multi-axis plots :/
- hackandthink 3y agoApache ECharts for React https://echarts.apache.org/examples/en/editor.html?c=mix-line-bar https://echarts.apache.org/examples/en/editor.html?c=mix-lin... https://github.com/hustcc/echarts-for-react https://github.com/hustcc/echarts-for-react
- hackandthink 3y agoggplot2 is great for exploring data. Once it was a unique selling point for R. For Dashboards I prefer Apache ECharts: https://github.com/ecomfe/awesome-echarts https://github.com/ecomfe/awesome-echarts
- revskill 3y agopip not found on my windows machine. Then i try python -m pip install Python is not found, too. Then i tried pip3 install. It worked. I should try with python3 -m pip3 or python3 -m pip install ? Confusing.
- bigfudge 3y agoTbh If pip isn’t found nothing much is going to work. I would fix that first, and although it’s an overhead I would learn about virtual environments too because will save pain fairly quickly.
- infinityio 3y agoFor a recent python install, python should be available under `python`, but you should also have the `py` utility installed - this is normally helpful in selecting from a set of versions. If neither of these resolve, the first step is probably to reinstall python With regard to installing packages, I think the general rule is that `python -m pip` is best practice, because it assures that the python you install packages to is the same one you're planning to run them on
- baq 3y agopy -3 -m pip
- scientism 3y agoI see wildcard imports. I'll pass. Also if you want to use R in python why not use the rpy2 library?
- Hasnep 3y agoIt's actually written in Kotlin with a Python wrapper, an alternative is Plotnine, which is a pure python reimplementation of ggplot.
- vegabook 3y agoDownside of all the ggplot-alikes in languages other than R is that they lose the enormous number of amazing add-on libraries[1] available for the original. Personally, where it's better I do a lot of data crunching in Python, then export to R and do all my graphics there. I feel like the statistics crowd just appreciates graphics more and has spent more time getting it perfect. Another plus is that Copilot really helps with R-based ggplot semantics and options because it's got so much to learn from. Not sure that would be true for the subtle differences in the ggplot clones. [1] https://youtu.be/7UjA_5gNvdw https://youtu.be/7UjA_5gNvdw
- choppaface 3y agoNice video. It definitely tells the story that R provides extra leverage in exposition. Might as well learn some R rather than yet another python plotting wrapper.
- sigg3 3y agoAs a novice, R is really fun too because it operates differently than general purpose languages (it's all about matrices).
- ImaCake 3y ago>Copilot really helps with R-based ggplot semantics and options because it's got so much to learn from. Not sure that would be true for the subtle differences in the ggplot clones I would suspect this wouldn't be much of a hurdle for an LLM. If you've ever tried converting scripts from one language to another you can see how well LLMs generalise (not perfect ofc). So, as long as you give it enough context it will probably provide viable results.
- deleted 3y ago[deleted]
- vegabook 3y agoExcept if the range of the function given the same domain is much, much bigger. Extrapolation of a [massively multidimensional, non-linear] function is a lot harder than interpolation.
- noelwelsh 3y agoKinda disappointing to me that, as far as I can tell, they directly copied ggplot. ggplot is not the last word in designing visualization libraries. For example, it has the concept of a scale which is exactly a function. This just adds useless conceptual cruft in the library. Getting rid of that is an easy improvement.
- ImaCake 3y agoWhatever ggplots flaws are, I haven't found matplotlib, base R, or any other plotting library to allow me to generate plots at essentially the speed I can type at. I can do that in ggplot without any help. I can only get close to that in matplotlib with recent exposure to it and github copilot.
- noelwelsh 3y agoI'm a big fan of the compositional style of ggplot vs the imperative style of Matplotlib. I just don't think ggplot is the last word in this style of library.
- hadley 3y agoA scale isn’t exactly a function because it also needs the inverse in order to draw axes and legends. And it turns out axes and legends are where most of the complexity of scales lie.
- amelius 3y agoDoes this provide interaction? I.e. getting values at a user-picked point, moving labels around, or viewing a 3d plot from a different angle?
- sobriquet9 3y agoNo empirical CDF plots? This is the first thing I do when looking at the new data.
- horis-asmirnov 3y agoThere is no such thing in Lets-Plot yet, but there is a Q-Q plot: https://lets-plot.org/pages/api/lets_plot.geom_qq.html https://lets-plot.org/pages/api/lets_plot.geom_qq.html For a uniform distribution, a Q-Q plot would look almost the same as eCDF, only with switched axes, and with points instead of lines.
- nerdponx 3y agoPlotnine is a well-established implementation of the Grammar of Graphics in Python, and to a lesser extent Seaborn. Why should I use this instead?
- Alifatisk 3y agoOn a similar vein, there is a cli tool that can draw plots on the terminal. https://github.com/red-data-tools/YouPlot https://github.com/red-data-tools/YouPlot