【发布时间】:2015-02-04 07:16:05
【问题描述】:
如果不附上情节图像,很难描述我的问题。我有两组数据,一组有两个观察值,平均值约为 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
数据和代码(dataframe 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
我会非常感谢您的帮助,我已经坚持了两天了。提前致谢。
【问题讨论】:
-
我没有看到使用您的数据和脚本的重叠。
-
我正在使用 RStudio 版本。 0.98.1062; R版。 3.0.3 (2014-03-06) 和 ggplot2 版本。 1.0.0,如果有帮助的话。
-
RStudio 与此无关。我使用了相同版本的ggplot2。
-
我也尝试将绘图直接保存为 .png 文件,但同样的事情发生了。帕斯卡,您能否在此处使用我的数据和脚本发布您的结果图像?