I must be having trouble with less than a one liner, but have a look at the snippet below: I cannot the legend option to enter the text that I want in the legend as the name of the species (say, "foo1", "foo2", "foo3"). Notice that I do not want to change the original (iris in this case) dataset.
Any suggestion?
library(tidyverse)
library(plotly)
plot_ly(iris, x = ~Sepal.Length,
y = ~Sepal.Width,
type = 'scatter', color = ~Species,
symbol = ~Species,
mode = 'markers') %>%
layout(legend=list(title=list(text='My title')))