tags:

views:

535

answers:

1

I'm having a strange problem with the output window in RGui (under Win XP). I should see a plot like the one below...

alt text

... when I run this script:

library(ggplot2)
x <- rnorm(100,0,1)
y <- rnorm(100,0,1)
z <- data.frame(x,y) 
g <- ggplot(z, aes(x,y)) + geom_point() + theme_gray()

Instead, in the plot window it shows a white background and white grid lines, like below.

R Plot Window

alt text

When I export the plot to .png and I "preview" it in windows explorer - it doesn't show a background or grid lines.

Png in Windows

alt text

Same Png in Gimp

alt text

Same Png uploaded to image hosting

alt text

Any ideas about what's going on? How can I get the plot to display correctly in RGui?

+1  A: 

Sounds like a problem with the device rather than R, try reinstalling GTK+. If that doesn't work try plotting jpegs instead of png's if you can.

Brandon Bertelsen
I agree that it sounds like a device issue (a common problem with R, sadly!), but I strongly disagree with the recommendation to use JPGs. JPG is a *lossy* bitmap format, great for photos, terrible for things with lines. An alternative to PNG might be PDF, which is a lossless vector format ideal for graphs. Plus, you can use Inkscape to edit PDFs now, which is a great way to tweak ggplot (or any other R) output!
Harlan