Learn R Programming

simplevis (version 4.0.0)

plotly_col_legend: Change colour legend elements order.

Description

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

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataLab