O'Reilly logo

Learning Shiny by Hernán G. Resnizky

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

ggplot2 – first steps

ggplot2 (an acronym for Grammar of Graphics plot) is the most popular graphical package in R. This relies mainly on the fact that almost anything can be drawn with it. This huge flexibility, however, implies more complexity while drawing.

The underlying concept of ggplot2 is an empty canvas. Instead of specifying the type of plot and the data to be visualized, the ggplot2 functions expect vectors that denote positions, widths, sizes, and so on. From its conceptual point of view, this is very similar to an HTML document; this is an empty space that is filled with different objects to which different characteristics are specified. The following example is the equivalent of plot(iris$Sepal.Length):

ggplot.graph <- ggplot(data=iris) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required