我有一些移动应用程序用户的数据(不同电池电量的温度)。我想绘制每个用户的数据(都在一个单线图中)以及所有用户temp
的相似percentage
s 的中位数(在同一个图中,使用较粗的线突出显示它)。我可以使用 ggplot2 绘制除中位数以外的所有线条。这是我的虚拟数据文件(如果需要,我可以更改数据组织/结构或对数据进行分组):
userId, percentage, temp
11, 2, 32
11, 3, 32
11, 4, 33
11, 5, 33
11, 7, 34
11, 10, 30
12, 2, 30
12, 3, 30
12, 4, 30
12, 5, 30
12, 7, 34
12, 10, 32
这是我目前的做法:
library(ggplot2)
sampleDataFrame <- read.table(file.choose(), sep=",", header=T)
sampleDataFrame$userId <- factor(sampleDataFrame$userId)
p1 <- ggplot(sampleDataFrame, aes(x=percentage, y=temp, colour=userId)) + geom_line()
print(p1)
结果如下: