-
Notifications
You must be signed in to change notification settings - Fork 96
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
Visual artefacts when plotting stars objects #573
Comments
Both look good on my computer, with
I assume it has something to do with your OS & graphics device combination. What happens if you plot directly to pdf or png? |
That's certainly possible. Although I see similar effects in the pngs toward the end of the page from the generated html vignettes here: https://r-spatial.github.io/stars/articles/stars5.html I am on macos, details below. sessionInfo details
Direct to png (or pdf) creates similar hairlines when you look closely:
Effect more pronounced when output png is smaller...
|
Looking further into The problem is from a hairline gap or line that geom_sf is producing between polygons, also visible in original ggplot() + geom_sf(data=nc,mapping=aes(fill=AREA),col=NA,lwd=0) It doesn't cause a problem for these irregular polygons, although perhaps technically wrong, but with many tiny polygons (which the stars object becomes), then you start getting the artefacts. @edzer Do these lines also appear for you? (i.e. is this platform / graphic dev specific) |
No, they do not appear for me.
That vignette was created by the MacOS GitHub actions runner (broken a.t.m.). |
Thanks for checking. So tha all suggests it is macos graphics device issue then (and not even hidden in geom_sf). No idea where to chase something like that up! :-( Will look and update this issue if I can find something. |
I now suspect that it has something to do with the
(see https://ragg.r-lib.org/articles/ragg_quality.html#observations ) When I uninstall
Just to compare, I checked alternative settings on RStudio -> Preferences -> General -> Graphics:
=> Conclusion, Since I think this may be related to issues in
@edzer Just to be sure, can I check what graphics device you have? |
Fantastic. I believe I run cairo, as > capabilities("cairo")
cairo
TRUE |
I didn't test, but maybe it will help? This needs to be added to RMarkdown. knitr::opts_knit$set(dev.args = list(type = "cairo")) |
Another idea is maybe removing the Edit: With the 1fa061e it seems to work (vignette 2) but macOS is unhappy:
Probably XQuartz must be installed. |
CairoPNG did the job, but there are now new artefacts e.g. the figure in this section. How would you go about remove What I don't understand is why I cannot get the artefacts on my own computer, Ubuntu, with |
stars/.github/workflows/tic.yml Lines 110 to 111 in 1fa061e
For me locally on Windows and Ubuntu using Cairo the plots look good. |
It wasn't the best idea. Now we get this error: |
Thanks @kadyb and @tcwilkinson ! The advice is to stay away from using |
In 2af98c3 I added a > agg_png("/tmp/x.png")
> dev.capabilities()$rasterImage
[1] NA where > png("/tmp/x.png")
> dev.capabilities()$rasterImage
[1] "yes" |
Also, the examples there show that |
I'm not sure if this should be seen as a bug or just a necessary result of working with certain forms of translation.
I've noticed that plotting stars objects as sf or as curvilinear can result in some distracting visual artefacts (see examples below). I tried to work around, but have not found fix yet.
Suspect that these artefacts are not universal, can depend on graphics device, and device dimensions etc. etc. and won't be created by all datasets, but still don't like them much(!).
Is this a bug, or necessary result of working with rasters in a certain way (e.g. when transformed or warped)?
If the second, does anyone has good advice on how to avoid/reduce the effects of these, either within stars directly or by wrangling the data/plotting functions?
Some examples taken from the vignette docs (https://r-spatial.github.io/stars/articles/stars5.html), as per version: 3c0b627
Here the artifacts involve vertical and horizontal lines, looks like hairline outlines are created by converting each raster cell into polygon, to give a tartan effect. But color=NA and lwd=0 don't seem to help.
Here the artifacts look like circles, but closer in you can see that it looks like rotate hairline border lines or gaps.
Attempting to remove these lines with
color = NA
results in warning (as geom_stars already seems to request this anyway), but changes nothing.lwd=0
(an alternative way of removing polygon borders in ggplot) also has no effect.Just for good measure, it's not just ggplot, you can also see these in base plot, though the effect is different, depending on the size of the output.
It doesn't seem to be a problem with non-translated regular projected raster in base plot though.
The text was updated successfully, but these errors were encountered: