【发布时间】:2014-12-15 10:17:38
【问题描述】:
我想在 ggplot2 中绘制折线图。这是我的数据的样子
query,trace,precision,recall
safe.order.q3.txt,rstr_oper_50000_100m,49.8406,24.9156
safe.order.q3.txt,sstr_cpu_50000_100m,49.774,24.8442
safe.order.q3.txt,sstr_oper_50000_100m,49.8735,24.885
safe.sem.q1.txt,ran_50000_100m,74.9204,24.8125
safe.sem.q1.txt,sys_50000_100m,58.1995,11.8975
safe.sem.q1.txt,rstr_cpu_50000_100m,75.6115,25.1855
safe.sem.q1.txt,rstr_oper_50000_100m,75.2262,24.9382
safe.sem.q1.txt,sstr_cpu_50000_100m,74.997,25.0963
safe.sem.q1.txt,sstr_oper_50000_100m,75.4195,25.3233
safe.sem.q2.txt,ran_50000_100m,78.6449,24.6323
safe.sem.q2.txt,sys_50000_100m,10.9353,0.255188
safe.sem.q2.txt,rstr_cpu_50000_100m,79.3762,24.6961
这是我存储在文件recprec.r中的ggplot代码
w <- read.csv(file="../queryResults/comparison.100m.dat", head=TRUE, sep=",")
sem1 <- subset(w, query=="safe.sem.q1.txt")
p1 <- ggplot(data=sem1, aes(x=trace, y=precision)) + layer(geom="line") + geom_text(aes(y=precision + .4, label=precision))
print(p1)
代码的执行会产生以下错误,并且下图中的字符不显示值之间的线
> source("recprec.r")
geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
我错过了什么?
【问题讨论】:
-
您对
color=aes 的意图是什么?你想要某种多色线吗?通常,新颜色意味着新线,因此由于您为每个新的“Trace”值指定了新颜色并且“trace”是 x 轴,因此您没有连接点。 -
你说得对,颜色在这里无关紧要,让我编辑我的问题。
-
在那之后您是否尝试重新绘制?这没有改变剧情吗?现在有线路吗? (由于您的示例数据不包含列标题,因此不容易测试)
-
删除
aes中的颜色并没有改变任何东西。我已经更新了我的问题以在我的数据中添加标题。