我正在尝试创建一个图表来显示每个组内的计算值的平均值(按因子组织),以及归属点本身 . 我成功地做到了这一点,但是所有的点都使用相同的符号 . 我希望每个因子中的每个点都有不同的符号,并且最好对每个因子使用相同顺序的相同点 .
我目前正在制作的那种图形的示例版本如下,但是同一列中的所有点都使用相同的符号 .
我已经考虑过使用点的行数来定义符号形状,但我认为默认的 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))
1 回答
在绘图之前,我们可以为单元格中的每一行分配一个数字: