Sebastian Weber
2006-Oct-24 17:16 UTC
[R] [ggplot] trouble with ggabline and log-log-plots
Hello,
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 can produce plots as I want, if I transform all values before
plotting, like this:
pl2 <- qplot(log10(correlFunc), log10(correlFunc.ref), data=all)
pl2 <- ggabline(pl2, slope=1, intercept=0)
print(pl2) ## ah, I see the line, cool!
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?
Well, my versions are ggplot 0.4.0, R 2.3.1 on ubuntu edgy.
Thanks a lot in advance for your help.
Greetings,
Sebastian Weber
> 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