plotly / plotly/plotly.R

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

Offen
#2,307 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
R
Sterne
2.7k
Forks
641
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das bereitgestellte R-reprex auszuführen und die ggplot2-Ausgabe mit plotly::ggplotly(p) zu vergleichen, wobei du dich auf die beiden geom_pointrange()-Layer konzentrierst. Verfolge den Einstiegspunkt von ggplotly und ermittle, warum der 75%-Layer fehlt; als erledigt gilt die Aufgabe, wenn beide pointrange-Layer im konvertierten Plot gerendert werden und die vorhandenen Plotelemente intakt bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
r
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.