Closed Maschette closed 5 months ago
It's working fine for me. What's your sessionInfo()
- maybe different package versions somewhere? The graticule labels are rendered by graphics::text
. What does
plot(0, 1, type = "n")
text(0, 1, labels = parse(text = c("100*degree*E")))
look like? If that's also broken, it's that.
That's also broken... It seems to be a ragg/ggplot issue https://github.com/r-lib/ragg/issues/51
Thomas seems to think it's a base R problem (not ragg), to do with the default Windows graphics device (and introduced in R 4.2.2). I am not near a Windows machine at the moment, can you test this please:
plot(0, 1, type = "n")
text(0, 1, labels = c("100\u00b0E"))
(i.e. using the Unicode degree symbol rather than relying on the "degree" being converted into whatever symbol it's being converted into. If that works, we can use it as a work-around)
That works
Should be fixed in the dev-0.7 branch, by https://github.com/AustralianAntarcticDivision/SOmap/commit/9246d6684362977cd51744b882aa5a7999bcf684 Needs testing on Windows
It works for base plot but no the SOgg version.
Tracking it back, in the ggplot version I think it is because for ggplot we have conveniently been using the degree_label
crated by the graticule package, which uses the degreeLabelsEW
and degreeLabelsNS
functions from sp which are still using "*degree"
https://github.com/edzer/sp/blob/f8488cfbe10deb99c74b2ae2b12524f2bc01524f/R/gridlines.R#L14
For our ggplot rendering it's happening in geom_sf
, and we have no control over it. There is an existing issue: https://github.com/tidyverse/ggplot2/issues/5147
You should see the same problem with (first example from the geom_sf
help):
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
ggplot(nc) +
geom_sf(aes(fill = AREA))
(Our graticule labels, containing the unicode degree symbol, are used when we base-plot but not ggplot - for ggplot we are allowing geom_sf to do it, completely independently of the labels that we construct. It might be possible to suppress geom_sf's label handling and pass our own, but I'm not sure about that ...)
@Maschette I've added a borderline ridiculous and certainly ill-advised workaround in https://github.com/AustralianAntarcticDivision/SOmap/commit/056a49a92335c36756aefc4985ba2e0eba5b4b20. Hopefully the underlying issue gets resolved soon, but in the meantime this might get us by. Could you test pls ...
Confirmed that this is a known bug in R 4.2.2 (https://bugs.r-project.org/show_bug.cgi?id=18440) and has been fixed for the next R version (https://github.com/wch/r-source/commit/ffa365b1e993ec2ed79499d3188b0f6e9fc270dc). So if our dodgy patch works, we should only need to actually use it if the user is running R 4.2.2 on Windows.
I believe this is fixed now and can be closed?
The degrees symbol seems to be broken in both normal and SOgg plotting options?
Created on 2023-02-02 with reprex v2.0.2