cheat sheet图中大致得知:
?...五脏俱全的散点图
library(ggplot2)
# 表明我们使用diamonds数据集,
ggplot(diamonds) +
# 绘制散点图: 横坐标x为depth, 纵坐标y为price...= "black") +
# 添加垂直线
geom_vline(xintercept = 3, size = 1, linetype = "dotted", color = "black")...下面展示箱线图最长使用的一些方法:
library(ggplot2) # 绘图
library(ggsci) # 使用配色
# 使用diamonds数据框, 分类变量为cut, 目标变量为depth...p <- ggplot(diamonds, aes(x = cut, y = carat)) +
theme_linedraw()
# 一个因子型变量时, 直接用颜色区分不同类别, 后面表示将图例设置在右上角