3

Suppose I have a function that returns a ggplot object:

getplot = function() {
    x = rnorm(16)
    y = rnorm(16)
    dat = data.frame(x, y)
    myplot = ggplot(dat, aes(x, y)) + geom_point()
    myplot
}

After calling that function

x = getplot()

, how can I change the point size?

qed
  • 22,298
  • 21
  • 125
  • 196

2 Answers2

7

maybe you can use update_geom_defaults :

Modify geom/stat aesthetic defaults for future plots

So to change size:

getplot()
update_geom_defaults("point",list(size=10))
agstudy
  • 119,832
  • 17
  • 199
  • 261
4

Try this:

x = getplot() + geom_point(size=N) 
tbodt
  • 16,609
  • 6
  • 58
  • 83
qed
  • 22,298
  • 21
  • 125
  • 196