[R] [ggplot] trouble with ggabline and log-log-plots

hadley wickham h.wickham at gmail.com
Tue Oct 24 20:20:31 CEST 2006


> I'm trying to generate a log-log plot with ggplot. Within this plot, I
> would like to draw a straight line with the help of ggabline which does
> not work. The code is
>
> pl1 <- qplot(correlFunc, correlFunc.ref, data=all, log=c("xy"))
> pl1 <- ggabline(pl1, slope=1, intercept=0)
> print(pl1) ## no line in plot :(

I'm not really sure what the correct behaviour is here.  What do you
expect this line to look like?  It has intercept 0, which is -infinity
on the log scale, so where should I start drawing the line?


> But this is definetly not nice and I cannot imagine ggplot is meant to
> be used like this. Furthermore, I would desperately like see ticks in
> the form of expression(10^2). Is there some way acheiving this without
> to much work or did I overlook an option within the docs?

You should be able to specify them explicity using pscontinuous.  But
in general, coming up with nice tick marks is a very difficult problem
and my heuristics aren't very good.  Any suggestions would be
welcomed.

Hadley



More information about the R-help mailing list