以下是数据的小例子:
data <- read.table(header=TRUE, text='
height measurement temperature
h1 m1 24.5
h2 m1 24.0
h3 m1 25.0
h4 m1 16.0
h1 m2 22.0
h2 m2 25.0
h3 m2 23.5
h4 m2 17.0
h1 m3 23.2
h2 m3 24.2
h3 m3 23.0
h4 m3 16.9
')
library(ggplot2)
ggplot(data, aes(x=temperature, y=height, colour=measurement)) +
geom_point(shape=19, size=2.5) +
xlim(15, 30)
我想制作一个垂直折线图。这样的事情:http://i.stack.imgur.com/EeCrC.jpg
有什么想法吗?
答案 0 :(得分:1)
ggplot(data, aes(x=temperature, y=height, colour=measurement, group=measurement)) +
geom_point(shape=19, size=2.5) +
geom_path() +
xlim(15, 30)
答案 1 :(得分:0)
我认为这会有所帮助。我建议玩颜色来获得确切的感觉。
library(ggplot2)
ggplot(data) + geom_point(aes(temperature, factor(height), color=measurement)) + geom_path(aes(temperature, factor(height), group=measurement))