[R] ggsave to .png bug in ggplot2 (?)

Chris Friedl cfriedalek at gmail.com
Thu Aug 20 04:29:01 CEST 2009

Text is really small and legend boxes are huge in this plot when saved to
.png with ggsave. Plot is correct (i.e. looks the same as the screen) when
saved with dev.print. Saving to .pdf with ggsave give the correct output.

I'm a noob at ggplot2 so this may be user error rather than a bug. However
the interface to ggsave seems simple enough to exclude many possibilities
for screwing this up through ignorance. We'll see I guess.

Here's the example.

x <- data.frame(value=rnorm(5000, mean=0), case="A")
y <- data.frame(value=rnorm(5000, mean=3), case="B")
xy <- rbind(x, y)
p <- ggplot(xy, aes(x=value, colour=case, group=case)) + geom_density()

ggsave(p, filename = "xy_ggsave.png") 
dev.print(device=png, width=600, height=600, file="xy_devprint.png")
ggsave(p, filename = "xy_ggsave.pdf") 
dev.print(device=pdf, file="xy_devprint.pdf")

View this message in context: http://www.nabble.com/ggsave-to-.png-bug-in-ggplot2-%28-%29-tp25055170p25055170.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list