ggsql: Grammar of Graphics for SQL
Key point
ggsql has been released as an alpha version that lets you write visualizations using SQL syntax.
Details
The alpha release of ggsql has been unveiled. It's a tool that layers grammar of graphics on top of SQL syntax, letting you define visualizations directly within a query.
The core syntax is as follows.
- VISUALIZE defines the data and aesthetic mappings.
- DRAW stacks layers such as point, smooth, histogram, and boxplot.
- PLACE adds annotation layers such as rule and text.
- SCALE controls color palettes, transformations, and scale types.
- LABEL sets titles, subtitles, and axis/legend labels.
The SQL query portion is everything before VISUALIZE, and result tables or CTEs can be referenced directly from the visualization query. If the data is already prepared, you can omit the SQL portion and just write VISUALIZE ... FROM ....
As examples, it shows a scatter plot of the penguins dataset, a smooth line by species, and a bar chart, and presents a complete example combining a histogram, rule lines, and text annotations using the astronauts dataset. It emphasizes that the same data can easily be turned into different visualizations just by changing the layers and settings, such as boxplot, point + jitter, or distribution => 'density'.
The motivation behind its creation is to provide a more natural visualization experience for SQL users and to make reproducible, code-based reporting easier in Quarto, Jupyter, Positron, VS Code, and similar tools. It also cites the fact that LLMs are good at handling SQL as an advantage of this as a new interface.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.