Closed jsgro closed 9 months ago
What graphics device are you using? Have you read the README?
Hello David. Thank you for replying to the issue. The Readme file only says: "This requires R 4.1 or higher, and an appropriate graphics device."
I spent a little more time on the github page, and discovered the "test" directory. I engaged it on my MacBook Pro (Apple M1 Max chip, 32Gb RAM, Ventura 13.6.3) and the images created from these tests are close or identical to the _snaps
from the github page.
There were 50 "Warnings" stating:
In .setMask(mask$f, mask$ref) :
Ignored alpha mask (not supported on this device)
I just got a "Device refresher" from this lesson Graphics Devices in R Swirl Exploratory Data Analysis Lesson 3 (Roger D. Peng (compiled and edited by: Nunno Nugroho))
When we tried yesterday we were therefore using the default RStudio device:
dev.cur()
RStudioGD
2
I am not sure if that is the reason that when we tried "Red" Texas image we still had the neighboring states in blue within the Inset.
The one that triggered our "investigation" was in fact the StarWars picture. I now just tried to change the "Device" to PDF and lo-and-behold... this works.
Your package is a great + to even casual users. But for more casual users, having a minimal information on "Device" would be of gigantic help to understand that one needs e.g. a PDF (or perhaps PNG others) but NOT the RStudio RStudioGD
default!...
Best wishes for a successful continuation, and thanks for making this available to the rest of us! Thanks again, JYS
I just tested the "Texas" commands and I see that it works for PDF but not PNG Device.
However, while the transparency of the backbround of the PDF version is achieved, the Texas state itself is not colored red. With shadow = TRUE
there is a gray coloring inside. With shadow = FALSE
there is only the orange outline. I colored the rest of the states "green4" with "yellow" lines to make the image different. Here are the PDF (Device) output using pdf(file="Texasplot2.pdf")
and dev.off()
:
(Saving to PNG looks the same as the one on the first comment, with a red Texas but blue neighbours.)
The help file for geom_magnify
is pretty clear:
Limitations geom_magnify() uses masks. This requires R version 4.1.0 or higher, and a graphics device > that supports masking. If you are using knitr, you may have luck with the ragg_png device. > If your device doesn't support masks, only shape = "rect" will work, and the plot inset will > not be clipped to the panel area.
Maybe the README should mention this too, but I think it's reasonable to expect people to read the help. I'll keep this open and consider tweaking the README.
I've opened a separate issue for your last comment.
Fixed in e4d791
In our R club today we tried your great package on both Mac and PC and we noted that there is a difference with your images on github. A quick Docker-run Linux version seems to clarify that on Mac/PC there is a lack of cutting-out the background on non-square shapes (e.g. Hexagone) and that is even clearer to see on the Texas Map where the blue background remains on the Mac./PC run command but it is not present on your illustration.
I append the results for the "Texas" plot:
It seems that there may be specific graphics libraries present in Linux-based system that is lacking on macOS and Windows...