in an older script I used following lines to expand the y-axis and to add a
grey rectangle manually to a plot (to make a similar look like facett plots).
The following lines were working before (I can't remember if in the dev-mode or the normal mode) but in the new version, no rectangle is plotted...
y <- runif(1000,1,50000)
x <- runif(1000,1,10)
df <- data.frame(x,y)
yrange <- c(0.01,1000000)
ggplot(df, aes(x=x,y=y))+
geom_point()+
scale_y_continuous("Y-Axis",breaks=c(0.1,1,10,100,1000,10000),labels=c(0.1,1,10,100,1000,10000),limits=yrange,trans="log")+
scale_x_continuous("X Axis",limits=range(df$x),trans="log")+
annotate("rect", xmin=0, xmax=10000, ymin=200000, ymax= 50000000, fill="grey80")+
annotate("text", 3 , 700000, label="X-Axis",size=4) +
theme_bw()+
opts(legend.position = "none",
axis.title.y = theme_blank(),
axis.ticks = theme_blank(),
axis.title.x = theme_blank())
Does anyone know how to do that?
/johannes
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
I think this may be a bug, but if the x/y-min/max is out-of-range, the
the object will not be drawn.
try this:
...
annotate("rect", xmin=2, xmax=8, ymin=10, ymax= 50000, fill="grey80")+
...
2012年3月27日19:35 Johannes Radinger <JRad...@gmx.at>:
> y <- runif(1000,1,50000)
> x <- runif(1000,1,10)
>
> df <- data.frame(x,y)
> yrange <- c(0.01,1000000)
>
>
> ggplot(df, aes(x=x,y=y))+
> geom_point()+
> scale_y_continuous("Y-Axis",breaks=c(0.1,1,10,100,1000,10000),labels=c(0.1,1,10,100,1000,10000),limits=yrange,trans="log")+
> scale_x_continuous("X Axis",limits=range(df$x),trans="log")+
> annotate("rect", xmin=0, xmax=10000, ymin=200000, ymax= 50000000, fill="grey80")+
> annotate("text", 3 , 700000, label="X-Axis",size=4) +
> theme_bw()+
> opts(legend.position = "none",
> axis.title.y = theme_blank(),
> axis.ticks = theme_blank(),
> axis.title.x = theme_blank())
--
--
Kohske Takahashi <takahash...@gmail.com>
Research Center for Advanced Science and Technology,
The University of Tokyo, Japan.
http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
Yes it seems that there is a bug with rectangles that exceed the max values. The problem is that I need a rect that reaches the upper and right border of my plot. Any suggestion how to do that? Or will that bug be fixed in the next time?
/johannes
>
> 2012年3月27日19:35 Johannes Radinger <JRad...@gmx.at>:
> > y <- runif(1000,1,50000)
> > x <- runif(1000,1,10)
> >
> > df <- data.frame(x,y)
> > yrange <- c(0.01,1000000)
> >
> >
> > ggplot(df, aes(x=x,y=y))+
> > geom_point()+
> >
> scale_y_continuous("Y-Axis",breaks=c(0.1,1,10,100,1000,10000),labels=c(0.1,1,10,100,1000,10000),limits=yrange,trans="log")+
> > scale_x_continuous("X
> Axis",limits=range(df$x),trans="log")+
> > annotate("rect", xmin=0, xmax=10000, ymin=200000, ymax=
> 50000000, fill="grey80")+
> > annotate("text", 3 , 700000, label="X-Axis",size=4) +
> > theme_bw()+
> > opts(legend.position = "none",
> > axis.title.y = theme_blank(),
> > axis.ticks = theme_blank(),
> > axis.title.x = theme_blank())
>
>
>
> --
> --
> Kohske Takahashi <takahash...@gmail.com>
>
> Research Center for Advanced Science and Technology,
> The University of Tokyo, Japan.
> http://www.fennel.rcast.u-tokyo.ac.jp/profilee_ktakahashi.html
>
> --
> You received this message because you are subscribed to the ggplot2
> mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
ggplot(df, aes(x=x,y=y))+
geom_point()+
scale_y_continuous("Y-Axis",breaks=c(0.1,1,10,100,1000,10000),labels=c(0.1,1,10,100,1000,10000),trans="log")+
scale_x_continuous("X Axis",trans="log", breaks = c(2, 4, 6, 8))+
annotate("rect", xmin=0, xmax=10000, ymin=200000, ymax=
50000000, fill="grey80")+
annotate("text", 3 , 700000, label="X-Axis",size=4) +
theme_bw()+
opts(legend.position = "none",
axis.title.y = theme_blank(),
axis.ticks = theme_blank(),
axis.title.x = theme_blank()) +
coord_cartesian(xlim = range(df$x), ylim = yrange, wise = TRUE)
2012年3月27日20:07 Johannes Radinger <JRad...@gmx.at>:
setting coord_cartesian in you example was what I was looking for...
...everything is working fine now!
cheers,
johannes
-------- Original-Nachricht --------
> Datum: Tue, 27 Mar 2012 20:28:41 +0900
> Von: Kohske Takahashi <takahash...@gmail.com>
> An: Johannes Radinger <JRad...@gmx.at>
> CC: ggp...@googlegroups.com
> Betreff: Re: annotate "rect" in new ggplot2
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility