簡體   English   中英

ggplotly 從 ggplot 中刪除觀察結果

[英]ggplotly removing observations from ggplot

我正在嘗試創建一個圖表,顯示某個部門的論文收到的引用次數。 我希望它是一個交互式繪圖,以便在懸停特定條目時顯示更多信息。

很少引用的論文在 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 看起來像這樣:

在此處輸入圖片說明

情節版本如下所示:

在此處輸入圖片說明

有什么建議?

為什么不使用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

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM