我正在尝试创建一个图以显示每个组(按因素组织)中计算值的平均值,以及各个指标本身。我已经成功地做到了这一点,但是所有点都使用相同的符号。我希望每个因子中的每个点都有一个不同的符号,并且最好为每个因子以相同的顺序使用相同的点。
下面是我目前正在制作的图形的示例版本,但是同一列中的所有点都使用相同的符号。
我曾考虑过使用点的行号来定义符号形状,但是我认为默认ggplot2
程序包中只有25种不同的形状可用,而且我的真实数据有25个以上的点,如果相同的点,我更希望在每列中使用,以保持图形看起来一致。
Mean_list <- data.frame(Cells = factor(c("Celltype1", "Celltype2", "Celltype3",
"Celltype4"),
levels =c("Celltype1", "Celltype2", "Celltype3", "Celltype4")),
Mean = c(mean(c(1, 2, 3)), mean(c(5, 8, 4)), mean(c(9, 8 ,3)),
mean(c(3, 6, 8, 5))))
values_list <- data.frame(Cells2 = rep(c("Celltype1", "Celltype2", "Celltype3",
"Celltype4"), times = c(length(c(1, 2, 3)),
length(c(5, 8, 4)), length(c(9, 8 ,3)),
length(c(3, 6, 8, 5)))),
values = c(1, 2, 3, 5, 8, 4, 9, 8, 3, 3, 6, 8, 5))
ggplot() + geom_col(data = Mean_list, aes(Cells, Mean, fill = Cells)) +
geom_point(data = values_list, aes(Cells2, values))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句