Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Controlling Animation for Points When There Are Missing Values (ggplotly)

未關閉
#2,166 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
25/100
Issue 類型
缺陷
描述清晰度
需要釐清
活躍度
停滯
技術堆疊
r

研究方向

首先執行提供的 R 重現,分別使用 plot_ly() 和 ggplotly(),並包含 animation_opts() 和 animation_slider()。在存在缺少資料列的情況下,比較 Jan 2021 和 Feb 2021 之間的點識別和懸停標籤。完成的標準是解釋清楚該行為,並找出一種有文件記錄的保留 Clinic 識別的方法,或找出一個範圍明確的修正方案。

由索引模型根據 Issue 內容生成。

描述

I am building a Hans Rosling type visualisation, however, I am having issues with the point movements. I have attached some code that creates an example of my problem, which can be found below.

The best way I can describe it is that whenever there is a missing value, a point has to disappear, therefore a different becomes assigned to a point even if it's in a different group. This logically doesn't make any sense to me.

In the example below, I've removed the Month Year of Feb 2021 from Clinic A, (i.e. I've removed the whole row), which means that the point disappears as shown in the play animation movement. However, if you notice instead of the Clinic A point simply disappearing, it chooses to keep the Clinic A point, turn into a different Clinic, in this case Clinic B and also convert the surrounding points to different clinics as well. I think it's working off the logic of turn into whatever point is the nearest somehow.

To really understand what is happening observe the hover of the points from Jan 2021 to Feb 2021

My question(s) is/are:

  • Why is this happening?
  • How do I specify some sort of group or ID to the points so that they aren't randomly turning into other Clinics?

In my real world scenario I have over 90+ different unique IDs/Clinics so ideally someone would be able to press play and then follow a single point moving across the viz, specifically noticing for any abnormalities in movement. It's extremely difficult to do this, or rather almost impossible, if a given point is converting itself into another point on the fly.

Note: I have confirmed this problem is replicated when using both plot_ly() and ggplotly() and only seems to happen when there is missing data

Code to Replicate Problem:

set.seed(24)


test <- data.frame(Month_Year = rep(paste(month.abb, rep(2021:2022, each = 12), sep = "_"), 4),
           x = abs(rnorm(24*4)),
           y = abs(rgamma(24&4,2,1)),
           Clinic = rep(c("Clinic A", "Clinic B", "Clinic C", "Clinic D"), each = 24))

test$Month_Year <- factor(test$Month_Year, levels = paste(month.abb, rep(2021:2022, each = 12), sep = "_"))


test <- test[-c(2,8,12),]


pt <- test %>% 
  ggplot(aes(x = x, y = y, frame = paste0(sprintf("%02d", as.numeric(Month_Year)), Month_Year), text = 
               paste(
                 "RAR:", round(y, 3),
                 "\nMR:", round(x, 3),
                 "\nClinic:", Clinic
               ))) +
  geom_point(shape = 1, color = "firebrick", aes(group = Clinic)) +
  # geom_text(aes(y = NAG + 5)) +
  theme_minimal() +
  labs(x = "Rolled Mortality Rate - 3 Month Average", y = "Rolled Admission Rate - 3 Month Average") +
  scale_x_continuous(limits = c(0, 6))



ggplotly(pt, tooltip = "text") %>% 
  animation_opts(
    3000,
    redraw = T
  ) %>% 
  animation_slider(
    currentvalue = list(prefix = "Month Year: ")
  )
主要語言
R
星號
2.7k
分支
640
PR 合併指標
30 天內沒有已合併 PR

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

plotly/plotly.R 的其他 Issue

查看 plotly/plotly.R 的全部 Issue

相似的 Issue

更多 R Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。