Here is my current script and the output:
这是我当前的脚本和输出:
ggplot(data.and.factors.prov,aes(x=assumptions,y=FP,
colour=factor(Design.Complexity))) +
stat_summary(fun.data=mean_cl_normal,position=position_dodge(width=0.5)) +
geom_blank() + scale_colour_manual(values=1:7,name='Design Complexity') +
coord_flip()
How can I have (horizontal) bars (starting at FP=0 and ending at the point position) instead of points ? (I don't want to lose the error bars)
如何(水平)条形(从FP = 0开始到结束点位置)而不是点? (我不想丢失错误栏)
I'd like to give you my data.and.factors.prov data.table but it is too big to be posted ! If you need a reproducible example, please let me know how I can give you my data set ?!
我想给你我的data.and.factors.prov data.table,但它太大了,无法发布!如果您需要一个可重复的示例,请告诉我如何为您提供数据集?
1 个解决方案
#1
9
For the stat_summary()
default geom is "pointrange"
. To get the bars and errorbars one solution is to use two stat_summary()
calls - one to make errorbars and second to calculate just mean values and plot bars. You will need also to adjust width=
inside the position_dodge(
) and fill=
to the same factor as for colour=
to change filling of bars.
对于stat_summary(),默认geom是“pointrange”。要获得条形和错误条,一个解决方案是使用两个stat_summary()调用 - 一个用于生成错误栏,第二个用于计算平均值和绘图条。您还需要在position_dodge()内调整width =,并将fill =调整为与color =相同的因子,以更改条形的填充。
Here is an example with mtcars
data.
以下是mtcars数据的示例。
ggplot(mtcars,aes(x=factor(cyl),y=mpg,colour=factor(gear),fill=factor(gear))) +
stat_summary(fun.data=mean_cl_normal,position=position_dodge(0.95),geom="errorbar") +
stat_summary(fun.y=mean,position=position_dodge(width=0.95),geom="bar")+
coord_flip()
#1
9
For the stat_summary()
default geom is "pointrange"
. To get the bars and errorbars one solution is to use two stat_summary()
calls - one to make errorbars and second to calculate just mean values and plot bars. You will need also to adjust width=
inside the position_dodge(
) and fill=
to the same factor as for colour=
to change filling of bars.
对于stat_summary(),默认geom是“pointrange”。要获得条形和错误条,一个解决方案是使用两个stat_summary()调用 - 一个用于生成错误栏,第二个用于计算平均值和绘图条。您还需要在position_dodge()内调整width =,并将fill =调整为与color =相同的因子,以更改条形的填充。
Here is an example with mtcars
data.
以下是mtcars数据的示例。
ggplot(mtcars,aes(x=factor(cyl),y=mpg,colour=factor(gear),fill=factor(gear))) +
stat_summary(fun.data=mean_cl_normal,position=position_dodge(0.95),geom="errorbar") +
stat_summary(fun.y=mean,position=position_dodge(width=0.95),geom="bar")+
coord_flip()