Add scale_fill_selection()
or scale_color_selection
to a ggplot
to customize the scale for fill or color, respectively, for linked brushing.
Use selection_factor
to turn logical vectors representing selection,
to a factor with the levels ordered for use with ggplot2 bar stacking.
scale_fill_selection(color_false, color_true) scale_color_selection(color_false, color_true) selection_factor( x, na.replace = c(FALSE, NA, TRUE), reverse = packageVersion("ggplot2") < "2.2.0" )
color_false | The color that should be mapped to unselected rows |
---|---|
color_true | The color that should be mapped to selected rows |
x | Either a data frame with a |
na.replace | The value to use to replace |
reverse | Whether the factor level order should be |
if (FALSE) { sd <- SharedData$new(iris) renderPlot({ df <- sd$data(withSelection = TRUE, withFilter = TRUE) ggplot(df, aes(Sepal.Length, Sepal.Width, color = selection_factor(df))) + geom_point() + scale_color_selection("#444444", "skyblue1") }) }