在 Plotly 中的点悬停上显示图像图像、Plotly

2023-09-06 07:04:32 作者:小女人,惹人爱

Plotly 允许您在将鼠标悬停在散点图上的某个点上时显示文本字段.当用户悬停或点击它时,是否可以显示与每个点相关联的图像?我主要只是使用网络界面,但我可以从 R 推送我的 ggplot.

Plotly allows you to display text fields when hovering over a point on a scatterplot. Is it possible to instead display an image associated with each point when the user hovers over or clicks on it? I am mostly just using the web interface, but I could instead push my ggplot from R.

推荐答案

不幸的是,目前没有简单的方法可以在悬停时在绘图图表上显示图像.

Unfortunately, there is no easy way to display images on hover on plotly graphs at the moment.

如果你愿意学习一些 javascript,plotly 的 embed API 允许你自定义悬停(以及点击)交互性.

If you are willing to learn some javascript, plotly's embed API allows you to customize hover (as well as click) interactivity.

这是一个在顶部显示图像的自定义悬停交互的示例的情节图.可以在 这里找到 JavaScript 源代码.

Here is an example of a custom hover interaction showing images on top of a plotly graph. The javascript source code can be found here.