Skip to content

Commit 8113373

Browse files
committed
Add alpha control to ConditionalSmoothedScatterPlot
1 parent 50a452d commit 8113373

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: WVPlots
22
Type: Package
33
Title: Common Plots for Analysis
44
Version: 1.3.2
5-
Date: 2021-01-02
5+
Date: 2021-01-03
66
Authors@R: c(
77
person("John", "Mount", email = "[email protected]", role = c("aut", "cre")),
88
person("Nina", "Zumel", email = "[email protected]", role = c("aut")),

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
# WVPlots 1.3.2 2021-01-01
2+
# WVPlots 1.3.2 2021-01-03
33

44
* Fix error msg on ThresholdPlot
55
* Add accuracy as a ThresholdPlot metric.
6-
* Turn points of in ConditionalSmoothedScatterPlot.
6+
* Point controls in ConditionalSmoothedScatterPlot.
77

88
# WVPlots 1.3.1 2020-10-17
99

R/ConditionalSmoothedScatterPlot.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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)) {

man/ConditionalSmoothedScatterPlot.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)