Live data from Hacker News

Vega-Altair: Declarative Visualization in Python

altair-viz.github.io

31–40 of 44 posts

Re: Vega-Altair: Declarative Visualization in Python

#31
post #30
post #9

Earlier quoted context omitted.

I don’t know what you think declarative means, but the example you’re showing is as non-declarative as it could be for such a simple thing.

> I don’t know what you think declarative means, but the example you’re showing is as non-declarative as it could be for such a simple thing. According to Wikipedia this is a style of programming where you describe _what_ you want rather than _how_ it should be done. What I see in my example is declarative per this definition: "I want a chart with , with this X label and that Y label".

Yes but this is a contrived example so it’s not going to be the best illustration of the difference. You’re literally executing methods on an object as a way to instruct the computer to perform specific steps.

The fact that you can read it as if it were a description of the outcome is a happy accident (a purely aesthetic one at that) that would not necessarily happen with another example.

Re: Vega-Altair: Declarative Visualization in Python

#32
post #6

Earlier quoted context omitted.

If we only look at the simplest example then I would agree that there is not much difference. But more complicated plots will require you to write code in a more verbose and imperative fashion when using matplotlib. Take a faceted plot like this scatter matrix [1] and try to plot it in matplotlib. You would need to set up the grid using subplots, then define the combinations you want and finally write logic to fill e…

Mirror, mirror on the wall, what’s the most declarative dataviz programming language of all? :-) *** SAS SCATTER MATRIX EXAMPLE *** proc sgscatter data=sashelp.cars; matrix Horsepower Acceleration Miles_per_Gallon / group=Origin; *** ALTAIR SCATTER MARIX EXAMPLE *** import altair as alt from vega_datasets import data source = data.cars() alt.Chart(source).mark_circle().encode( alt.X(alt.repeat("column"), type='quanti…

Well, there also is for example `pandas.plotting.scatter_matrix()` [1] which is built on top of matplotlib. I suppose the question is how does SAS or any other alternative compare to vega/altair when the desired output is less standard.

[1]: http://pandas.pydata.org/pandas-docs/stable/reference/api/pa...

Re: Vega-Altair: Declarative Visualization in Python

#33

Working as a data scientist, I have exclusively used Altair since I joined my company in 2021. Every one of my coworkers uses Matplotlib. Two people said something like "Oh, you're using that library that's supposed to be better and probably is, but I just don't want to relearn everything for plotting" but nobody else has even shown interest, let alone taken the plunge. If you need to learn a plotting library and you…

Image export before Altair 5 was a bit complicated because it required either selenium plus a system web browser, or a node.js installation. In Altair 5, we switched to using vl-convert for image export, which is just a regular Python wheel with no external dependencies. So now, `chart.save("file.png")` should be just as easy to use as matplotlib's savefig!

(Disclaimer: I'm a Vega-Altair maintainer and the author of vl-convert)

Re: Vega-Altair: Declarative Visualization in Python

#34
post #24

I work as a data scientist (like many others in this thread) and Altair is a great tool for exploring the data. I really like the grammar of graphics approach and the ability to do things like cross-filter and the general ease of enabling interactivity are great! Amazing work by everyone on the Altair/Vega team. There are some drawbacks though that have been holding some of my colleagues back from switching from e.g.…

(Disclaimer: I'm a Vega-Altair maintainer)

Thanks for the feedback and for the kind words! All of these drawbacks are fair, just a couple of comments.

There is an experimental package called altair_tiles that makes is possible to add OSM-style maptile backgrounds to Altair charts. See https://github.com/altair-viz/altair_tiles. This is mostly for static charts at the moment, as it doesn't integrate well with pan/zoom yet.

As you mentioned, VegaFusion is able to remove unused columns in most cases. (And if it doesn't for a particular case, please open an issue!).

Re: Vega-Altair: Declarative Visualization in Python

#35

Altair is great. I'm using Plotly more lately, for 2 reasons - chart have very good interactivity by default and I'm also a Dash user - so it comes in naturally. But I believe Altair is excellent for exploration - simple charts are very simple to create, and it's not complicated to create a complex exploration dashboard - with all charts linked between them - so you can select a subset of data on one chart, and it au…

(a current Altair maintainer and a former plotly.py maintainer here)

Plotly is definitely a great option as well, and it can do a bunch of things Vega-Altair is not designed for. One comment, just in case you weren't aware, is that there is a relatively new library that provides good integration between Altair and Dash: https://github.com/altair-viz/dash-vega-components. It even makes it possible to access Altair selection states in Dash callbacks so that you can have other dashboard components respond to selections.

Re: Vega-Altair: Declarative Visualization in Python

#36
post #29

Working as a data scientist, I have exclusively used Altair since I joined my company in 2021. Every one of my coworkers uses Matplotlib. Two people said something like "Oh, you're using that library that's supposed to be better and probably is, but I just don't want to relearn everything for plotting" but nobody else has even shown interest, let alone taken the plunge. If you need to learn a plotting library and you…

I use seaborn to plot directly with pandas, does Altair have any extra advantages? Or is it a similar style?

I wrote an article a while back about why I think it's the best default choice for vis in Python: https://www.robinlinacre.com/backing_vega_lite/

Re: Vega-Altair: Declarative Visualization in Python

#37
post #34
post #24

I work as a data scientist (like many others in this thread) and Altair is a great tool for exploring the data. I really like the grammar of graphics approach and the ability to do things like cross-filter and the general ease of enabling interactivity are great! Amazing work by everyone on the Altair/Vega team. There are some drawbacks though that have been holding some of my colleagues back from switching from e.g.…

(Disclaimer: I'm a Vega-Altair maintainer) Thanks for the feedback and for the kind words! All of these drawbacks are fair, just a couple of comments. There is an experimental package called altair_tiles that makes is possible to add OSM-style maptile backgrounds to Altair charts. See https://github.com/altair-viz/altair_tiles . This is mostly for static charts at the moment, as it doesn't integrate well with pan/zoo…

Thanks for the feedback! Looking forward to `altair_tiles`. And again, great work, very much appreciate it!

Maybe while you're here: Is there any desire to implement box-zoom (or x-range zoom) at any point in the future?

Re: Vega-Altair: Declarative Visualization in Python

#38
post #37
post #34

Earlier quoted context omitted.

(Disclaimer: I'm a Vega-Altair maintainer) Thanks for the feedback and for the kind words! All of these drawbacks are fair, just a couple of comments. There is an experimental package called altair_tiles that makes is possible to add OSM-style maptile backgrounds to Altair charts. See https://github.com/altair-viz/altair_tiles . This is mostly for static charts at the moment, as it doesn't integrate well with pan/zoo…

Thanks for the feedback! Looking forward to `altair_tiles`. And again, great work, very much appreciate it! Maybe while you're here: Is there any desire to implement box-zoom (or x-range zoom) at any point in the future?

Box zoom would need to be added to Vega-Lite first, and there has been some discussion around it in https://github.com/vega/vega-lite/issues/4742. Bottom line is that there's nothing blocking its implementation, someone just needs to do the work in Vega-Lite. And once released in Vega-Lite, Altair would pick it up automatically with how we generate the Altair API from the Vega-Lite schema.

Re: Vega-Altair: Declarative Visualization in Python

#39

Earlier quoted context omitted.

We are working on GPU accelerated rendering for Vega and Altair.

Is this open? Is there a way to read more about it? Issues/pull requests?

Have you seen https://github.com/jonmmease/avenger? Which is an experimental Vega visualization renderer in Rust using wgpu.

Re: Vega-Altair: Declarative Visualization in Python

#40
post #35

Altair is great. I'm using Plotly more lately, for 2 reasons - chart have very good interactivity by default and I'm also a Dash user - so it comes in naturally. But I believe Altair is excellent for exploration - simple charts are very simple to create, and it's not complicated to create a complex exploration dashboard - with all charts linked between them - so you can select a subset of data on one chart, and it au…

(a current Altair maintainer and a former plotly.py maintainer here) Plotly is definitely a great option as well, and it can do a bunch of things Vega-Altair is not designed for. One comment, just in case you weren't aware, is that there is a relatively new library that provides good integration between Altair and Dash: https://github.com/altair-viz/dash-vega-components . It even makes it possible to access Altair se…

Thank you !

Wasn't aware of that. Are there any plans to improve the interactivity - by that I mean scale on X / Y independently - 'plotly' like ? I know you can bind specifically to one axis, when generating the chart, however, what I usually want is to be able to just zoom in on a specific axis when looking at the chart - Plotly is really great as the behaviour is depending of what you select - a rectangle is just a rectangle (zoom on both axes), a vertical selection zooms on Y axis, and horizontal one on X axis.

Post reply on HN