Plotly - Using custom images in place of standard legend

Viewed 34

I have a pie chart in plotly which I want to add images to the legend, rather than have the text indicating what each variable means. I post a reproducible example below. What I would like from this example, is to know of a way where the "Toyota Corolla" and "Volvo 142E" wording can be replaced with an image? Is there a way that this can be done. An example of an image would be the logo of the two respective manufacturers instead if the words.

library(plotly)
plot_ly(mtcars%>%rownames_to_column(var = "Manufacturer")%>%
filter(Manufacturer=="Toyota Corolla"|
Manufacturer=="Volvo 142E"),
labels = ~Manufacturer, values = ~mpg, type = 'pie')%>% layout(title = 'Car Manufacturer',
xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
0 Answers
Related