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

Custom formating of axis tick labels #2389

Open
dazu89 opened this issue May 6, 2024 · 1 comment
Open

Custom formating of axis tick labels #2389

dazu89 opened this issue May 6, 2024 · 1 comment
Labels
feature a feature request or enhancement

Comments

@dazu89
Copy link

dazu89 commented May 6, 2024

Apparently, ggplot2 relies on sf to draw the graticule and axes labels. Currently, when trying to plot to tikzDevice the usage of plotmath expression for the degree symbol in the axes labels paste0(abs(x), "*degree", dir[pos]) (see degreeLabelsEW function) leads to an error as ‹there is specifically no support for input of plotmath characters as unicode since the user can simply input Latex math directly› (Tikz User Manual).
I wanted to suggest to hard code the degree symbol as \u00B0 which is rendered correctly with the default graphic device but also with tikzDevice using the options(tikzDefaultEngine = 'xetex').

> sessionInfo()
R version 4.4.0 (2024-04-24 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)

Matrix products: default

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] scales_1.3.0      tikzDevice_0.12.6 ggplot2_3.5.1     sf_1.0-16        

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5        cli_3.6.2          rlang_1.1.3        DBI_1.2.2         
 [5] KernSmooth_2.23-22 png_0.1-8          generics_0.1.3     labeling_0.4.3    
 [9] glue_1.7.0         colorspace_2.1-0   e1071_1.7-14       fansi_1.0.6       
[13] grid_4.4.0         munsell_0.5.1      classInt_0.4-10    tibble_3.2.1      
[17] lifecycle_1.0.4    compiler_4.4.0     filehash_2.4-5     dplyr_1.1.4       
[21] Rcpp_1.0.12        pkgconfig_2.0.3    rstudioapi_0.16.0  digest_0.6.35     
[25] farver_2.1.1       R6_2.5.1           class_7.3-22       tidyselect_1.2.1  
[29] utf8_1.2.4         pillar_1.9.0       magrittr_2.0.3     tools_4.4.0       
[33] proxy_0.4-27       withr_3.0.0        gtable_0.3.5       units_0.8-5
@edzer
Copy link
Member

edzer commented May 6, 2024

I wanted to suggest to hard code the degree symbol as \u00B0 which is rendered correctly with the default graphic device but also with tikzDevice using the options(tikzDefaultEngine = 'xetex').

Interesting thought, but how do we make sure that this works across all graphic devices, given that graphics is not part of the package testing code? Maybe start with implementing your special case only?

@edzer edzer added the feature a feature request or enhancement label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants