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

1

6

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?

Dactylology answered 21/1, 2010 at 7:53 Comment(3)
In Windows Explorer, do Tools/Folder Options.../File Types tab/ and then, in the populated list, search for PNG. What is the associated software for opening PNG files? Try to set it back to "Windows Picture and Fax Viewer"Concessive
Thanks for the idea. But I'm really hoping to get something to fix how it shows up in the R plot windowDactylology
I'm using R 2.10.1 on WinXP and it is showing up fine in R. Does the following change something: g <- ggplot(z, aes(x,y)) + geom_point() + theme_bw() Did you check or change screen settings?Colly
C
2

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.

Cranwell answered 22/1, 2010 at 16:18 Comment(1)
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!Quiff

© 2022 - 2024 — McMap. All rights reserved.