Support "ggnewscale" through geom_NewGeomLine etc
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
There are many use cases where a user wants to split a colour (or any other attribute) scale into multiple components. For example, if two separate types of data are being presented and it doesn't make sense to compare colours between these datasets.
In the example below, I am visualising a time series with time/y coordinates using geom_line, and also known timepoints that have only time coordinates using geom_vline. Note that this renders correctly using ggplot, but results in a blank plot and many errors with ggplotly:
require('dplyr')
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
require('tidyr')
#> Loading required package: tidyr
require('tibble')
#> Loading required package: tibble
require('ggplot2')
#> Loading required package: ggplot2
require('ggnewscale')
#> Loading required package: ggnewscale
require('plotly')
#> Loading required package: plotly
#>
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#>
#> last_plot
#> The following object is masked from 'package:stats':
#>
#> filter
#> The following object is masked from 'package:graphics':
#>
#> layout
series = rnorm(50*5) %>%
matrix(ncol=5) %>%
as_tibble() %>%
rownames_to_column() %>%
pivot_longer(cols=!rowname)
#> Warning: The `x` argument of `as_tibble.matrix()` must have unique column names if `.name_repair` is omitted as of tibble 2.0.0.
#> Using compatibility `.name_repair`.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.
changepoints = cbind(
x=sample(x=1:50, size=8, replace=T),
name=sample(x=c('a', 'b'), size=8, replace=T)
) %>%
as_tibble()
plt = ggplot() +
geom_line(data=series, aes(x=rowname, y=value, color=name, group=name)) +
new_scale_color() +
geom_vline(data=changepoints, aes(xintercept=x, color=name), size=1.5)
print(plt)

print(ggplotly(plt))
#> Warning in geom2trace.default(dots[[1L]][[5L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_NewGeomLine() has yet to be implemented in plotly.
#> If you'd like to see this geom implemented,
#> Please open an issue with your example code at
#> https://github.com/ropensci/plotly/issues
#> Warning in geom2trace.default(dots[[1L]][[5L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_NewGeomLine() has yet to be implemented in plotly.
#> If you'd like to see this geom implemented,
#> Please open an issue with your example code at
#> https://github.com/ropensci/plotly/issues
#> Warning in geom2trace.default(dots[[1L]][[5L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_NewGeomLine() has yet to be implemented in plotly.
#> If you'd like to see this geom implemented,
#> Please open an issue with your example code at
#> https://github.com/ropensci/plotly/issues
#> Warning in geom2trace.default(dots[[1L]][[5L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_NewGeomLine() has yet to be implemented in plotly.
#> If you'd like to see this geom implemented,
#> Please open an issue with your example code at
#> https://github.com/ropensci/plotly/issues
#> Warning in geom2trace.default(dots[[1L]][[5L]], dots[[2L]][[1L]], dots[[3L]][[1L]]): geom_NewGeomLine() has yet to be implemented in plotly.
#> If you'd like to see this geom implemented,
#> Please open an issue with your example code at
#> https://github.com/ropensci/plotly/issues
Created on 2021-02-12 by the reprex package (v1.0.0)
Ideally the entire package ggnewscale would be supported in ggplotly. Internally it seems to use functions such as geom_NewGeomLine, and these are the functions that plotly would need to implement to get this to work.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo l’esempio ggplotly fornito e tracciando gli avvisi da geom2trace.default per geom_NewGeomLine. Esamina come ggplotly gestisce questi geoms generati, quindi determina il supporto richiesto per l’esempio ggnewscale e verifica che venga renderizzato senza gli avvisi segnalati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- r
- Ambito
- data-visualization
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100