我正在使用 geom_area 在堆叠的样本中绘制一组变量,并且我想让特定“案例”= N 的线条更大并且具有特定颜色(红色)。我已经定义了颜色,但是如何使用正确的代码添加命令scale_color_manual?我正在使用更大的数据集 Variable=92 所以我想避免单独绘制变量...
data <- tibble::tibble(
value = c(0.0693, 0.0677, 0.0727, 0.0650, 0.0908, 0.00112, 0.131, 0.0975, 0.109, 0.105, 0.0927, 0.0552, 0.0532, 0.0559, 0.0771, 0.0563, 0.0551,
0.191, 0.193, 0.147, 0.157, 0.258, 0.00738, 0.00808, 0.00661, 0.00495210983601696, 0.451, 0.379, 0.0653, 0.0350, 0.0559, 0.192, 0.0738, 0.107,
0.0138, 0.0104, 0.0145, 0.0103, 5.08255237961193E-05, 0.0361, 0.0264, 0.0454, 0.0277, 0.0117, 8.92140244446427E-05, 0.0173727368061961, 0.0108, 8.54627809588924E-05, 2.35593459925552E-05, 3.13020069803476E-05, 1.12019464502152E-05,
0.0453, 0.0577, 0.0627, 0.0450, 0.0508, 0.00212, 0.031, 0.0875, 0.100, 0.115, 0.0827, 0.0452, 0.0332, 0.0459, 0.0671, 0.0263, 0.0451),
Sample = rep(c(1:17),4),
Variable = rep(c(rep("A1",17),rep("A2",17),rep("A3",17),rep("A4",17))),
Case = rep(c(rep("P",17),rep("N",34),rep("L",17))))
ggplot(data, aes(x=Sample, y=value, color=Case, group = interaction(Variable,Case))) + geom_line(position = "stack") + scale_color_manual(values = c("P" = "green4", "N" = "red", "L"="black"))
我也尝试过这段代码,但是在顶部再次绘制了两个 N 值,并与已经存在的值重叠:
p + geom_line(data=subset(data, Case == "N"), colour="red", size=1.5)
类似的东西可能是什么?
scale_size_manual(values=c(size = ("L"=0.5), ("N"=1), ("P"=0.5)))