Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: label_tex as an extention of ggplot2::label_parsed #160

Merged
merged 9 commits into from
Aug 16, 2022

Conversation

atusy
Copy link
Contributor

@atusy atusy commented Aug 14, 2019

By this PR, math in facets' stripe becomes quite easy.

image

library(dplyr)
library(ggplot2)
library(ggforce)
d <- data.frame(
    facet = "$f(x) = \\frac{1}{\\sqrt{2\\pi\\sigma^2}}exp\\left(-\\frac{(x-\\mu)^2}{2\\sigma^2}\\right)$",
    x = seq(-3, 3, 0.1)
  ) %>%
  mutate(y = dnorm(x))
ggplot(d, aes(x, y)) +
  geom_line() +
  facet_wrap(~ facet, labeller = label_tex)

@thomasp85
Copy link
Owner

I would love to add this but would prefer if latex2exp was put in Suggest instead of Import

@atusy
Copy link
Contributor Author

atusy commented Aug 16, 2022

I'm glad you like this. I force pushed with following changes

  • moved latex2exp to suggests
  • rebased to current main branch
  • coordinated with latest API of ggplot2 and latex2exp

Copy link
Owner

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic - just a few changes needed

R/labeller.R Outdated Show resolved Hide resolved
R/labeller.R Outdated Show resolved Hide resolved
R/labeller.R Show resolved Hide resolved
@atusy
Copy link
Contributor Author

atusy commented Aug 16, 2022

Thank you for the review!! Now the problems should be fixed.

@atusy
Copy link
Contributor Author

atusy commented Aug 16, 2022

Oops, I need to avoid string becoming factors by as.data.frame .

@thomasp85
Copy link
Owner

Once the last merge conflicts are fixed I can merge

@thomasp85 thomasp85 merged commit cd9a76b into thomasp85:main Aug 16, 2022
@thomasp85
Copy link
Owner

thanks!!

@atusy
Copy link
Contributor Author

atusy commented Aug 16, 2022

Thank you, too!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants