Thank you, that works wonderfully. My plot is now:
ggplot(runtimes, aes(x='', fill=variants, y=speedup)) +
geom_hline(yintercept=1, colour='grey50') +
geom_bar(stat='identity', position='dodge') +
opts(axis.title.x=theme_blank()) +
facet_grid(. ~ bench) +
scale_x_discrete(breaks=NA) +
scale_y_log2('Speedup (1.0 = CPython 2.4.1)')
(I also tried with x=NA, but that gave me ticks marked 'NA').
>> In the same plot, I have a log2-scale y axis with an axis label. Is it
>> possible to increase the space (which currently appears to be zero)
>> between the tick labels and axis label?
I'm still having this problem (see attached). I've tried every spacing
parameter I could find, but note how the bottom of the left
parenthesis touches the 2 in 2^-1. Any ideas?
--Nicholas
This is a poor spacing choice which I hope to improve in the next
version. In the meantime, the easiest solution is probably just to
add a new line to the axis label:
scale_y_log2('Speedup (1.0 = CPython 2.4.1)\n')
Hadley
I'd like to be able to use scale_y_logit() and
coord_trans(ytrans="invlogit") to construct a plot summarizing some
proportion data. I have two problems:
1) scale_y_logit() fails with the error
Error in plogis(q, location, scale, lower.tail, log.p) : Non-numeric
argument to mathematical function
You can see this with the following code:
--8<---------------cut here---------------start------------->8---
library(boot) # logit()
library(ggplot2)
## load binomial data, compute proportion (disregarding sample size
## for this example)
data(cbpp, package="lme4")
cbpp <- within(cbpp, prop <- incidence/size)
## plot the mean proportion. works.
ggplot(cbpp, aes(x=as.numeric(period), y=prop)) +
stat_summary(fun.y=mean, geom="line")
## plot the logit of the mean proportion by hand. works.
ggplot(cbpp, aes(x=as.numeric(period), y=prop)) +
stat_summary(fun.y=function(y) logit(mean(y)), geom="line")
## use a transformer to get the logit of the mean proportion.
## breaks with error reported above
ggplot(cbpp, aes(x=as.numeric(period), y=prop)) +
stat_summary(fun.y=mean, geom="line") +
scale_y_logit()
--8<---------------cut here---------------end--------------->8---
Also, maybe I've got things backwards here, but why does the transformer
to put things onto the logit scale call plogis? plogis takes values in
the logit space and returns probabilities. qlogis takes probabilities
and returns results in logit space.
qlogis(0) # -Inf, logit space
plogis(0) # 0.5, probability space
For a transformation from probability space into logit space, which is
what I think scale_y_logit() is supposed to do, don't we want qlogis?
2) invlogit isn't defined as a possible transform
At the end of the above plot, I'd ideally like to add something like
+ coord_trans(ytrans="invlogit") # should use plogis?
But that transformer is not in the list in table 6.2 of the book. So,
is it possible to define new transformers? What do they have to look
like?
Thanks for any help,
/au
--
Austin Frank
http://aufrank.net
GPG Public Key (D7398C2F): http://aufrank.net/personal.asc
Ooops. Fixed in the development version.
Yes, you're right. Fixed in the development version too.
> For a transformation from probability space into logit space, which is
> what I think scale_y_logit() is supposed to do, don't we want qlogis?
>
> 2) invlogit isn't defined as a possible transform
>
> At the end of the above plot, I'd ideally like to add something like
>
> + coord_trans(ytrans="invlogit") # should use plogis?
To define your own transformer, call Trans$new. It takes three
arguments: the function, it's inverse, and a function to create
labels. A few examples should give you the idea:
TransLog2 <- Trans$new("log2", "log2", function(x) 2^x, function(x)
bquote(2^.(x)))
TransPow10 <- Trans$new("pow10",function(x) 10^x, "log10", function(x) log10(x))
Does that help?
Hadley