Math symbols in ggplot facets

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Math symbols in ggplot facets

Lars Bishop-2
Hello,

I would like to show in my facet labels the equivalent in LaTex of
$\sigma_{0}= \sqrt{2}$. I think I'm close below, but not yet as it shows
$(\sigma_{0}, \sqrt{2})$

m <- mpg
levels(m$drv) <- c("sigma[0]=sqrt(2)", "sigma[0]=2 * sqrt(2)", "sigma[0]= 3
* sqrt(2)")

ggplot(m, aes(x = displ, y = cty)) + geom_point() +
  facet_grid(. ~ drv, labeller = label_parsed)


Thanks,
Lars.

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Math symbols in ggplot facets

djmuseR
Hi:

You were close...

library(ggplot2)
m <- mpg

# Set the factor labels with plotmath code (note the ==)
m$drv <- factor(m$drv, labels = c("sigma[0] == sqrt(2)",
                                  "sigma[0] == 2 * sqrt(2)",
                                  "sigma[0] == 3 * sqrt(2)"))

ggplot(m, aes(x = displ, y = cty)) + geom_point() +
  facet_grid(. ~ drv, labeller = label_parsed)

Dennis

On Sat, Feb 22, 2014 at 3:24 AM, Lars Bishop <[hidden email]> wrote:

> Hello,
>
> I would like to show in my facet labels the equivalent in LaTex of
> $\sigma_{0}= \sqrt{2}$. I think I'm close below, but not yet as it shows
> $(\sigma_{0}, \sqrt{2})$
>
> m <- mpg
> levels(m$drv) <- c("sigma[0]=sqrt(2)", "sigma[0]=2 * sqrt(2)", "sigma[0]= 3
> * sqrt(2)")
>
> ggplot(m, aes(x = displ, y = cty)) + geom_point() +
>   facet_grid(. ~ drv, labeller = label_parsed)
>
>
> Thanks,
> Lars.
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.