如何删除在 R 中使用 plot_ly 创建的饼图中的百分比标签

How to remove percentage labels in a pie chart created using plot_ly in R

library(plotly)
ds <- data.frame(labels = c("A", "B", "C"), values = c(10, 40, 60))
plot_ly(ds, labels = labels, values = values, type = "pie") %>%
layout(title = "Basic Pie Chart using Plotly")

我想删除饼图上显示的百分比标签。

基于 R chart attribute reference 您必须将 textinfo 属性 设置为 none

plot_ly(ds, labels = labels, values = values, type = "pie", textinfo = "none")

应该这样做:

library(plotly)
ds <- data.frame(labels = c("A", "B", "C"), values = c(10, 40, 60))
plot_ly(ds, labels = labels, values = values, type = "pie", textinfo= "text", text="") %>%
  layout(title = "Basic Pie Chart using Plotly")

如果要标注可以在text=""中填写信息。