@@ -425,21 +425,26 @@ diagnostic_points <- function(size = NULL) {
425425# Functions wrapping around scale_color_manual() and scale_fill_manual(), used to
426426# color the intervals by rhat value
427427scale_color_diagnostic <- function (diagnostic = c(" rhat" , " neff" )) {
428- d <- match.arg(diagnostic )
428+ d <- match.arg(diagnostic , choices = c( " rhat " , " neff " , " neff_ratio " ) )
429429 diagnostic_color_scale(d , aesthetic = " color" )
430430}
431431
432432scale_fill_diagnostic <- function (diagnostic = c(" rhat" , " neff" )) {
433- d <- match.arg(diagnostic )
433+ d <- match.arg(diagnostic , choices = c( " rhat " , " neff " , " neff_ratio " ) )
434434 diagnostic_color_scale(d , aesthetic = " fill" )
435435}
436436
437- diagnostic_color_scale <- function (diagnostic = c(" rhat" , " neff_ratio" ),
438- aesthetic = c(" color" , " fill" )) {
437+ normalize_diagnostic_name <- function (diagnostic ) {
439438 diagnostic <- match.arg(diagnostic , choices = c(" rhat" , " neff" , " neff_ratio" ))
440439 if (diagnostic == " neff" ) {
441440 diagnostic <- " neff_ratio"
442441 }
442+ diagnostic
443+ }
444+
445+ diagnostic_color_scale <- function (diagnostic = c(" rhat" , " neff_ratio" ),
446+ aesthetic = c(" color" , " fill" )) {
447+ diagnostic <- normalize_diagnostic_name(diagnostic )
443448 aesthetic <- match.arg(aesthetic )
444449 dc <- diagnostic_colors(diagnostic , aesthetic )
445450 do.call(
@@ -455,10 +460,7 @@ diagnostic_color_scale <- function(diagnostic = c("rhat", "neff_ratio"),
455460
456461diagnostic_colors <- function (diagnostic = c(" rhat" , " neff_ratio" ),
457462 aesthetic = c(" color" , " fill" )) {
458- diagnostic <- match.arg(diagnostic , choices = c(" rhat" , " neff" , " neff_ratio" ))
459- if (diagnostic == " neff" ) {
460- diagnostic <- " neff_ratio"
461- }
463+ diagnostic <- normalize_diagnostic_name(diagnostic )
462464 aesthetic <- match.arg(aesthetic )
463465 color_levels <- c(" light" , " mid" , " dark" )
464466 if (diagnostic == " neff_ratio" ) {
0 commit comments