Quando salvi un ggplot che utilizza geom_raster
, le piastrelle escono "macchiate". È lo stesso risultato se uso ggsave()
o pdf()
. Non ho questo problema con geom_tile
o image
. Non ho questo problema con i dispositivi grafici RStudio, X11 o PNG.geom_raster esce "imbrattato" quando si salva in PDF
Che cosa sta causando questo? Come posso ripararlo?
Esempi:
library(ggplot2)
## doesn't work: tiles are smeared together
ggsave("smeared1.pdf",
ggplot(cbind(expand.grid(x = 1:3, y = 1:3), fill = rnorm(9))) +
geom_raster(aes(x = x, y = y, fill = fill)))
pdf("smeared2.pdf")
ggplot(cbind(expand.grid(x = 1:3, y = 1:3), fill = rnorm(9))) +
geom_raster(aes(x = x, y = y, fill = fill))
dev.off()
## works fine
ggsave("not-smeared0.png",
ggplot(cbind(expand.grid(x = 1:3, y = 1:3), fill = rnorm(9))) +
geom_raster(aes(x = x, y = y, fill = fill)))
ggsave("not-smeared1.pdf",
ggplot(cbind(expand.grid(x = 1:3, y = 1:3), fill = rnorm(9))) +
geom_tile(aes(x = x, y = y, fill = fill)))
pdf("not-smeared2.pdf")
ggplot(cbind(expand.grid(x = 1:3, y = 1:3), fill = rnorm(9))) +
geom_tile(aes(x = x, y = y, fill = fill)))
dev.off()
pdf("not-smeared3.pdf")
image(matrix(rnorm(9), 3))
dev.off()
Forse inviare una schermata o due in modo che possiamo facilmente vedere che cosa vuoi dire? – Gregor