[英]Create a plotly bar chart with different colors for each bar
如何创建一个条形图,每个条的颜色不同,并添加一个带有每个条的名称和使用的颜色的图例(不是颜色的名称,颜色本身)。
library(plotly)
fig <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(20, 14, 23),
name = "SF Zoo",
type = "bar"
)
fig
有一个color
参数
fig <- plot_ly(
x = c("giraffes", "orangutans", "monkeys"),
y = c(20, 14, 23),
name = c("giraffes", "orangutans", "monkeys"),
type = "bar", color = c('red', 'blue', 'green')
)
fig
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.