0

Im trying to fix this scatterplot so the background is WHITE, and there is no grid... is this possible? Also changing the text to Open Sans if that is even an option.

data$Aspects <- factor(data$Aspects,
                       levels = c("Key Support Areas",
                       "Strategic Support and Relationship Management",
                       "Sales and Marketing Support",
                       "Google AW Account Management and Product Support"))
library(ggplot2)    
ggplot(data = data, aes(x = X, y = Y,  color = Aspects)) + 
    geom_point(size=3) + 
    scale_colour_manual(values = c("blue", "red4", "purple4", "olivedrab")) +
    geom_text(aes(label = Label),
                color = "black", hjust=0.4, vjust=1.5, size = 2.5) +
    labs(x = "Impact on Overall Satisfaction", y = "Higher Rating")

enter image description here

A better quality version of the image is available here: http://s14.postimg.org/z0z3f3yhd/PSAT_2014_Executive_Summary_Chart_Exclude_AGY.png

Community
  • 1
  • 1
user3735087
  • 41
  • 1
  • 1
  • 4
  • This may have been handled here: (slight edit) [remove grid backgroud](http://stackoverflow.com/questions/10861773/remove-grid-background-color-and-top-and-right-borders-from-ggplot2) – samhiggins2001 Jun 13 '14 at 22:50
  • See this questino for fonts: http://stackoverflow.com/questions/4094094/modifying-fonts-in-ggplot2 – Ricardo Saporta Jun 13 '14 at 23:07

2 Answers2

0

You can turn off the grid and change the background to white with a theme()

ggplot(data.frame(x=1:10, y=cumsum(rnorm(10))), aes(x,y)) + 
    geom_point() + 
    theme(panel.background=element_rect(fill="white"), 
      panel.grid.major = element_blank(), 
      panel.grid.minor = element_blank()
)

As far as I know, changing font faces is no easy task.

MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • @BenBolker if I read correctly this only works with PDFs and windows bitmaps. I'm still out if luck with my Mac PNGs? – MrFlick Jun 14 '14 at 01:12
  • as far as I can tell. (Do you insist on PNG? Can you use ImageMagick or some other converter to get PDF -> PNG?) – Ben Bolker Jun 14 '14 at 01:17
  • based on comments elsewhere maybe the Cairo device will let you do it? http://rforge.net/doc/packages/Cairo/CairoFontMatch.html – Ben Bolker Jun 14 '14 at 01:19
0

So first of all, your code does not run as is: you have not shown us the full data frame data. Second, even if it did, it would not produce the plot you show, because the legend is not positioned properly.

Assuming your plot is called ggp, as in

ggp <- ggplot(data=data,...) + geom_point(...) + geom_text(...) etc.

and assuming the Open Sans font is installed on your (Windows...) system, then this will yield the result you want:

windowsFonts(OpenSans=windowsFont("Open Sans"))
ggp +
  theme(panel.background=element_blank(),
        panel.grid.major=element_blank(),
        panel.grid.minor=element_blank(),
        text=element_text(family="OpenSans"))
jlhoward
  • 58,004
  • 7
  • 97
  • 140