如何在这里删除trace0? [英] How to remove trace0 here?

查看:52
本文介绍了如何在这里删除trace0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

信息trace0"总是显示在蓝线的悬停文本框旁边,我该如何删除它?为什么不在橙色线上?trace0 到底是什么意思?

The info "trace0" always shows beside the hover text box of the blue line, How can I remove it? Why not on the orange line? What the trace0 exactly mean?

library(plotly)

fig <- plot_ly() 
fig <- fig %>%
  add_trace(
    type = 'scatter',
    mode = 'lines+markers',
    x = c(1,2,3,4,5),
    y = c(2.02825,1.63728,6.83839,4.8485,4.73463),
    text = c("Text A", "Text B", "Text C", "Text D", "Text E"),
    hovertemplate = paste('<i>Price</i>: $%{y:.2f}',
                        '<br><b>X</b>: %{x}<br>',
                        '<b>%{text}</b>'),
    showlegend = FALSE
  ) 
fig <- fig %>%
  add_trace(
    type = 'scatter',
    mode = 'lines+markers',
    x = c(1,2,3,4,5),
    y = c(3.02825,2.63728,4.83839,3.8485,1.73463),
    hovertemplate = 'Price: %{y:$.2f}<extra></extra>',
    showlegend = FALSE
  )

fig

提前致谢!

推荐答案

添加:

hovertemplate = paste('<i>Price</i>: $%{y:.2f}',
                      '<br><b>X</b>: %{x}<br>',
                      '<b>%{text}</b><extra></extra>'),

这篇关于如何在这里删除trace0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆