library(ggplot2)
x = 1:10
y = x^2
ggplot(data.frame(x, y), aes(x, y)) + geom_point()
Вместо geom_point() можно указать, соответствующую ей по умолчанию статистику stat_identity(), результат будет аналогичный.
ggplot(data.frame(x, y), aes(x, y)) + geom_line()
y = rnorm(100, mean=10, sd=5)
ggplot(data.frame(y), aes(y)) + geom_histogram()
y = c(1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 7, 7, 7, 10)
ggplot(data.frame(y), aes(y)) + geom_bar()
Изменим цвет фона с серого theme_grey (по умолчанию) на чёрно-белый theme_bw.
ggplot(data.frame(y), aes(y)) + geom_bar() + theme_bw()