我正在尝试创建一个图表,显示一个部门的论文收到的引文数量。我希望它是一个交互式绘图,以便在悬停特定条目时显示更多信息。
引用很少的论文在ggplotly版本中被取消,但我希望它们仍然像ggplot中那样显示出来。
这是我使用的代码:
library(tidyverse)
library(plotly)
download.file("https://raw.githubusercontent.com/luizaandrade/dec-bibliometrics-dashboard/main/citations.rds",
"data.rds",
method = "curl")
data <- readRDS("data.rds")
graph <-
data %>%
ggplot() +
geom_segment(
aes(x = year_scholar,
xend = year_scholar,
y = start,
yend = end,
color = year_id,
text = paste0(title, "<br>",
all_authors, "<br>",
journal, "<br>",
"Citations: ", cites)),
size = 10,
lineend = "butt")
ggplotly(graph,
tooltip = "text")ggplot如下所示:

plotly版本看起来是这样的:

有什么建议吗?
发布于 2021-11-11 00:30:09
为什么不使用geom_col
graph <- ggplot(data) +
geom_col(
aes(x = year_scholar,
y = cites,
fill = year_id,
text = paste0(title, "<br>",
all_authors, "<br>",
journal, "<br>",
"Citations: ", cites)),
size = 10)
pl_graph <- ggplotly(graph,
tooltip = "text")
pl_graph

https://stackoverflow.com/questions/69804162
复制相似问题