我从带有df = as.data.frame(read.table("file.txt"))
的文本文件中导入了以下数据
AED round2 round3
1 0.00 0.020 0.022
2 0.02 0.041 0.045
3 0.04 0.066 0.073
4 0.06 0.094 0.103
5 0.08 0.120 0.132
6 0.10 0.146 0.160
7 0.12 0.171 0.189
8 0.14 0.195 0.215
9 0.16 0.218 0.241
10 0.18 0.240 0.265
现在我想制作一个简单的点图,其中y轴上的round2值与x轴上的AED值相同,并且在同一图形中,第二个图表显示round3的值,其中颜色不同,间距为0.10。
我想到的最好的解决方案是qplot(data=df, AED, round2, color="Round2")
但我需要一些帮助,如何在那里获得第二个绘图以及如何将轴上的间距从0.25更改为0.10
我在这里阅读了http://www.cookbook-r.com/Graphs/Axes_%28ggplot2%29/的教程,但是他们使用的是不同的数据布局,每个行都明确指定了组,而不是简单的标题。
那么我怎么能得到这个为每一列制作1个图? (在一个图中)
这是一个使用dotchart在基本graphics中的解决方案
# Make data frame with a factor and two numeric ranges
Dt <- data.frame(Item = c("a","b","c","d","e","f"),
V1 = seq(1:6),
V2 = seq(1:6)+.2
)
# Plot dotchart for first range
dotchart(Dt$V1,
labels = Dt$Item,
pch = 20,
pt.cex = 2 ,
xlim = c(0, max(Dt$V2)),
col = "blue")
# Allow over-plotting
par(new = TRUE)
# Plot dotchart for second range
dotchart(Dt$V2,
labels = Dt$Item,
pch = 15,
pt.cex = 2,
xlim = c(0, max(Dt$V2)),
col = "black"
)
# Add a legend for each range
legend("bottomright",
c("V1","V2"),
pch = c(20,15),
col = c("blue","black")
)