如果我有一个像这个散点图这样的Plot.ly图:
suppressPackageStartupMessages(library("plotly"))
plot_ly(data = iris, x = Sepal.Length, y = Petal.Length, mode = "markers",
color = Species)

如何显示每个类别的点数?例如,我希望这个传说看起来像这样:
其中的数字是所显示的点数总数。是否有一种方法可以用Plot.ly来实现这一点,这样所显示的值将反映在图上显示的点数吗?是否还有其他使用Plot.ly实现此操作的方法?
发布于 2016-09-20 07:42:05
n <- count(iris, Species) %>% mutate(new = paste(Species, '-', n))
levels(iris$Species) <- n$new
plotly::plot_ly(data = iris, x = Sepal.Length, y = Petal.Length, mode = "markers",
color = Species)https://stackoverflow.com/questions/39584002
复制相似问题