@@ -57,6 +57,7 @@ smoothing = function(frm, xvar, yvar, k, align) {
5757# ' @param k width of smoothing window. Must be odd for a center-aligned plot. Defaults to 3
5858# ' @param align smoothing window alignment: 'center', 'left', or 'right'. Defaults to 'center'
5959# ' @param point_color color of points, when groupvar is NULL. Set to NULL to turn off points.
60+ # ' @param point_alpha alpha/opaqueness of points.
6061# ' @param smooth_color color of smoothing line, when groupvar is NULL
6162# ' @param palette name of Brewer palette, when groupvar is non-NULL (can be NULL)
6263# ' @examples
@@ -75,7 +76,9 @@ ConditionalSmoothedScatterPlot = function(frame, xvar, yvar,
7576 title = ' ConditionalSmoothedScatterPlot' ,
7677 ... ,
7778 k = 3 , align = " center" ,
78- point_color = " black" , smooth_color = " black" ,
79+ point_color = " black" ,
80+ point_alpha = 0.2 ,
81+ smooth_color = " black" ,
7982 palette = " Dark2" ) {
8083 vlist <- list (xvar = xvar , yvar = yvar )
8184 if (! is.null(groupvar )) {
@@ -107,7 +110,10 @@ ConditionalSmoothedScatterPlot = function(frame, xvar, yvar,
107110 fs = fs [! is.na(fs $ smooth ), ]
108111 p = ggplot2 :: ggplot()
109112 if (! is.null(point_color )) {
110- p = p + ggplot2 :: geom_point(data = frame , ggplot2 :: aes_string(x = xvar , y = yvar ), color = point_color )
113+ p = p + ggplot2 :: geom_point(data = frame ,
114+ ggplot2 :: aes_string(x = xvar , y = yvar ),
115+ color = point_color ,
116+ alpha = point_alpha )
111117 }
112118 p = p + ggplot2 :: geom_line(data = fs , ggplot2 :: aes_string(x = xvar , y = " smooth" ), color = smooth_color )
113119 } else {
@@ -119,7 +125,9 @@ ConditionalSmoothedScatterPlot = function(frame, xvar, yvar,
119125 fs = fs [! is.na(fs $ smooth ),]
120126 p = ggplot2 :: ggplot()
121127 if (! is.null(point_color )) {
122- p = p + ggplot2 :: geom_point(data = frame , ggplot2 :: aes_string(x = xvar , y = yvar , color = groupvar ))
128+ p = p + ggplot2 :: geom_point(data = frame ,
129+ ggplot2 :: aes_string(x = xvar , y = yvar , color = groupvar ),
130+ alpha = point_alpha )
123131 }
124132 p = p + ggplot2 :: geom_line(data = fs , ggplot2 :: aes_string(x = xvar ,y = " smooth" ,color = groupvar ))
125133 if (! is.null(palette )) {
0 commit comments