首页 > 解决方案 > 悬停以在 ggplot2 中显示图像或图标(R markdown)

问题描述

我对动态或交互式 ggplot 图很着迷。ggiraph我在https://davidgohel.github.io/ggiraph/找到了一些简单的悬停选项这是 R 降价的 MWE:

---
title: "Hover"
author: "Author"
output: html_document
---
## Hover ggplot2
```{r, warning=FALSE, message=FALSE}
library(ggplot2)
library(ggiraph)
data <- mtcars
data$carname <- row.names(data)
gg_point = ggplot(data = data) +
    geom_point_interactive(aes(x = wt, y = qsec, color = disp,
    tooltip = carname, data_id = carname)) +
  theme_minimal()
girafe(ggobj = gg_point)
```

在此处输入图像描述

将鼠标悬停在降价中的 ggplot 中的数据点上时,是否有可能显示小图像或图标?我想知道如何以及在哪里存储这些图像。我想给每个数据点一个特定的图像。我正在研究著名的画家,即假设我在散点图中只有很少的数据点。因此,当人们将鼠标悬停在“呐喊”上时,他们应该会看到https://en.wikipedia.org/wiki/List_of_most_expensive_paintings#/media/File:The_Scream_Pastel.jpg的小版本

在此处输入图像描述

标签: rggplot2r-markdown

解决方案


推荐阅读