ragg
ragg copied to clipboard
ragg does not render minus sign in axis title superscript
I have an unusual issue, which I can't isolate the cause of. The ragg png device seems to drop the minus sign in negative exponents, for example, day-1 or 10-1.
It seems to work fine with the base png device. Example:
data(mtcars)
# Using base png device
png("/tmp/default_image.png")
plot(data = mtcars, disp ~ mpg, xlab = expression("efficiency" ~ mpg^-1))
dev.off()
#> png
#> 2
# Using ragg png device
ragg::agg_png("/tmp/ragg_image.png")
plot(data = mtcars, disp ~ mpg, xlab = expression("efficiency" ~ mpg^-1))
dev.off()
#> png
#> 2
Created on 2021-08-22 by the reprex package (v2.0.1)
Session info
sessionInfo()
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Arch Linux
#>
#> Matrix products: default
#> BLAS: /usr/lib/libopenblasp-r0.3.17.so
#> LAPACK: /usr/lib/liblapack.so.3.10.0
#>
#> locale:
#> [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
#> [4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
#> [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] ragg_1.1.3
#>
#> loaded via a namespace (and not attached):
#> [1] knitr_1.33 magrittr_2.0.1 rlang_0.4.11 fansi_0.5.0
#> [5] stringr_1.4.0 styler_1.5.1 highr_0.9 tools_4.1.1
#> [9] xfun_0.25 utf8_1.2.2 withr_2.4.2 systemfonts_1.0.2
#> [13] htmltools_0.5.1.1 ellipsis_0.3.2 yaml_2.2.1 digest_0.6.27
#> [17] tibble_3.1.3 lifecycle_1.0.0 crayon_1.4.1 textshaping_0.3.5
#> [21] purrr_0.3.4 vctrs_0.3.8 fs_1.5.0 glue_1.4.2
#> [25] evaluate_0.14 rmarkdown_2.10 reprex_2.0.1 stringi_1.7.3
#> [29] compiler_4.1.1 pillar_1.6.2 backports_1.2.1 pkgconfig_2.0.3
These lead to:
Base png:
ragg png:
I'm unsure how to debug this. Any suggestions would be really appreciate. Thanks.
Interestingly, it seems like forcing the minus sign through unicode works:
data(mtcars)
# Using ragg png device
ragg::agg_png("/tmp/ragg_image.png")
plot(data = mtcars, disp ~ mpg, xlab = expression("efficiency" ~ mpg^{"\u2212"*1}))
dev.off()
#> png
#> 2
Created on 2021-08-22 by the reprex package (v2.0.1)
Session info
sessionInfo()
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Arch Linux
#>
#> Matrix products: default
#> BLAS: /usr/lib/libopenblasp-r0.3.17.so
#> LAPACK: /usr/lib/liblapack.so.3.10.0
#>
#> locale:
#> [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C LC_TIME=en_GB.UTF-8
#> [4] LC_COLLATE=en_GB.UTF-8 LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
#> [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=C LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] knitr_1.33 magrittr_2.0.1 ragg_1.1.3 rlang_0.4.11
#> [5] fansi_0.5.0 stringr_1.4.0 styler_1.5.1 highr_0.9
#> [9] tools_4.1.1 xfun_0.25 utf8_1.2.2 withr_2.4.2
#> [13] systemfonts_1.0.2 htmltools_0.5.1.1 ellipsis_0.3.2 yaml_2.2.1
#> [17] digest_0.6.27 tibble_3.1.3 lifecycle_1.0.0 crayon_1.4.1
#> [21] textshaping_0.3.5 purrr_0.3.4 vctrs_0.3.8 fs_1.5.0
#> [25] glue_1.4.2 evaluate_0.14 rmarkdown_2.10 reprex_2.0.1
#> [29] stringi_1.7.3 compiler_4.1.1 pillar_1.6.2 backports_1.2.1
#> [33] pkgconfig_2.0.3
This issue seems to be unique to your system or maybe Arch Linux... Don't know what to make of it I'm afraid
Will see if I can reproduce in a VM