Cannot change colour legend position for continuous variable
未关闭
还没有人认领这个 Issue。
- 主要语言
- R
- 星标
- 2.7k
- 派生
- 641
- PR 合并指标
- 30 天内没有已合并 PR
描述
Locked question #1049 relates to the same issue, which still persists. Changing legend position is fiddly but works ok for factor variable:
require(ggplot2)
require(ggmap)
require(plotly)
m = c(left=60.5, bottom =29.3, right = 75.2, top = 38.5) |>
ggmap::get_stamenmap(maptype = 'toner', zoom = 6)
d = data.frame(x = rnorm(mean = 65, sd = 3, 50),
y = rnorm(mean = 34, sd = 2, 50))
p1 = ggmap(m) +
geom_point(data=d, aes(x, y, col = factor(round(x))), size=3) +
labs(col = 'Eastness', x = NULL, y = NULL) +
theme_void()
ggplotly(p1) |> layout(legend = list(xanchor = "left", x = 0, yanchor = "bottom", y = 0.2))
But for a continuous variable this fails:
p2 = ggmap(m) +
geom_point(data=d, aes(x, y, col = x), size=3) +
labs(col = 'Eastness', x = NULL, y = NULL) +
theme_void()
ggplotly(p2) |> layout(legend = list(xanchor = "left", x = 0, yanchor = "bottom", y = 0.2))
This seems to me this is a pretty basic and important thing to get right. I wonder if there's any chance to fix?
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行 issue 中针对 p1 和 p2 的可复现 R 示例,比较 layout 调用后 factor 颜色图例和连续颜色图例。跟踪 ggplotly 如何转换每个图例,以及如何应用 layout 的定位。完成的标准是连续颜色图例移动到请求的位置,同时不破坏 factor 情况。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- r
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100