hrbrmstr's Daily Drop

Share this post

Drop #126 (2022-10-25): Livin' La Vida Vega[-Lite]

dailyfinds.hrbrmstr.dev

Drop #126 (2022-10-25): Livin' La Vida Vega[-Lite]

vl-convert; lux; altair Themes

boB Rudis
Oct 25, 2022
Share this post

Drop #126 (2022-10-25): Livin' La Vida Vega[-Lite]

dailyfinds.hrbrmstr.dev

There is a rich data visualization ecosystem around the Vega and Vega-Lite grammars. Today's drop includes a new CLI utility for working with Vega[-Lite] specs, dead simple Vega-powered interactive EDA, and theming resources to make Vega output less, um, "Vega".

vl-convert

three pupas
Photo by Suzanne D. Williams on Unsplash

Vega-Lite specs are nothing more than JSON files that conform to a schema designed to make it very straightforward — if not a tad verbose, even in -Lite form — to completely describe a data visualization. How that spec is rendered is up to the rendering engine. While there have been a few Vega[-Lite] CLI rendering tools, there's a new Rusty kid on the block called vl-convert that enabled rendering Vega and Vega-Lite specs to SVG or PNG and Vega-Lite specs to full-on Vega specs.

An example render from a spec generated by Alicia Shep's seriously cool {vegabrite} R package (just call vegawidget::vw_as_json() on any Vega-Lite spec created by her package to get the JSON spec) is below. I modified the height and width for show (and inverted the image colors), but you can swap out any compatible data source and use the same spec to generate similar data visualizations.

Jon Mease has way more details over on his (ugh) Medium blog, which goes into why he made the utility, the Python hooks for it, and future work for the utility and module.

Share

lux

purple diamond shaped glass decor
Photo by Michael Dziedzic on Unsplash

While I continue to be a believer in the "static-first" data visualization principle, there are times and places where interactive data visualizations should be paramount. One great use of them is the Python lux module, which is best described as "automagical interactive exploratory data analysis (EDA)". Give lux a pandas data frame, and you get a series of interactive charts to explore it:

Highlighted Visual Dataframe Workflow with Lux

While lux can be used in the default way, you can also specify various exploratory intents directly. There's a great Binder example using COVID-19 intervention data, which shows off both the simplicity and power of the package.

To see even more of what you can do with lux, head on over to their gallery of examples.

Leave a comment

altair Themes

multicolored pastel paints lot
Photo by Maureen Sgro on Unsplash

Normally, one can recognize a D3/Vega[-Lite] data visualization by the tell-tale steelblue bars and default axis and font styles. Whenever I see them, my first response is similer to that of the former default {ggplot2} gray panel plots, which is either "someone is new to the library" or "someone was in a hurry".

Customizing a plot takes quite a bit of work, but if you wrap that work into a theme, you can then apply said themes to future plots with much less effort. These themes also allow you to brand your chart, whether said brand be personal or according to some organizational style guide.

Altair is a Pythonic way to specify Vega[-Lite] specs (there's also an R version of it), and these specs can be themed. You don't need to take my word for it as Sergio Sánchez Zavala (@chekoswh) has a great blog on the topic with accompanying code/examples. Sergio goes way into the details, as you can see in his theming scaffold outline:

If you're in the Vega[-Lite] universe and haven't adopted a theme, yet, take some time to dig into Sergio's post and start building up your own brand (and save some time!).

Share

FIN

For U.S. readers, November 8th is not too far away! Make sure you know where to vote (if you haven’t already) and keep this list handy in the event you need to report on any voter intimidation tactics. ☮

Share this post

Drop #126 (2022-10-25): Livin' La Vida Vega[-Lite]

dailyfinds.hrbrmstr.dev
Previous
Next
Comments
TopNewCommunity

No posts

Ready for more?

© 2023 boB Rudis
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing