信息“trace0”始终显示在蓝线的悬停文本框旁边,如何将其删除?为什么不在橙色线上?trace0 究竟是什么意思?
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
Run Code Online (Sandbox Code Playgroud)
提前致谢!
添加<extra></extra>:
hovertemplate = paste('<i>Price</i>: $%{y:.2f}',
'<br><b>X</b>: %{x}<br>',
'<b>%{text}</b><extra></extra>'),
Run Code Online (Sandbox Code Playgroud)