`ggplotly()` function does not respect line width and does not show legend lines of `geom_linearange()`
未關閉
還沒有人認領這個 Issue。
- 主要語言
- R
- 星號
- 2.7k
- 分支
- 641
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Trying to apply ggplotly() to the following ggplot + geom_linerange() resulted in a faulted graph: the line width is not respected (or considered) and the legend does not show the lines for each key (what line of what color corresponds to each entry?)
``` r
library(tidyverse)
library(plotly)
df = tibble(
task = c("Job A", "Job B", "Job C", "Job A"),
start = c(0, 5, 10, 6),
end = c(4, 9, 15, 7),
resource=c ('Alex', 'Max', 'Max', 'Alex')
)
p <- ggplot(data = df,
aes(x = start,
y = task
)
) +
geom_linerange(aes(xmin = start,
xmax = end,
color = resource
),
size = 5.5,
alpha = 0.76
) +
labs(x = "Time (s)",
y = "Tasks",
color = "",
title = "Gantt plot (ggplot)")
print(p)
ggplot output:

but ggplotly:
ply <- ggplotly(p)
print(ply)
output:

Session info
sessionInfo()
#> R version 4.1.3 (2022-03-10)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 19043)
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] plotly_4.10.0 forcats_0.5.1 stringr_1.4.0 dplyr_1.0.9
#> [5] purrr_0.3.4 readr_2.1.2 tidyr_1.2.0 tibble_3.1.7
#> [9] ggplot2_3.3.6 tidyverse_1.3.1
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
首先使用 ggplotly() 執行 issue 中可重現的 R 範例,並將其與 ggplot 輸出進行比較。追蹤 geom_linerange() 如何轉換,以及其 size 和 resource 色彩對映如何傳遞到互動式圖表中。完成的標準是轉換後的繪圖遵循要求的線寬,且圖例為每個資源顯示具代表性的線條。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- r
- 領域
- data-visualization
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100