Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ Suggests:
rmarkdown,
testthat,
crosstalk,
knitr,
spelling,
emmeans,
vdiffr
ggridges
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
SystemRequirements: openssl
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export(ggally_cross)
export(ggally_crosstable)
export(ggally_density)
export(ggally_densityDiag)
export(ggally_density_ridges)
export(ggally_denstrip)
export(ggally_diagAxis)
export(ggally_dot)
Expand Down
28 changes: 28 additions & 0 deletions R/gg-plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,34 @@ ggally_naDiag <- function(...) {
ggally_na(...)
}

#' Create a ridgeline plot.
#'
#' `ggally_density_ridges` generates a ridgeline plot with partially overlapping line plots that create the impression of a mountain range. They can be quite useful for visualizing changes in distributions over time or space.
#'
#' @param data The data set used.
#' @param mapping The aesthetics used.
#' @param ... Other parameters passed on to \code{\link[ggridges]{geom_density_ridges2}}.
#'
#' @examples
#' data(iris)
#' ggpairs(iris, lower = list("combo" = ggally_density_ridges))
#' ggpairs(iris, lower = list("combo" = ggally_density_ridges, mapping = ggplot2::aes(color = Species)))
#' ggpairs(iris, lower = list("combo" = wrap(ggally_density_ridges, rel_min_height = 0.01), mapping = ggplot2::aes(color = Species)))
#'
#' @author Jens Preussner \email{jens.preussner@@mpi-bn.mpg.de}
#' @export
ggally_density_ridges <- function(data, mapping, ..., scale = 1) {
require_namespaces("ggridges")
horizontal <- GGally:::is_horizontal(data, mapping)

if (!horizontal) {
mapping <- GGally:::mapping_swap_x_y(mapping)
}

mapping <- GGally:::mapping_color_to_fill(mapping)

ggplot2::ggplot(data) +
ggridges::geom_density_ridges2(mapping, ..., scale = scale)


#' Scatterplot for continuous and categorical variables
Expand Down
28 changes: 28 additions & 0 deletions man/ggally_density_ridges.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-zzz_ggpairs.R
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ test_that("subtypes", {
)
comSubs <- list(
"autopoint",
"box", "dot", "box_no_facet", "dot_no_facet",
"box", "dot", "box_no_facet", "dot_no_facet", "density_ridges",
wrap("facethist", binwidth = 1),
"facetdensity",
"facetdensitystrip",
Expand Down
Loading