plotly / plotly/plotly.R

Only a single geom_pointrange() layer showing when using ggplotly()

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

还没有人认领这个 Issue。

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

描述

I am trying to use ggploty to show a ggplot with two pointrange layers. This works in ggplot but not when I use ggplotly. I am not sure if this is possible to do?

# Create some dummy data
``` r
dat<-dplyr::tibble("kvotealtternativ"=c(15,30,45),
                "prognose"=c(68.9,60.6,52.4), 
                "lower50" =c(62,54,45),
                "lower75"=c(56.7,48.8,40.9),
                "upper50"=c(76,66,58), 
                "upper75"=c(82.2,73.5,64.9))
# Create the ggplot with two layers - 75% CI and 50% CI

p=dat |>
ggplot2::ggplot()+
  ggplot2::geom_pointrange(mapping=ggplot2::aes(x=kvotealtternativ, y=prognose, ymin=upper75, ymax=lower75), fatten=1, size=3, color="darkred")+
  ggplot2::geom_pointrange(mapping=ggplot2::aes(x=kvotealtternativ, y=prognose, ymin=upper50, ymax=lower50), fatten=1, size=3, color="darkorange")+
  ggplot2::geom_point(ggplot2::aes(kvotealtternativ,prognose), colour="black", size=6)+
  ggplot2::labs(x="Uttak", y="Prognose")+
  ggplot2::geom_hline(yintercept=65, linetype=2)+
  ggplot2::theme_classic()+
  ggplot2::theme(axis.text.x = ggplot2::element_text(color = "grey20", size = 15, face = "plain"),
        axis.text.y = ggplot2::element_text(color = "grey20", size = 15, face = "plain"),  
        axis.title.x = ggplot2::element_text(color = "grey20", size = 20, face = "plain"),
        axis.title.y = ggplot2::element_text(color = "grey20", size = 20, face = "plain"))
# This is the desired plot
p

# But when I use ggplotly the 75% layer is not displayed 
plotly::ggplotly(p, tooltip="none") 

Created on 2023-10-19 with reprex v2.0.2

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先运行所提供的 R reprex,并将 ggplot2 的输出与 plotly::ggplotly(p) 进行比较,重点关注两个 geom_pointrange() 图层。跟踪 ggplotly 的入口点,并确定 75% 图层缺失的原因;当两个 pointrange 图层都能在转换后的图中渲染,同时现有的图元素保持完整时,即视为完成。

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

评估

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

把新 issue 发到你的邮箱

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