From the course: Data Visualization in R with ggplot2

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

The grammar of graphics

The grammar of graphics

From the course: Data Visualization in R with ggplot2

Start my 1-month free trial

The grammar of graphics

- [Instructor] The grammar of graphics lies at the heart of ggplot2 and also lies at the heart of how we define our data visualizations. You can think of the grammar of graphics as very similar to the grammar of any spoken or written language. The grammar of graphics consists of the set of rules that we follow to make sure that we construct sentences that other people can understand. For example, the grammar of words says that we should create sentences that consist of subjects and predicates, and use nouns, verbs, adjectives, and adverbs for different purposes. If we try to compose sentences without a grammar, we wouldn't be able to understand each other. The grammar of graphics has the four components shown in this table. First, we must have some data that we'd like to visualize. Then we use geometries to define the shapes that we'd like to use to visualize our data. This might be points for a scatterplot, lines for a line graph, or bars for a bar or column graph. Then we can modify…

Contents