Skip to content

Commit 9f1b39f

Browse files
authored
Merge branch 'main' into pimp_my_legend_keys
2 parents 1a2f97c + 6de07af commit 9f1b39f

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Suggests:
5252
ggplot2movies,
5353
hexbin,
5454
Hmisc,
55+
hms,
5556
knitr,
5657
mapproj,
5758
maps,

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)
1212
* `draw_key_polygon()` and `draw_key_timeseries()` now reflect the
1313
`outline.type` parameter (@teunbrand, #6649).
14+
* `stat_boxplot()` treats `width` as an optional aesthetic (@Yunuuuu, #6575)
1415

1516
# ggplot2 4.0.0
1617

R/geom-count.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ NULL
33

44
#' Count overlapping points
55
#'
6-
#' This is a variant [geom_point()] that counts the number of
6+
#' This is a variant of [geom_point()] that counts the number of
77
#' observations at each location, then maps the count to point area. It
88
#' useful when you have discrete data and overplotting.
99
#'

R/guides-.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ Guides <- ggproto(
659659
if (!stretch_spacing) {
660660
spacing <- convertWidth(spacing, "cm")
661661
}
662-
heights <- unit(height_cm(lapply(heights, sum)), "cm")
662+
663+
total_height <- max(inject(unit.c(!!!lapply(heights, sum))))
663664

664665
if (stretch_x || stretch_spacing) {
665666
widths <- redistribute_null_units(widths, spacing, margin, "width")
@@ -672,14 +673,14 @@ Guides <- ggproto(
672673
# Set global justification
673674
vp <- viewport(
674675
x = global_xjust, y = global_yjust, just = global_just,
675-
height = max(heights),
676+
height = total_height,
676677
width = vp_width
677678
)
678679

679680
# Initialise gtable as legends in a row
680681
guides <- gtable_row(
681682
name = "guides", grobs = grobs,
682-
widths = widths, height = max(heights),
683+
widths = widths, height = total_height,
683684
vp = vp
684685
)
685686

@@ -701,7 +702,7 @@ Guides <- ggproto(
701702
if (!stretch_spacing) {
702703
spacing <- convertWidth(spacing, "cm")
703704
}
704-
widths <- unit(width_cm(lapply(widths, sum)), "cm")
705+
total_width <- max(inject(unit.c(!!!lapply(widths, sum))))
705706

706707
if (stretch_y || stretch_spacing) {
707708
heights <- redistribute_null_units(heights, spacing, margin, "height")
@@ -715,13 +716,13 @@ Guides <- ggproto(
715716
vp <- viewport(
716717
x = global_xjust, y = global_yjust, just = global_just,
717718
height = vp_height,
718-
width = max(widths)
719+
width = total_width
719720
)
720721

721722
# Initialise gtable as legends in a column
722723
guides <- gtable_col(
723724
name = "guides", grobs = grobs,
724-
width = max(widths), heights = heights,
725+
width = total_width, heights = heights,
725726
vp = vp
726727
)
727728

R/stat-boxplot.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
StatBoxplot <- ggproto("StatBoxplot", Stat,
66
required_aes = c("y|x"),
77
non_missing_aes = "weight",
8+
optional_aes = "width",
89
# either the x or y aesthetic will get dropped during
910
# statistical transformation, depending on the orientation
1011
dropped_aes = c("x", "y", "weight"),
@@ -69,9 +70,11 @@ StatBoxplot <- ggproto("StatBoxplot", Stat,
6970
if (any(outliers)) {
7071
stats[c(1, 5)] <- range(c(stats[2:4], data$y[!outliers]), na.rm = TRUE)
7172
}
72-
73-
if (vec_unique_count(data$x) > 1)
73+
if (length(data$width) > 0L) {
74+
width <- data$width[1L]
75+
} else if (vec_unique_count(data$x) > 1) {
7476
width <- diff(range(data$x)) * 0.9
77+
}
7578

7679
df <- data_frame0(!!!as.list(stats))
7780
df$outliers <- list(data$y[outliers])

man/geom_count.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)