passing parameters to ggplot

前端 未结 4 1418
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 03:00

would like to create a function that generates graphs using ggplot. For the sake of simplicity, the typical graph may be

ggplot(car, aes(x=speed, y=dist)) +          


        
4条回答
  •  余生分开走
    2020-12-05 03:45

    Another option is to use do.call. Here is a one line copy paste from a working code:

    gg <- gg + geom_rect( do.call(aes, args=list(xmin=xValues-0.5, xmax=xValues+0.5, ymin=yValues, ymax=rep(Inf, length(yValues))) ), alpha=0.2, fill=colors )
    

提交回复
热议问题