ggplot()

Every ggplot2 graph starts with the ggplot() function. Plot variables are specified inside the aes() function.

This page uses the lfs26sep dataset from the Setup section.

ggplot()
ggplot(lfs26sep)

Empty grey ggplot canvas with no axes

ggplot(lfs26sep, aes(x = hrlyearn))

ggplot canvas with an x-axis for hourly earnings and no data

ggplot(lfs26sep, aes(x = uhrsmain, y = hrlyearn))

ggplot canvas with x- and y-axes and no data

To draw data on the canvas, add a geom function, such as geom_histogram(), using +. The next examples show how.