I am plotting a plotly bubble chart on a webpage.. I want to get the list of default colors, plotly uses to draw the bubbles.
You can also use something like this to retrieve the colours used in your plot:
return.plot_ly.ColorsUsed <- function( plotlyObject ) {
explorePlot = plotly_json(plotlyObject)
explorePlot = jsonlite::fromJSON(explorePlot$x$data)
# Extract colors, names and fillcolors
colors = explorePlot$data$marker$color
names = explorePlot$data$name
fillcolors = explorePlot$data$marker$fillcolor
# Returns a list with the names, colors and fillcolors used in the plot
toReturn = list( "names" = names,
"colors" = colors,
"fillcolors" = fillcolors )
return(toReturn)
} # End FUnction return.plot_ly.ColorsUsed