我的plotly图中,鼠标悬停框外显示的悬停名称因名称过长而被截断。我已经找到了解决方案plotly.js和plotly.py,但没有R语言的解决方案。我已经能够将该名称从悬停中移除或将其与值一起移入框内,但需要一种解决方案,使其保持在原位同时允许完整名称可见,不要写解释,保留html标签。
# sample data
Value <- rnorm(100, mean = 5)
Time <- c(1:100)
Site <- "Really long name for Site 1"
datTemp <- data.frame(Time, Value, Site)
Value <- rnorm(100, mean = 5)
Time <- c(1:100)
Site <- "Really long name for Site 2"
datTemp2 <- data.frame(Time, Value, Site)
Value <- rnorm(100, mean = 5)
Time <- c(1:100)
Site <- "Really long name for Site 3"
datTemp3 <- data.frame(Time, Value, Site)
figTemp<-datTemp%>%
plot_ly(x = ~Time, y = ~Value, type = "scatter", mode = "lines", line = list(width = 0.75), name = ~Site[1])%>%
layout(xaxis = list(title = "Date"), yaxis = list(title = "Temperature (C)"), legend = list(x = 0, y = 1.05, orientation = "h"))
figTemp<-figTemp%>%
add_trace(data = datTemp2, y = ~Value, type = "scatter", mode = "lines", name = ~Site[1])%>%
add_trace(data = datTemp3, y = ~Value, type = "scatter", mode = "lines", name = ~Site[1])