I tried to offset an object, so that it doesn't overlap others - here's a simple example:
ggplot(diamonds[1:1000,], aes(cut, carat)) + geom_point(alpha=0.3) + stat_summary(fun.data="mean_cl_normal", color="red")
I'd like to move the pointrange a bit to the right, so that the points are not overlapped - I tried position_dodge, etc. but it didn't work ...
Any ideas?
Thanks,
Felix
maybe like this:
ggplot(diamonds[1:1000,], aes(cut, carat)) +
geom_point(alpha=0.3,position=position_dodge(width=.2)) +
stat_summary(fun.data="mean_cl_normal",color="red")
regards,
stefan
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
>
that works for the points - however, I want to move the pointrange-object and unfortunately it does not work for that (maybe because it is only one object and the dodge algorithm distributes the objects based on their count?).
Best,
Felix
Am 05.02.2010 um 10:42 schrieb smu:
> Hi,
>
> maybe like this:
>
> ggplot(diamonds[1:1000,], aes(cut, carat)) +
> geom_point(alpha=0.3,position=position_dodge(width=.2)) +
> stat_summary(fun.data="mean_cl_normal",color="red")
>
> regards,
> stefan
>
maybe something like
stat_summary(fun.color="red",position="jitter",heigth=0)
But it is not perfect, the different spaces between poitnrange and
points doesn't look so nice. Maybe someone else has a better idea.
regards,
stefan
Best,
Felix
df <- diamonds[1:1000,]
ggplot(df, aes(y = carat)) +
geom_point(aes(as.numeric(cut)), alpha=0.3) +
stat_summary(aes(as.numeric(cut)+0.2), fun.data="mean_cl_normal",
color="red") +
scale_x_continuous('cut', breaks = 1:nlevels(df$cut), labels =
levels(df$cut), minor_breaks = NA)
Xie Chao
Best,
Felix
You can simplify the code a little bit:
df <- diamonds[1:1000,]
ggplot(df, aes(cut, carat)) +
geom_point(alpha=0.3) +
stat_summary(aes(as.numeric(cut)+0.2), fun.data="mean_cl_normal",
color="red")
Hadley