plotly / plotly/plotly.R

ggplotly unable to handle multiple legends properly in layered charts generated by ggplot2

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

还没有人认领这个 Issue。

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

描述

From the example in http://bxhorn.com/legends-ggplot/#managing-multiple-legends-in-a-layered-chart

# Multiple Legends
# load data
data(diamonds)
# calc quantiles with specified probabilities
new.prob <- c(0.90, 0.95, 0.99)
cut.probs <- plyr::ddply(diamonds, .(cut), numcolwise(quantile, probs = new.prob))[, c("cut", "price")]
cut.probs <- transform(cut.probs, quantile = c("P90", "P95", "P99"))
# layered graph
gg<-ggplot(diamonds, aes(cut, price)) + 
  geom_boxplot(aes(fill = factor(cut))) + 
  geom_point(data = cut.probs, aes(cut, price, color = factor(quantile)), size = 5) +
  scale_fill_discrete(name = "Quality of the Cut") +
  scale_color_discrete(name = "My Quantiles")
gg
plotly::ggplotly(gg)
  1. Multiple legend titles are clustered together
  2. Multiple legends are not separated
  3. There is extra text ",1" in legend labels

This is the ggplot2 output:
image

This is the ggplotly output:
newplot

贡献指南

打开贡献指南

从这里开始

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

调研方向

从提供的分层 ggplot2 示例和 ggplotly(gg) 入口开始,将其输出与 ggplot2 输出进行比较。跟踪两个 aesthetics 及其 scale 名称如何变成 legend。完成的标准是标题已分开、legend 彼此独立,并且不存在额外的 ",1" 文本。

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

评估

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

把新 issue 发到你的邮箱

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