如何解决将鼠标悬停在ggplot上时弹出窗口的位置
我一直在研究app,并从here的灵感中汲取了关于如何使弹出窗口显示在悬停点旁边的信息。在我的笔记本电脑(15英寸)上,它运行得很好,但是,当我使用个人笔记本电脑(13英寸)时,弹出窗口出现在陌生的位置。
我想这与笔记本电脑的常规显示设置有关,因为我的较小型笔记本电脑使用的缩放比例为150%(建议使用此选项)。
但是,我不知道如何适应该脚本,以使其能够在所有屏幕上正常工作。
我的完整代码是here,我想需要对其进行修改以使其适用于所有屏幕缩放的这段代码是:
# calculate point position INSIDE the image as percent of total dimensions
# from left (horizontal) and from top (vertical)
left_pct <- (hover$x - hover$domain$left) / (hover$domain$right - hover$domain$left)
top_pct <- (hover$domain$top - hover$y) / (hover$domain$top - hover$domain$bottom)
# calculate distance from left and bottom side of the picture in pixels
left_px <- hover$range$left + left_pct * (hover$range$right - hover$range$left)
top_px <- hover$range$top + top_pct * (hover$range$bottom - hover$range$top)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。