Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R ggplot2 - no background or grid lines in plot with RGui

Tags:

r

ggplot2

rgui

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?

like image 442
user246211 Avatar asked Jan 21 '10 07:01

user246211


1 Answers

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.

like image 182
Brandon Bertelsen Avatar answered Nov 10 '22 16:11

Brandon Bertelsen