ggplot2 line plot - R software and data visualization
基本的线图
数据
这里使用的数据来自数据集ToothGrowth,描述了不同剂量药物下牙齿的生长情况...按组别改变线型
下面图中,组别的线型、点类型都是根据变了supp自动控制的:
# 按组别 (supp) 改变线型
ggplot(df2, aes(x=dose, y=len, group=supp))...+
geom_line(aes(linetype=supp))+
geom_point()
# 改变线型和点的类型
ggplot(df2, aes(x=dose, y=len, group=supp...()
# 使用position_dodge水平移动误差棒以避免重叠
ggplot(df3, aes(x=dose, y=len, group=supp, color=supp)) +
geom_errorbar...自定义线图
# 简单的线图
# 分组改变点型和线型
ggplot(df3, aes(x=dose, y=len, group = supp, shape=supp, linetype=supp))+