plotly / plotly/plotly.R

Mapping alpha to continuous variable in geom_tile()/geom_raster()

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

还没有人认领这个 Issue。

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

描述

I am trying to convert a heatmap I created with ggplot to a plotly object. Everything works fine, except no matter what I do, it won't translate the alpha values (I have tried both having it as aes- what I want- but also giving it a random value and it won't work. This is the ggplot code and output, which works fine:

I have tried both geom tile and geom raster and none of them seem to work.

 plot <- datos%>%
    ggplot(aes(Var2, Var1, fill = value,  alpha = dum,
text = paste("<b>Edad:</b>", Var2, "<br>",
                                                    "<b>Año:</b>", Var1, "<br>",
                                                    "<b> Año de nacimiento: </b>", (Var1 - Var2), "<br>",
                                                    "<b>Renta relativa:</b>", format(value, 
                                                                              big.mark = ".", 
                                                                              scientific = FALSE, 
                                                                              digits = 2))))+
  geom_raster()+
  scale_alpha(range = c(0.6, 1))+
  scale_x_continuous(breaks = seq(20, 75, by = 5), limits = c(20, 80))+
  scale_y_continuous(breaks = seq(2008, 2016, by = 2 ), limits = c(2008, 2016))+
  theme_minimal()

ggplot output (with a little more formatting:
image

ggplotly output (just doing ggplotly(plot)):
image

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先使用 ggplotly(plot) 重现所提供的示例,比较 geom_raster() 和 geom_tile(),以及映射的 alpha 值和固定的 alpha 值。跟踪 ggplotly 针对 alpha aesthetic 的转换路径,并将结果与原始 ggplot 输出进行核对。转换后的交互式热图能够保留连续 alpha 值即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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