plotly / plotly/plotly.R

`ggplotly()` function does not respect line width and does not show legend lines of `geom_linearange()`

未关闭
#2,133 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 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:
2022-05-05 15_21_27-RStudio_ Notebook 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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先使用 ggplotly() 运行 issue 中可复现的 R 示例,并将其与 ggplot 输出进行比较。跟踪 geom_linerange() 的转换过程,以及其 size 和 resource 颜色映射如何传递到交互式图表中。完成的标准是转换后的绘图遵循所请求的线宽,并且图例为每个资源显示具有代表性的线条。

由索引模型根据 Issue 内容生成。

评估

技术栈
r
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。