首页 > 解决方案 > Plotly R sankey plot - 在单个悬停标签上隐藏值

问题描述

我在 r (plot_ly) 中使用 plotly 创建了一个非常标准的 sankey 图。有没有办法在悬停标签中只显示一些值。我想显示所有链接,但由于数据机密性限制,隐藏其中少数的特定值。

谢谢

fig <- plot_ly(
  type = "sankey",
  domain = list(x =  c(0,1),y =  c(0,1)),
  arrangement = "freeform",
  orientation = "h",
  valueformat = ".1f",
  #valuesuffix = "TWh",key 
  
  node = list(
    label = lab,
    x=posx,
    y=posy,
    color = col,
    pad = 10,
    thickness = 15,
    line = list(color = "black",width = 0.5)
  ),
  
  link = list(
    source = sum$source,
    target = sum$target,
    value  = sum$value,
    label  = sum$label,
    color  = sum$color
  )
) 
fig <- fig %>% layout(
  #title = "", font = list(size = 10),
  xaxis = list(showgrid = F, zeroline = F),
  yaxis = list(showgrid = F, zeroline = F)
)

fig

标签: plothoverlabelplotly

解决方案


推荐阅读