@@ -145,13 +145,13 @@ color_scheme_set <- function(scheme = "blue") {
145145# ' @rdname bayesplot-colors
146146# ' @md
147147# ' @export
148- # ' @param i For `color_scheme_get()`, a subset of the integers from `1`
148+ # ' @param i For `color_scheme_get()`, an optional subset of the integers from `1`
149149# ' (lightest) to `6` (darkest) indicating which of the colors in the
150150# ' scheme to return. If `i` is not specified then all six colors in the
151151# ' scheme are included.
152152# '
153- color_scheme_get <- function (scheme , i ) {
154- if (! missing (scheme )) {
153+ color_scheme_get <- function (scheme = NULL , i = NULL ) {
154+ if (! is.null (scheme )) {
155155 scheme <- scheme_from_string(scheme )
156156 } else {
157157 x <- .bayesplot_aesthetics $ scheme
@@ -160,7 +160,8 @@ color_scheme_get <- function(scheme, i) {
160160 attr(scheme , " scheme_name" ) <- attr(x , " scheme_name" )
161161 }
162162 class(scheme ) <- c(" bayesplot_scheme" , " list" )
163- if (missing(i )) {
163+
164+ if (is.null(i )) {
164165 return (scheme )
165166 } else if (is.character(i )) {
166167 return (get_color(i ))
@@ -179,7 +180,6 @@ color_scheme_view <- function(scheme = NULL) {
179180 if (is.null(scheme ) || length(scheme ) == 1 ){
180181 return (plot_scheme(scheme ))
181182 }
182-
183183 bayesplot_grid(
184184 plots = lapply(scheme , plot_scheme ),
185185 grid_args = list (ncol = length(scheme ))
@@ -192,6 +192,7 @@ print.bayesplot_scheme <- function(x, ...) {
192192 colnames(tab ) <- attr(x , " scheme_name" ) %|| % " hex_color"
193193 print(tab , ... )
194194}
195+
195196# ' @export
196197plot.bayesplot_scheme <- function (x , ... ) {
197198 scheme <- attr(x , " scheme_name" ) %|| % stop(" Scheme name not found." )
@@ -339,8 +340,9 @@ prepare_custom_colors <- function(scheme) {
339340 not_found <- character (0 )
340341 for (j in seq_along(scheme )) {
341342 clr <- scheme [j ]
342- if (! is_hex_color(clr ) && ! clr %in% grDevices :: colors())
343+ if (! is_hex_color(clr ) && ! clr %in% grDevices :: colors()) {
343344 not_found <- c(not_found , clr )
345+ }
344346 }
345347 if (length(not_found )) {
346348 stop(
0 commit comments