Skip to content

Custom formating of axis tick labels #2389

Open
@dazu89

Description

@dazu89

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions