Live data from Hacker News

Vega-Altair: Declarative Visualization in Python

altair-viz.github.io

41–44 of 44 posts

Re: Vega-Altair: Declarative Visualization in Python

#41
I love Vega(-lite) / Altair, the grammar of graphics plotting system is really great to build any kind of chart even when it wasn't thought through by the authors of the library. There are other wrappers for languages that lack viz libraries, such as Elixir / Livebook [0]

However, when I used it a couples years back it struggled with large vizs, I think due to Vega(-lite)'s way of embedding the data in the viz artifact.

Also, interactive is nice but often I just need a quick static plot, and matplotlib is more convenient for this, you can easily see the png in any environment etc.

These days I'm eager to see an Observable Plot [1] wrapper for Python ! See [2] for a comparison to vega-lite

[0] https://github.com/livebook-dev/vega_lite

[1] https://github.com/observablehq/plot

[2] https://observablehq.com/@observablehq/plot-vega-lite

Re: Vega-Altair: Declarative Visualization in Python

#42
post #2

> empowers you to spend less time writing code and more time exploring your data Sidenote: I like Altair and think it's a good development, despite rendering being performed client side. This said, the claim here is tiring when it's used everywhere. Having spent significant time with Altair, I'd argue it might have tighter code but the documentation can be obscure. I haven't found it to make things easier from a deve…

Feel free to open an issue to let us know which parts of the documentation you find obscure and if you have suggestions for how to improve them. We did a larger overhaul a few months back and are always open to feedback on how to improve it further! https://altair-viz.github.io/

(disclaimer: I'm a co-maintainer of Altair)

Re: Vega-Altair: Declarative Visualization in Python

#43

Like many, I was a big fan of ggplot2 from R, so coming into Python, I've always been searching for an equivalent graphical library. I used to be put off by Altair's famous MaxRowsError: The number of rows in your dataset is greater than the maximum allowed (5000). but ever since the Vegafusion companion library came unto the scene, I'm back using Altair. Overall, it's my preferred Python viz library although I do wi…

Altair actually does introspection when the data is passed as a dataframe (e.g. via pandas or polars). In these cases you can leave out the `:Q` and just write `x='abc'` and Altair will figure out that the encoding type shoudl be quantitative based on the column datatype in the dataframe.

If you are reading the data directly from a URL instead of via a dataframe, the URL is passed on to Vega-Lite and Python never sees the data, so no introspection can be made on the Altair side of things.

(disclaimer: I'm a co-maintainer of Altair)

Re: Vega-Altair: Declarative Visualization in Python

#44

Earlier quoted context omitted.

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...

If you are interested in similar shortcuts for repeated charts in Altair, I'm experimenting a bit with such a syntax in the package altair-ally https://joelostblom.github.io/altair_ally/examples.html. Feel free to try it out and leave feedback!

(disclaimer: I'm a co-maintainer of Altair)

Post reply on HN