r - 在添加的散点图平均线上添加 hoverinfo 文本
问题描述
我创建了一个基本的散点图,并添加了一条平均线。是否可以添加 hoverinfo 文本,例如:"Average : <Average Value>"
?另一种解决方案是将文本永久显示在行上,但我认为这可能更复杂。
pts<-c(10,20,30)
npts<-c(24,56,78)
ex<-data.frame(pts,npts)
library(plotly)
p <- plot_ly(data = ex, x = ~pts, y = ~npts,
marker = list(size = 10,
color = 'white',
line = list(color = 'rgba(152, 0, 0, .8)',
width = 2))) %>%
add_segments(x = 0, xend = max(ex$pts), y = mean(ex$npts), yend =mean(ex$pts) )%>%
add_trace(
text = ~paste("Team Pts: ", pts, '</br>Fantasy Pts:', npts),
hoverInfo='text'
)
p
解决方案
推荐阅读
- curses - Python curses 绘制 nvim 风格的 gui 光标竖条
- vb.net - Outlook 365 桌面加载项无法正常工作
- docker - Docker Flask,卡在“等待来自本地主机的响应”
- f# - F# 将浮点数列表组合为浮点数
- sql - 比较两列 varchar 类型
- swift - 如何阻止我的 UITableView 重用单元格?
- amazon-web-services - 每个 vpc 都需要一个 NAT 实例吗?
- excel - 从同一个子中的多个组合框中获取值
- typescript - 转换TaskEither
[] 到 TaskEither - c++ - 类不存在默认构造函数