geom_crossbar 生成的图的 y 比例不合适

geom_crossbar produces a plot with inappropriate y scale

如果不附上情节图片,很难描述我的问题。我有两组数据,一组有两个观察值,均值约为 1,误差约为 1.5;另一个有两个观察值,平均值约为 30,误差约为 2。

但在图中,条形重叠且 y 轴刻度线乱序:

0; 0.1; 1; 1.7; 2; 27.8; 29.3; 29.8; 3.2; 31.3; 31.8; 33.3

数据和代码(数据框my.data):

my.data <- structure(list(factor1 = structure(c(1L, 1L, 2L, 2L), .Label = c("oil1", "oil2"), class = "factor"), factor2 = structure(c(1L, 2L, 1L, 2L), .Label = c("prod1", "prod2"), class = "factor"), value = c(1.7, 1, 29.8, 31.3), err = c(1.5, 1, 2, 2), min = c(0.2, 0, 27.8, 29.3), max = c(3.2, 2, 31.8, 33.3)), .Names = c("factor1", "factor2", "value", "err", "min", "max"), class = "data.frame", row.names = c("1", "2", "3", "4"))

    # Plots
      p1 <- ggplot(data=my.data, aes(x=factor2, fill=factor1))
      p2 <- p1 + geom_crossbar(aes(y=value, ymin=min, ymax=max), position = position_dodge(width = 0.66), width=0.6)
      p2

非常感谢对此的帮助,我已经坚持了两天了。提前致谢。

使用您的数据和脚本我得到: