3 Reviewing the basic concepts of Altair
This chapter covers
- Vega and Vega-Lite
- The basic components of an Altair chart
- A relevant case study
It may, at first glance, seem counterintuitive for the topic of running a data story in Altair (chapter 2) to be covered before the basics of Altair (chapter 3). The reason is that now that you have a general understanding of how Altair works, you’re ready to see all the details. If you had read this chapter right away, you probably would have gotten bored and skipped it. Instead, now, you are ready to read it calmly. In this chapter, we will review the basic concepts underlying Vega and Vega-Lite, the visualization grammars upon which Altair is built. Then, we’ll focus on the Altair main components: encodings, marks, conditions, compound charts, and interactivity. In the last part of the chapter, we’ll implement a practical example.
3.1 Vega and Vega-Lite
Vega and Vega-Lite are visualization grammars used by Altair. A visualization grammar is a set of rules and principles defining how to represent data visually, much like how grammar functions in a spoken language. A visualization grammar includes a vocabulary of visual elements, such as points, lines, and bars, as well as rules for combining and arranging these elements to create meaningful visualizations. Using a visualization grammar allows you to create clear and effective data visualizations that convey insights and tell stories.