错误栏通过打开的符号显示 [英] Error bars show through open symbol
问题描述
我有一对有点偏移的点。每对点都有相关的误差线。我已经指出,这一对中第一个点的符号与第二个点的符号不同(实心圆与空心圆)。我希望它能够通过打开的符号显示错误栏。
I have a plot with pairs of points that are slightly offset. Each pair of points has associated error bars. I have specified that the symbol of the first point in the pair is different from that of the second (closed circle vs open circle). I would like it so that the error bars do not show through the open symbol.
这是一个模拟数据集:
x = runif(4,-2,2)
x_1 = runif(4,-1,3)
dfr <- data.frame(
x = c(x, x_1),
y = rep(c("A","B","C","D"), 2),
upper = c(x+2, x_1+1),
lower = c(x-2, x_1-2),
type = rep(c("alpha", "beta"), each = 4))
这里是情节:
And here is the plot:
dodge=position_dodge(width=0.5)
ggplot(dfr,aes(x=y,y=x,colour=type)) +
geom_point(size=8,aes(shape=type),position=dodge) +
geom_errorbar(aes(ymax=upper,ymin=lower),position = dodge) +
scale_colour_manual(values = c('gray','black')) +
scale_shape_manual(values = c(19,21)) +
coord_flip() +
opts(legend.position="none")
感谢您提供任何帮助e!
Thanks for any help you can provide!
推荐答案
我想不出一种方法来制作一个开放的点,而不是让错误栏显示低谷。这样做的唯一方法是用与背景颜色相同的点填充点,但是通过这一点您的网格线将不可见。
I can't think of a way to make an 'open' point and not let the errorbar show trough. The only way of doing this would be to fill the points with the same colour as the background, but then your gridlines won't be visible through the point.
做将 fill
唯美性映射到类型,并用填充颜色 grey90 <>指定
scale_fill_manual
/ code>这是 theme_grey
设置:
To do this, map the fill
aesthetic to type, and specify scale_fill_manual
with the fill colour grey90
which is the theme_grey
setting:
ggplot(dfr,aes(x=y,y=x,colour=type, fill=type)) +
geom_errorbar(aes(ymax=upper,ymin=lower),position = dodge) +
geom_point(size=8,aes(shape=type),position=dodge) +
scale_colour_manual(values = c('gray','black')) +
scale_fill_manual(values=c('grey', 'grey90')) +
scale_shape_manual(values = c(19,21)) +
coord_flip() +
opts(legend.position="none")
这篇关于错误栏通过打开的符号显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!