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

Degrees symbol broken #108

Open
Maschette opened this issue Feb 2, 2023 · 10 comments
Open

Degrees symbol broken #108

Maschette opened this issue Feb 2, 2023 · 10 comments

Comments

@Maschette
Copy link

The degrees symbol seems to be broken in both normal and SOgg plotting options?

library(SOmap)
#> Loading required package: raster
#> Loading required package: sp
x<-c(20,160)

y<-c(-30, -60)

map<-SOgg(SOmap_auto(x,y,input_points=F, input_lines = F))

map

Created on 2023-02-02 with reprex v2.0.2

@raymondben
Copy link
Member

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.

@Maschette
Copy link
Author

Maschette commented Feb 2, 2023

That's also broken...
It seems to be a ragg/ggplot issue r-lib/ragg#51

@raymondben
Copy link
Member

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)

@Maschette
Copy link
Author

That works

@raymondben
Copy link
Member

Should be fixed in the dev-0.7 branch, by 9246d66
Needs testing on Windows

@Maschette
Copy link
Author

It works for base plot but no the SOgg version.

@Maschette
Copy link
Author

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

@raymondben
Copy link
Member

raymondben commented Feb 6, 2023

For our ggplot rendering it's happening in geom_sf, and we have no control over it. There is an existing issue: tidyverse/ggplot2#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 ...)

@raymondben
Copy link
Member

@Maschette I've added a borderline ridiculous and certainly ill-advised workaround in 056a49a. Hopefully the underlying issue gets resolved soon, but in the meantime this might get us by. Could you test pls ...

@raymondben
Copy link
Member

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 (wch/r-source@ffa365b). 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants