Issue when specifying both the size and color mapping in a scatter plots
未关闭
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hi,
I can not manage to specify both the size and the color mapping with completely satisfactory results.
If I specify the size mapping globally:
library(plotly)
df <- data.frame(x = 1:12, y = 1:12, s = 1:12, g = rep(c("A", "B", "C"), 4))
plot_ly(data = df, x = ~x, y = ~y, size = ~s, color= ~g)%>%
add_markers()
I have a perfect plot but I suffer from the spurious line.width warning already mentioned in https://github.com/ropensci/plotly/issues/1367
If I specify the size mapping in the marker itself:
plot_ly(data = df, x = ~x, y = ~y, color= ~g)%>%
add_markers(marker = list(size = ~s))
The sizes are wrong: it seems there is an ordering by group within plotly which is not used in the markers.
Indeed, sorting the data.frame according to the colors fixes the issue:
df_sorted = df[order(df[['g']]), ]
plot_ly(data = df_sorted, x = ~x, y = ~y, color= ~g)%>%
add_markers(marker = list(size = ~s))
Let me know how I can help!
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从使用 plot_ly() 和 add_markers() 的两个未排序示例开始,然后将它们的标记大小行为与已排序 data.frame 示例进行比较。跟踪颜色分组和标记大小映射是如何对齐的,并验证未排序数据在没有报告的 line.width 警告的情况下保留预期大小。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100