【发布时间】:2017-08-03 21:54:50
【问题描述】:
我有一个像这样的数据集:
df <- data.frame(Species = c("Sp A", "Other sp", "Other sp", "Other sp",
"Sp A", "Other sp", "Other sp"),
Study = c("A", "A", "A", "A",
"B", "B", "B"),
Value = c(1, 3, 4, 5, 3, 6, 7))
看起来像这样:
> df
Species Study Value
1 Sp A A 1
2 Other sp A 3
3 Other sp A 4
4 Other sp A 5
5 Sp A B 3
6 Other sp B 6
7 Other sp B 7
我想将物种 A 的值与同一研究中其他物种的值进行比较。
这是我现在的情节:
ggplot(df, aes(y = Value, x = Species)) +
geom_point(shape = 1) +
geom_line(aes(group = Study), color = "gray50") +
theme_bw()
我不想要垂直线。取而代之的是,我想要 5 条线,3 条从较低的“Sp A”点开始,指向同一研究 (A) 的 3 个相应的“其他 sp”点,2 条从上部的“Sp A”开始,指向来自同一研究的其他 2 点 (B)。
【问题讨论】: