Unequal facet heights
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- R
- Estrellas
- 2.7k
- Forks
- 641
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
In the reprex below, the first and last panels are noticeably taller than the others (note the y axis ticks are overlapping for the remaining panels).
library(plotly)
#> Loading required package: ggplot2
#>
#> 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
library(plyr)
#>
#> Attaching package: 'plyr'
#> The following objects are masked from 'package:plotly':
#>
#> arrange, mutate, rename, summarise
date <- rep(as.Date(1:365,origin='2011-1-1'),7)
location <- factor(rep(1:7,365))
product <- rep(letters[1:7], each=365)
value <- c(sample(1:10, size=365, replace=T),
sample(1:3, size=365, replace=T),
sample(10:100, size=365, replace=T),
sample(1:50, size=365, replace=T),
sample(1:20, size=365, replace=T),
sample(50:100, size=365, replace=T),
sample(1:100, size=365, replace=T))
dat<-data.frame(date,location,product,value)
p <- ggplot(dat, aes(x=date, y=value, color=location, group=location)) +
geom_line()+
theme(panel.spacing.y = ggplot2::unit(1, "lines")) +
facet_grid(product ~ ., scales = "fixed")
ggplotly(p)

(Also, the legend compresses the first few panels awkwardly, but that is a separate issue).
The problem also occurs with facet_wrap():
library(plotly)
#> Loading required package: ggplot2
#>
#> 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
library(plyr)
#>
#> Attaching package: 'plyr'
#> The following objects are masked from 'package:plotly':
#>
#> arrange, mutate, rename, summarise
date <- rep(as.Date(1:365,origin='2011-1-1'),7)
location <- factor(rep(1:7,365))
product <- rep(letters[1:7], each=365)
value <- c(sample(1:10, size=365, replace=T),
sample(1:3, size=365, replace=T),
sample(10:100, size=365, replace=T),
sample(1:50, size=365, replace=T),
sample(1:20, size=365, replace=T),
sample(50:100, size=365, replace=T),
sample(1:100, size=365, replace=T))
dat<-data.frame(date,location,product,value)
p <- ggplot(dat, aes(x=date, y=value, color=location, group=location)) +
geom_line()+
theme(panel.spacing.y = ggplot2::unit(1, "lines")) +
facet_wrap(ncol = 1, vars(product), scales = "fixed")
ggplotly(p)

This issue doesn't appear to be coming from ggplot, but rather from ggplotly:
library(plotly)
#> Loading required package: ggplot2
#>
#> 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
library(plyr)
#>
#> Attaching package: 'plyr'
#> The following objects are masked from 'package:plotly':
#>
#> arrange, mutate, rename, summarise
date <- rep(as.Date(1:365,origin='2011-1-1'),7)
location <- factor(rep(1:7,365))
product <- rep(letters[1:7], each=365)
value <- c(sample(1:10, size=365, replace=T),
sample(1:3, size=365, replace=T),
sample(10:100, size=365, replace=T),
sample(1:50, size=365, replace=T),
sample(1:20, size=365, replace=T),
sample(50:100, size=365, replace=T),
sample(1:100, size=365, replace=T))
dat<-data.frame(date,location,product,value)
p <- ggplot(dat, aes(x=date, y=value, color=location, group=location)) +
geom_line()+
theme(panel.spacing.y = ggplot2::unit(1, "lines")) +
facet_grid(product ~., scales = "fixed")
print(p)

Created on 2022-01-12 by the reprex package (v2.0.1)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza ejecutando el reprex de R proporcionado con ggplotly() y, después, compara las salidas de facet_grid() y facet_wrap() con el resultado de ggplot con el tamaño correcto. Rastrea la conversión del diseño de facets de ggplotly e identifica dónde las alturas de los paneles o el espaciado pasan a ser desiguales. Se considera terminado cuando ambos ejemplos renderizan paneles de igual altura sin que se superpongan las marcas del eje y.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- plotly, r
- Área
- data-visualization
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100