
Altair: Declarative Visualization in Python - TheAlchemist
https://altair-viz.github.io/
======
peatmoss
Jake and company are doing nice work here. By comparison to the R community, I
feel that the Python community sometimes swashbuckles toward new libraries
without always doing a good review of prior art. Not so in this case.

Vega / Vega-lite are doing something cool, namely bringing the grammar of
graphics to the web. By extension, Altair may not be the only plotting library
you need in Python, but it's rapidly becoming the one I'd look to first.

------
siddboots
I would be interested in hearing peoples experience of Altair vs Bokeh. I've
used Bokeh on a couple of very small vis products, but never really dived into
it fully. Altair seems to have a similar goals, and a similar design
philosophy. Is that an accurate impressions? Does either of the two stand
obviously ahead of the other?

~~~
afonit
Altair enables you to do very quick data visualizations of your data - this is
crucial when doing Exploratory Data Analysis. There is minimal code to write
to get sophisticated plots. That to me is its strength.

Bokeh's strength (for me) is when I need to heavily customize a visual to an
extreme. I know of some who use it for streaming data - etc which cannot be
done in altair.

Additionally you would only want to use Altair on medium sized data. But Bokeh
in combination with Holoviews and Datashader can render incredible amounts of
data (see pyviz.org)

------
gandreani
As a Python newbie, their docs seem wayyy more welcoming than MatPlot.

I'm a newbie to data visualization so their extensive examples and how their
organized is a way better exploratory experience for me.

Also their API seems way more sane than MatPlot. I haven't used both
extensively so these are just first impressions

~~~
brilee
You're right that matplotlib has an unpleasant API - I've never had a good
experience with matplotlib, but I've used Altair for a few data viz tasks and
love it.

Matplotlib intentionally took on the API that Matlab had created, to make it
easier for Matlab users to jump over to the Python ecosystem. But today, very
few people are coming to Python from a Matlab background so the API just looks
wonky.

~~~
mkl
Matplotlib basically has two APIs, the global state Matlab-like one PyPlot
(which is often used in beginner tutorials), and a much nicer object-oriented
API, where state is explicitly connected to the plot components.

To quote from their documentation [1]: "While it is easy to quickly generate
plots with the matplotlib.pyplot module, we recommend using the object-
oriented approach for more control and customization of your plots."

I use matplotlib.pyplot for basically only two purposes, calling subplots to
get figure and axis objects, or calling rc_context to set up a "with" block
with certain settings (e.g. font size).

That said, I'm certainly watching where alternative plotting libraries are
going. I've used bqplot a bit, but only played around with others so far.

[1] [https://matplotlib.org/api/pyplot_summary.html#the-object-
or...](https://matplotlib.org/api/pyplot_summary.html#the-object-oriented-api)

------
ngould
I like Altair, and have built a couple analyses and products with it. In
general, it's a convenient way to do exploratory data analysis. But I have
found it to be sort of inflexible for simple variations on common chart types
-- especially if you want to augment a chart with information that is not in
the dataframe instance used to instantiate the altair.Chart object. For
instance, if you want to draw a line overlay on a chart, the best way to do it
(to my knowledge) is append the start and end coordinates to your dataframe
before calling mark_line().

I'm curious whether anyone else has had similar frustrations? I wonder what
enhancements might make practical use of Altair for those use cases easier.

~~~
kanitw
For drawing lines with specific coordinate values, you can just encode
position (x, y, x2, y2) of lines or rules with constant values?

If you have specific use case that's really cumbersome in Altair/Vega-Lite,
please feel free to file an issue. We're happy to help improve the tool. :)

Disclosure: I'm a co-author of Vega-Lite.

------
danso
I've been interested in Altair ever since I saw this blog post comparing it to
other Python libraries a couple years back:

[https://dsaber.com/2016/10/02/a-dramatic-tour-through-
python...](https://dsaber.com/2016/10/02/a-dramatic-tour-through-pythons-data-
visualization-landscape-including-ggplot-and-altair/)

At that time (Fall 2016), Altair was at v1.2. Version 1.2.1 hit a full year
later. And v2.0 apparently landed just last month:

[https://github.com/altair-viz/altair/releases](https://github.com/altair-
viz/altair/releases)

~~~
domoritz
The final 2.0 release of Altair was actually just yesterday.

------
sandGorgon
Can this not be used to make reports ? It seems it is closely tied to the
choice of the front-end (co-lab, jupyter,etc).

What about batch mode - in case you want to generate reports and send it by
email ?

~~~
domoritz
I haven't seen anyone build these specific applications but I don't see
anything in the way of building it.

Notebooks can be shared just like any other Jupyter Notebook (charts become
images unless are running the notebook). If you want something more polished,
you can build a dashboard. Under the hood, Altair uses Vega-Lite so you can
export your charts and embed them in a web dashboard with
[https://github.com/vega/vega-embed](https://github.com/vega/vega-embed). To
send charts, you can export them as images.

------
nsriv
Quick little issue in the docs for Getting Started>Installation>Quick
Start:Altair+Colab:

Following the instructions leads to an error at the from vega_datasets line.

Needed to fix by first running !pip install vega_datasets

I see there's a debate on building vega_datasets into Altair, but just wanted
to offer a potential revision to the docs for that section.

------
smrtinsert
What's the ggplot of python?

~~~
huac
[https://github.com/has2k1/plotnine](https://github.com/has2k1/plotnine)
matches the ggplot2 API and philosophy very closely and returns good results.
It's not as polished as ggplot2 but is excellent for day-to-day work. The
author also accepts PR's and is quick to respond to issues.

