The easiest way to specify a legend title is to set it through ggplotand have it plotlyread from the corresponding object:
library( plotly )
gg <- ggplot( mtcars, aes( x=mpg, y=wt, color=factor(vs) ) ) +
geom_point() + labs( color = "MyTitle" )
ggplotly( gg )
However, the problem is that it plotlyconverts the legend title into an annotation, which becomes disconnected from the legend in this process. In my browser, it also overlaps with the menu plotlyin the upper right corner:

, ggplot :
gg <- ggplot( mtcars, aes( x=mpg, y=wt, color=factor(vs) ) ) +
geom_point() + theme( legend.title = element_blank() )
ggplotly( gg ) %>%
add_annotations( text="MyTitle", xref="paper", yref="paper",
x=1.02, xanchor="left",
y=0.8, yanchor="bottom",
legendtitle=TRUE, showarrow=FALSE ) %>%
layout( legend=list(y=0.8, yanchor="top" ) )
, y, , . , "" . :
