Unequal facet heights
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- R
- Star
- 2.7k
- Fork
- 641
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy R reprex được cung cấp với ggplotly(), sau đó so sánh đầu ra của facet_grid() và facet_wrap() với kết quả ggplot có kích thước chính xác. Theo dõi quá trình chuyển đổi bố cục facet của ggplotly và xác định vị trí chiều cao hoặc khoảng cách giữa các panel trở nên không đồng đều. Được xem là hoàn tất khi cả hai ví dụ đều render các panel có chiều cao bằng nhau mà không chồng lấp các dấu tick của trục y.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- plotly, r
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100