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

Plotmath greek characters render differently depending on plot device #71

Open
dkStevensNZed opened this issue Apr 9, 2024 · 2 comments

Comments

@dkStevensNZed
Copy link

A quirky little issue this. Using quarto/pdf, I created a plot with plotmath greek character mu $\mu$ in the y label. In rendering to pdf, if the chunk's dev is not selected {r}, the greek mu is rendered as a proportional symbol ($\propto$). If I use {r,dev='cairo_pdf'} , mu renders correctly. The same code in pure R (executed from the console) shows properly. Here's a MWE in quarto. I hope this is a known issue. Any help is welcome.

`---
format: pdf

{r}
#| echo: false
#| message: false
#| fig-cap: myCap
#| fig-height: 3.5
#| fig-width: 5.
#| out-width: 5.in
x <- rnorm(20,0,1)
plot(x,
xlab='x var',
ylab=expression(paste('The Greek Letter mu (', mu, ')')))

{r,dev='cairo_pdf'}
#| echo: false
#| message: false
#| fig-cap: myCap2
#| fig-height: 3.5
#| fig-width: 5.
#| out-width: 5.in
plot(x,
xlab='x var',
ylab=expression(paste('The Greek Letter mu (', mu, ')')))
`

@benj919
Copy link
Collaborator

benj919 commented Apr 17, 2024

Hi @dkStevensNZed

Thanks for this issue.

Unicode plotting in R is a sad mess -.- There was an issue where Cran did a crack down recently: #66

I'm pretty sure the default printing also depends on your locale and language settings.

Iirc we tried using cairo_pdf, but it did not play well with other parts of the plotting code... or I didn't have the time to fully convert all plotting 🤷‍♂️ we may revisit this topic at some point

Are you asking for help, or was this just a comment on how you solved the issue?

cheers

@dkStevensNZed
Copy link
Author

Thanks for the update. Kinda both - asking for help and the comment on the approach to use if ever one needs to avoids these circumstances. I haven't tried all possibilities, only noticed that 'mu' becomes 'proportion' but beta renders correctly. I haven't noticed other issues with cairo_pdf. What should I be looking out for?

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

No branches or pull requests

2 participants