On 6/7/2012 1:06 PM, Herbert J�gle wrote:
> I have two questions.
> 1. If i use labeller=label_parsed like for plot q, the numbers are
> reformatted with a format like "%.3f", so the 0.0002 will show as 2e-04.
> How can i set the number formatting?
> 2. I want to use label_parsed to use an expression including superscript
> characters. The label should show like "0.01 cd.s/m2" with a superscript 2.
> i tried the following to get an expression
>
> expression(fact_str* ' cd.s/m' ^ '2')
>
> but how do i get fact_str substituted with the actual string and how do i
> get the expression into facet_grid?
I believe what you want is
labeller=label_bquote(expr = (.x)* ' cd.s/m' ^ '2')
I'm not sure about the first request.
See also
https://github.com/hadley/ggplot2/wiki/labeller
> Thanks,
> Herbert
>
> --------
> df.d<- data.frame(x=rnorm(100), y=rnorm(100), fact=rep(c(0.01,0.0002), 50))
> df.d$fact_str<- sprintf('%.4f', df.d$fact)
> df.d$fact_int<- factor(df.d$fact, levels=unique(df.d$fact),
> labels=unique(df.d$fact_str), ordered=TRUE)
>
> p<- ggplot(df.d) +
> geom_point(aes(x, y)) +
> facet_grid(fact_int ~ .)
> print(p)
>
> q<- ggplot(df.d) +
> geom_point(aes(x, y)) +
> facet_grid(fact_int ~ ., labeller='label_parsed')
> print(q)
>
--
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University