Only a single geom_pointrange() layer showing when using ggplotly()
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied R reprex and comparing the ggplot2 output with plotly::ggplotly(p), focusing on the two geom_pointrange() layers. Trace the ggplotly entry point and determine why the 75% layer is absent; done means both pointrange layers render in the converted plot while the existing plot elements remain intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100