在ggplot2中,我可以调整坐标由其因子水平决定的点和线吗?

时间:2011-09-12 14:08:10

标签: r ggplot2

  

可能重复:
  Order Bars in ggplot2 bar graph
  R: ggplot2 offset scatterplot points

我在这里有一个示例data.frame和plot。我想稍微重新定位'factory'类型中的点和水平误差线,以便它们不会相互重叠。

## example data.frame 
df <- structure(list(factory = structure(c(1L, 1L, 4L, 4L, 3L, 3L, 
2L, 2L), .Label = c("A", "B", "C", "D"), class = "factor"), response = c(0.12, 
0.08, 0.14, 0.11, 0.12, 0.11, 0.15, 0.09), lci = c(0.13, 0.1, 
0.11, 0.09, 0.11, 0.06, 0.13, 0.06), uci = c(0.14, 0.07, 0.15, 
0.1, 0.22, 0.14, 0.15, 0.08), variable = structure(c(1L, 2L, 
1L, 2L, 1L, 2L, 1L, 2L), .Label = c("T1", "T2"), class = "factor")), .Names = c("factory", 
"response", "lci", "uci", "variable"), row.names = c("3", "4", 
"5", "6", "7", "8", "9", "10"), class = "data.frame")

## example plot
qplot(response, factory, colour = variable, data = df) +
  geom_point() +
  geom_errorbarh(aes(xmax = response + uci, xmin = response - lci),
                 height = .25)

如果你看一下样本情节,我想你会看到我正在追求的东西。谁知道怎么样? position_dodge似乎很有希望,但我看不出如何使它与点和错误栏一起工作。

0 个答案:

没有答案