ggplot: Initiate a new ggplot

View source: R/ggplot.r

ggplotR Documentation

Initiate a new ggplot

Description

If you declare a dataset and an aesthetic mapping inside the ggplot() call, each layer will inherit that information by default.

Usage

ggplot(data, aes(x, y, ...))

Arguments

data

A tibble.

x

Specify which variable should be drawn on the x-axis.

y

Specify which variable should be drawn on the y-axis.

...

Any other aeshetic mappings (color, fill, etc).

Examples

library(tidyverse)
library(gapminder)

# Draw a scatterplot:

ggplot(gapminder, aes(x = gdpPercap, y = lifeExp)) +
  geom_point()

# Draw a histogram:

ggplot(gapminder, aes(x = lifeExp)) +
  geom_histogram()


cobriant/qelp documentation built on July 1, 2022, 7:24 a.m.