Skip to content

Commit

Permalink
feat: Support grid::pattern() / gradient fills (#98)
Browse files Browse the repository at this point in the history
* feat: Support 'grid::pattern()' / gradient fills

* Bumps required {ggplot2} to v3.5.0 when `fill_alpha()` was introduced.
* Replace each `fill = alpha(fill, alpha)` with `fill = fill_alpha(fill, alpha)`.

closes #94

* docs(NEWS.md): Add entry for pattern fill feature
  • Loading branch information
trevorld authored Dec 11, 2024
1 parent a8a9982 commit 344e40f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ BugReports: https://github.com/wilkelab/ggridges/issues
Depends:
R (>= 3.2)
Imports:
ggplot2 (>= 3.4.0),
ggplot2 (>= 3.5.0),
grid (>= 3.0.0),
scales (>= 0.4.1),
withr (>= 2.1.1)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ ggridges 0.5.6.9000
----------------------------------------------------------------
- Add support for weighted density estimates in `stat_density_ridges()` by
allowing the use of the `weight` aesthetic (@joranE, #90)
- Add support for `grid::pattern()`, `grid::linearGradient()`, and `grid::radialGradient()` values for `fill` and `point_fill` aesthetics
by using [`ggplot2::fill_alpha()`](https://ggplot2.tidyverse.org/reference/fill_alpha.html) (@trevorld, #94)

ggridges 0.5.6
----------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions R/geoms-gradient.R
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ GeomRidgelineGradient <- ggproto("GeomRidgelineGradient", Geom,
data$point_colour %||% data$point_color %||% data$colour,
data$point_alpha %||% data$alpha
),
fill = alpha(
fill = ggplot2::fill_alpha(
data$point_fill %||% data$fill,
data$point_alpha %||% data$alpha
),
Expand Down Expand Up @@ -303,7 +303,7 @@ GeomRidgelineGradient <- ggproto("GeomRidgelineGradient", Geom,
data$point_colour %||% data$point_color %||% data$colour,
data$point_alpha %||% data$alpha
),
fill = alpha(
fill = ggplot2::fill_alpha(
data$point_fill %||% data$fill,
data$point_alpha %||% data$alpha
),
Expand Down
10 changes: 5 additions & 5 deletions R/geoms.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,
height = grid::unit(1, "npc") - grid::unit(lwd, "mm"),
gp = grid::gpar(
col = data$colour,
fill = alpha(data$fill, data$alpha),
fill = ggplot2::fill_alpha(data$fill, data$alpha),
lty = data$linetype,
lwd = lwd * .pt,
linejoin = "mitre"
Expand Down Expand Up @@ -191,7 +191,7 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,
data$point_colour %||% data$point_color %||% data$colour,
data$point_alpha %||% data$alpha
),
fill = alpha(
fill = ggplot2::fill_alpha(
data$point_fill %||% data$fill,
data$point_alpha %||% data$alpha
),
Expand Down Expand Up @@ -304,7 +304,7 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,
data$point_colour %||% data$point_color %||% data$colour,
data$point_alpha %||% data$alpha
),
fill = alpha(
fill = ggplot2::fill_alpha(
data$point_fill %||% data$fill,
data$point_alpha %||% data$alpha
),
Expand Down Expand Up @@ -355,7 +355,7 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,
munched_poly$x, munched_poly$y, id = munched_poly$id,
default.units = "native",
gp = grid::gpar(
fill = ggplot2::alpha(aes$fill, aes$alpha),
fill = ggplot2::fill_alpha(aes$fill, aes$alpha),
lty = 0)
)
)
Expand Down Expand Up @@ -591,7 +591,7 @@ GeomDensityRidges2 <- ggproto("GeomDensityRidges2", GeomDensityRidges,
munched_poly$x, munched_poly$y, id = munched_poly$id,
default.units = "native",
gp = grid::gpar(
fill = ggplot2::alpha(aes$fill, aes$alpha),
fill = ggplot2::fill_alpha(aes$fill, aes$alpha),
col = aes$colour,
lwd = aes$linewidth * .pt,
lty = aes$linetype)
Expand Down
2 changes: 1 addition & 1 deletion R/geomsv.R
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ GeomVRidgeline <- ggproto("GeomVRidgeline", Geom,
munched_poly$x, munched_poly$y, id = munched_poly$id,
default.units = "native",
gp = grid::gpar(
fill = ggplot2::alpha(aes$fill, aes$alpha),
fill = ggplot2::fill_alpha(aes$fill, aes$alpha),
lty = 0)
))
grid::grobTree(ag, lg)
Expand Down

0 comments on commit 344e40f

Please sign in to comment.