Skip to contents

Applies advanced custom styling to the legend of a Plotly figure. This function adds a box around each individual legend item and changes legend symbols to rectangles. The modifications are applied using JavaScript via htmlwidgets::onRender().

Usage

ro_ply_legend_theme(fig)

Arguments

fig

A Plotly figure object created by plotly::plot_ly() or similar.

Value

The Plotly figure object with the custom legend styling applied.

Examples

if (FALSE) { # \dontrun{
fig <- plotly::plot_ly(data = mtcars, x = ~mpg, y = ~hp,
  color = ~factor(cyl), type = 'scatter', mode = 'markers')
fig_styled <- ro_ply_legend_theme(fig)
fig_styled
} # }