How can I create a bar chart with each bar colored differently and also add a legend with the name of each bar and the color used (not the name of the color,the color itself).
library(plotly)
fig <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(20, 14, 23),
name = "SF Zoo",
type = "bar"
)
fig