plotly / plotly/plotly.R

ggplotly can omit geom_lines when they are colour coded within groups

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

还没有人认领这个 Issue。

bug ggplotly
主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

Create a ggplot graph in which geom_line objects connect data points within a grouping variable and when colour is also mapped to a variable. i.e. the output is a grid of dots in which dots at the same height are connected by horizontal lines:

ggplot_output

When passed to the ggplotly function, however, the lines are often omitted. In the reproducible example below, all the lines are omitted, but in other examples, sometimes just individual lines fail to plot. In this example, lines, but not points, do appear in the legend:

ggplotly_output

To isolate the problem, in the example below, if the colour = time parameter is dropped from the aes() function, then the lines (in monochrome) do get displayed.

library(ggplot2)
library(dplyr)
library(plotly)

# a dataframe with multiple values per case:
d = data.frame(case = as.factor(rep(1:5, each = 4)),
               time = as.factor(rep(1:4, times = 5)))

p = d %>% 
  ggplot(aes(x = time, y = case, colour = time)) +
  # produce lines to link points within a case: 
  geom_line(aes(group = case)) + 
  geom_point()

print(p) # standard ggplot output includes both lines and points
 
ggplotly(p) # but plotly output omits lines when colour is specified

贡献指南

打开贡献指南

从这里开始

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

调研方向

从使用 ggplotly()、geom_line()、geom_point() 并将 colour 映射到 time 的可复现 R 示例开始;将其输出与单色线条变体进行比较。追踪 ggplotly 如何转换分组的 geom_line 图层,然后验证在映射 colour 时所有分组线条都会出现,并且点和图例仍然正确。

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

评估

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

把新 issue 发到你的邮箱

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