开发者

In ggplot2, can I adjust points and lines whose coordinates are determined by their factor level? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Order Bars in ggplot2 bar graph

R: ggplot2 offset scatterplot points

I have an example data.frame and plot here. I would like to slightly re-position the points and horizontal errorbar lines within 'factory' type, so that they don't overlap with each other.

## 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)

If you look at the sample plot, I think you'll see what I'm after. A开发者_如何学JAVAnyone know how? position_dodge seems promising, but I couldn't see how to make it work with points and errorbars.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜