Skip to contents

Change colour legend elements order.

Usage

plotly_col_legend(plotly, rev = FALSE, order = NULL)

Arguments

plotly

A plotly object. Required input.

rev

TRUE or FALSE of whether to reverse the order of elements.

order

A numeric vector specifying the order of elements.

Examples

library(dplyr)
plot_data <- dplyr::sample_frac(ggplot2::diamonds, 0.05) 

plot <- gg_point_col(data = plot_data, 
                     x_var = carat, 
                     y_var = price, 
                     col_var = color)

plotly::ggplotly(plot)
plotly::ggplotly(plot) %>% plotly_col_legend(rev = TRUE)
plotly::ggplotly(plot) %>% plotly_col_legend(order = c(2, 1, 3:7))