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

Rendering artefacts when using spplot #131

Closed
janlimbeck opened this issue Apr 11, 2023 · 3 comments · Fixed by #98
Closed

Rendering artefacts when using spplot #131

janlimbeck opened this issue Apr 11, 2023 · 3 comments · Fixed by #98

Comments

@janlimbeck
Copy link

When using ragg as the png rendering device I observe striping/visible borders e.g. when plotting spatial data using spplot from the sp package. I think under the hood lattice is used.

library(lattice)
library(sp)

trellis.par.set(sp.theme()) # sets bpy.colors() ramp
demo(meuse, ask = FALSE, echo = FALSE)

l2 <- list("SpatialPolygonsRescale", layout.north.arrow(), offset = c(181300,329800), 
           scale = 400)
l3 <- list("SpatialPolygonsRescale", layout.scale.bar(), offset = c(180500,329800), 
           scale = 500, fill=c("transparent","black"))
l4 <- list("sp.text", c(180500,329900), "0")
l5 <- list("sp.text", c(181000,329900), "500 m")

meuse.grid$g <- factor(sample(letters[1:5], 3103, replace=TRUE),
                       levels=letters[1:10])
meuse.grid$f <- factor(sample(letters[6:10], 3103, replace=TRUE),
                       levels=letters[1:10])
spplot(meuse.grid, c("f","g"), col.regions=bpy.colors(10))

With default rendering device:
image

With ragg as rendering device:
image

@edzer
Copy link

edzer commented May 2, 2023

See also r-spatial/stars#573 - for raster maps png usually does a better job. For pkgdown, you can turn using ragg off, see https://github.com/r-spatial/stars/blob/main/_pkgdown.yml

@janlimbeck
Copy link
Author

Thanks for the response!

I am using the code within an RShiny application. I am aware that I can turn ragg off globally but would like to avoid that if possible due to the other benefits that ragg provides over the native rendering device.

Is there a way to select a specific rendering device for one individual RShiny plot? That would be an acceptable workaround for me.

@tcwilkinson
Copy link

One work-around for you may be to add a thin border of the same colour as the fill. Haven't tried it myself, and not sure if it has effect on performance -- but if lucky it may achieve what you want without playing with graphics devices etc...

See here: #103 (comment)

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

Successfully merging a pull request may close this issue.

3 participants