project-gen3sis / R-package

Repository of the R-packageGen3sis
https://project-gen3sis.github.io/R-package/
GNU General Public License v3.0
28 stars 9 forks source link

Plotmath greek characters render differently depending on plot device #71

Open dkStevensNZed opened 5 months ago

dkStevensNZed commented 5 months ago

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 commented 5 months ago

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: https://github.com/project-gen3sis/R-package/issues/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 :man_shrugging: 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 commented 5 months ago

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?