Skip to content

Commit

Permalink
Project-wide renaming. Things seem to be mostly working.
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Sep 13, 2017
1 parent cf76c42 commit 7267395
Show file tree
Hide file tree
Showing 35 changed files with 431 additions and 449 deletions.
14 changes: 7 additions & 7 deletions DESCRIPTION
@@ -1,13 +1,13 @@
Package: ggjoy
Package: ggridges
Type: Package
Title: Joyplots in 'ggplot2'
Version: 0.3.0.9000
Title: Ridgeline plots in 'ggplot2'
Version: 0.4.0
Authors@R: c(
person("Claus O.", "Wilke", , "wilke@austin.utexas.edu", c("cre", "aut")),
person("RStudio", role = c("cph"), comment = "Copyright for ggplot2 code copied to ggjoy"))
Description: Joyplots provide a convenient way of visualizing changes in distributions over
person("RStudio", role = c("cph"), comment = "Copyright for ggplot2 code copied to ggridges"))
Description: Ridgeline plots provide a convenient way of visualizing changes in distributions over
time or space. This package enables the creation of such plots in 'ggplot2'.
URL: https://github.com/clauswilke/ggjoy
URL: https://github.com/clauswilke/ggridges
Depends:
R (>= 3.2),
ggplot2 (>= 2.2.0),
Expand All @@ -30,7 +30,7 @@ Suggests:
VignetteBuilder: knitr
Collate:
'data.R'
'ggjoy.R'
'ggridges.R'
'geoms.R'
'geomsv.R'
'geoms-gradient.R'
Expand Down
18 changes: 9 additions & 9 deletions NAMESPACE
@@ -1,18 +1,18 @@
# Generated by roxygen2: do not edit by hand

export(GeomJoy)
export(GeomJoy2)
export(GeomJoyGradient)
export(GeomDensityRidges)
export(GeomDensityRidges2)
export(GeomDensityRidgesGradient)
export(GeomRidgeline)
export(GeomRidgelineGradient)
export(GeomVRidgeline)
export(ScaleCyclical)
export(StatBinline)
export(StatJoy)
export(StatDensityRidges)
export(cyclical_scale)
export(geom_joy)
export(geom_joy2)
export(geom_joy_gradient)
export(geom_density_ridges)
export(geom_density_ridges2)
export(geom_density_ridges_gradient)
export(geom_ridgeline)
export(geom_ridgeline_gradient)
export(geom_vridgeline)
Expand All @@ -23,8 +23,8 @@ export(scale_fill_cyclical)
export(scale_linetype_cyclical)
export(scale_size_cyclical)
export(stat_binline)
export(stat_joy)
export(theme_joy)
export(stat_density_ridges)
export(theme_ridges)
import(ggplot2)
importFrom(ggplot2,Geom)
importFrom(ggplot2,ScaleDiscrete)
Expand Down
26 changes: 5 additions & 21 deletions NEWS
@@ -1,22 +1,6 @@
ggjoy 0.3.0.9000
ggridges 0.4.0
----------------------------------------------------------------
- Added an option to center axis labels to `theme_joy()`.

ggjoy 0.3.0
----------------------------------------------------------------
- Added cyclical scales that make it easy to alternate between fill colors
and other aesthetics.

ggjoy 0.2.0
----------------------------------------------------------------
Numerous improvements:
- New stat `binline` that can be used to draw histogram joyplots.
- Various improvements in `stat_joy`. In particular, it now works properly
with multiple panels. It also now has parameters `from` and `to` to limit the
range of density estimation, just like `density()`.
- Improvements in the vignettes
- New geoms `geom_ridgeline_gradient` and `geom_joy_gradient` that can handle gradient fills.

ggjoy 0.1.0
----------------------------------------------------------------
First complete implementation ready for initial release
- Initial import of code base from ggjoy, and renaming:
geom_joy -> geom_density_ridges
stat_joy -> stat_density_ridges
theme_joy -> theme_ridges
20 changes: 10 additions & 10 deletions R/geoms-gradient.R
@@ -1,6 +1,6 @@
#' Plot ridgelines and joyplots with fill gradients along the x axis
#' Plot ridgelines and ridgeline plots with fill gradients along the x axis
#'
#' The geoms `geom_ridgeline_gradient` and `geom_joy_gradient` work just like [`geom_ridgeline`] and [`geom_joy`] except
#' The geoms `geom_ridgeline_gradient` and `geom_density_ridges_gradient` work just like [`geom_ridgeline`] and [`geom_density_ridges`] except
#' that the `fill` aesthetic can vary along the x axis. Because filling with color gradients is fraught with issues,
#' these geoms should be considered experimental. Don't use them unless you really need to. Note that due to limitations
#' in R's graphics system, transparency (`alpha`) has to be disabled for gradient fills.
Expand Down Expand Up @@ -187,7 +187,7 @@ GeomRidgelineGradient <- ggproto("GeomRidgelineGradient", Geom,
munched_poly <- ggplot2::coord_munch(coord, positions, panel_params)


# placing the actual grob generation into a separate function allows us to override for geom_joy2
# placing the actual grob generation into a separate function allows us to override for geom_density_ridges2
self$make_group_grob(munched_line, munched_poly, aes, gradient_lwd)
},

Expand Down Expand Up @@ -219,20 +219,20 @@ GeomRidgelineGradient <- ggproto("GeomRidgelineGradient", Geom,



#' @param panel_scaling Argument only to `geom_joy_gradient`. If `TRUE`, the default, relative scaling is calculated separately
#' @param panel_scaling Argument only to `geom_density_ridges_gradient`. If `TRUE`, the default, relative scaling is calculated separately
#' for each panel. If `FALSE`, relative scaling is calculated globally.
#'
#' @rdname geom_ridgeline_gradient
#' @importFrom ggplot2 layer
#' @export
geom_joy_gradient <- function(mapping = NULL, data = NULL, stat = "joy",
geom_density_ridges_gradient <- function(mapping = NULL, data = NULL, stat = "density_ridges",
panel_scaling = TRUE,
na.rm = TRUE, gradient_lwd = 0.5, show.legend = NA, inherit.aes = TRUE, ...) {
layer(
data = data,
mapping = mapping,
stat = stat,
geom = GeomJoyGradient,
geom = GeomDensityRidgesGradient,
position = "identity",
show.legend = show.legend,
inherit.aes = inherit.aes,
Expand All @@ -251,16 +251,16 @@ geom_joy_gradient <- function(mapping = NULL, data = NULL, stat = "joy",
#' @importFrom grid gTree gList
#' @examples
#'
#' # Example for `geom_joy_gradient()`
#' # Example for `geom_density_ridges_gradient()`
#' ggplot(lincoln_weather, aes(x = `Mean Temperature [F]`, y = `Month`, fill = ..x..)) +
#' geom_joy_gradient(scale = 3, rel_min_height = 0.01) +
#' geom_density_ridges_gradient(scale = 3, rel_min_height = 0.01) +
#' scale_x_continuous(expand = c(0.01, 0)) +
#' scale_y_discrete(expand = c(0.01, 0)) +
#' scale_fill_viridis(name = "Temp. [F]", option = "C") +
#' labs(title = 'Temperatures in Lincoln NE in 2016') +
#' theme_joy(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank())
#' theme_ridges(font_size = 13, grid = TRUE) + theme(axis.title.y = element_blank())
#' @export
GeomJoyGradient <- ggproto("GeomJoyGradient", GeomRidgelineGradient,
GeomDensityRidgesGradient <- ggproto("GeomDensityRidgesGradient", GeomRidgelineGradient,
default_aes =
aes(color = "black",
fill = "grey70",
Expand Down
56 changes: 28 additions & 28 deletions R/geoms.R
Expand Up @@ -2,7 +2,7 @@
#'
#' Plots the sum of the `y` and `height` aesthetics versus `x`, filling the area between `y` and `y + height` with a color.
#' Thus, the data mapped onto y and onto height must be in the same units.
#' If you want relative scaling of the heights, you can use [`geom_joy`] with `stat = "identity"`.
#' If you want relative scaling of the heights, you can use [`geom_density_ridges`] with `stat = "identity"`.
#'
#' @param mapping Set of aesthetic mappings created by [`aes()`] or
#' [`aes_()`]. If specified and `inherit.aes = TRUE` (the
Expand Down Expand Up @@ -176,7 +176,7 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,
positions <- plyr::summarise(data, x = x, y = ymax, id = ids)
munched_line <- ggplot2::coord_munch(coord, positions, panel_params)

# placing the actual grob generation into a separate function allows us to override for geom_joy2
# placing the actual grob generation into a separate function allows us to override for geom_density_ridges2
self$make_group_grob(munched_line, munched_poly, aes)
},

Expand Down Expand Up @@ -206,17 +206,17 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,



#' Create joyplot
#' Create ridgeline plot
#'
#' `geom_joy` arranges multiple density plots in a staggered fashion, as in the cover of the famous Joy Division album Unknown Pleasures.
#' `geom_density_ridges` arranges multiple density plots in a staggered fashion, as in the cover of the famous Joy Division album Unknown Pleasures.
#'
#' By default, this geom calculates densities from the point data mapped onto the x axis. If density calculation is
#' not wanted, use `stat="identity"` or use [`geom_ridgeline`]. The difference between `geom_joy` and [`geom_ridgeline`]
#' is that `geom_joy` will provide automatic scaling of the ridgelines (controlled by the `scale` aesthetic), whereas
#' not wanted, use `stat="identity"` or use [`geom_ridgeline`]. The difference between `geom_density_ridges` and [`geom_ridgeline`]
#' is that `geom_density_ridges` will provide automatic scaling of the ridgelines (controlled by the `scale` aesthetic), whereas
#' [geom_ridgeline] will plot the data as is. Note that when you set `stat="identity"`, the `height` aesthetic must
#' be provided.
#'
#' Note that the default [`stat_joy`] makes joint density estimation across all datasets. This may not generate
#' Note that the default [`stat_density_ridges`] makes joint density estimation across all datasets. This may not generate
#' the desired result when using faceted plots. As an alternative, you can set `stat = "density"` to use [`stat_density`].
#' In this case, it is required to add the aesthetic mapping `height = ..density..` (see examples).
#'
Expand All @@ -233,7 +233,7 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,
#' * `group` Defines the grouping. Not needed if a categorical variable is mapped onto `y`, but needed otherwise. Will typically be the same
#' variable as is mapped to `y`.
#' * `height` The height of each ridgeline at the respective x value. Automatically calculated and
#' provided by [`stat_joy`] if the default stat is not changed.
#' provided by [`stat_density_ridges`] if the default stat is not changed.
#' * `scale` A scaling factor to scale the height of the ridgelines relative to the spacing between them.
#' A value of 1 indicates that the maximum point of any ridgeline touches the baseline right above, assuming
#' even spacing between baselines.
Expand All @@ -248,33 +248,33 @@ GeomRidgeline <- ggproto("GeomRidgeline", Geom,
#' @examples
#' # set the `rel_min_height` argument to remove tails
#' ggplot(iris, aes(x = Sepal.Length, y = Species)) +
#' geom_joy(rel_min_height = 0.005) +
#' geom_density_ridges(rel_min_height = 0.005) +
#' scale_y_discrete(expand = c(0.01, 0)) +
#' scale_x_continuous(expand = c(0.01, 0)) +
#' theme_joy()
#' theme_ridges()
#'
#' # set the `scale` to determine how much overlap there is among the plots
#' ggplot(diamonds, aes(x = price, y = cut)) +
#' geom_joy(scale = 4) +
#' geom_density_ridges(scale = 4) +
#' scale_y_discrete(expand=c(0.01, 0)) +
#' scale_x_continuous(expand=c(0.01, 0)) +
#' theme_joy()
#' theme_ridges()
#'
#' # the same figure with colors, and using the ggplot2 density stat
#' ggplot(diamonds, aes(x = price, y = cut, fill = cut, height = ..density..)) +
#' geom_joy(scale = 4, stat = "density") +
#' geom_density_ridges(scale = 4, stat = "density") +
#' scale_y_discrete(expand = c(0.01, 0)) +
#' scale_x_continuous(expand = c(0.01, 0)) +
#' scale_fill_brewer(palette = 4) +
#' theme_joy() + theme(legend.position = "none")
geom_joy <- function(mapping = NULL, data = NULL, stat = "joy",
#' theme_ridges() + theme(legend.position = "none")
geom_density_ridges <- function(mapping = NULL, data = NULL, stat = "density_ridges",
panel_scaling = TRUE,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) {
layer(
data = data,
mapping = mapping,
stat = stat,
geom = GeomJoy,
geom = GeomDensityRidges,
position = "identity",
show.legend = show.legend,
inherit.aes = inherit.aes,
Expand All @@ -286,12 +286,12 @@ geom_joy <- function(mapping = NULL, data = NULL, stat = "joy",
)
}

#' @rdname geom_joy
#' @rdname geom_density_ridges
#' @format NULL
#' @usage NULL
#' @importFrom grid gTree gList
#' @export
GeomJoy <- ggproto("GeomJoy", GeomRidgeline,
GeomDensityRidges <- ggproto("GeomDensityRidges", GeomRidgeline,
default_aes =
aes(color = "black",
fill = "grey70",
Expand Down Expand Up @@ -360,27 +360,27 @@ GeomJoy <- ggproto("GeomJoy", GeomRidgeline,
)


#' `geom_joy2` is identical to `geom_joy` except it draws closed polygons rather than ridgelines.
#' `geom_density_ridges2` is identical to `geom_density_ridges` except it draws closed polygons rather than ridgelines.
#'
#' @rdname geom_joy
#' @rdname geom_density_ridges
#' @importFrom ggplot2 layer
#' @export
#' @examples
#'
#' # use geom_joy2() instead of geom_joy() for solid polygons
#' # use geom_density_ridges2() instead of geom_density_ridges() for solid polygons
#' ggplot(iris, aes(x = Sepal.Length, y = Species)) +
#' geom_joy2() +
#' geom_density_ridges2() +
#' scale_y_discrete(expand = c(0.01, 0)) +
#' scale_x_continuous(expand = c(0.01, 0)) +
#' theme_joy()
geom_joy2 <- function(mapping = NULL, data = NULL, stat = "joy",
#' theme_ridges()
geom_density_ridges2 <- function(mapping = NULL, data = NULL, stat = "density_ridges",
panel_scaling = TRUE,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) {
layer(
data = data,
mapping = mapping,
stat = stat,
geom = GeomJoy2,
geom = GeomDensityRidges2,
position = "identity",
show.legend = show.legend,
inherit.aes = inherit.aes,
Expand All @@ -392,13 +392,13 @@ geom_joy2 <- function(mapping = NULL, data = NULL, stat = "joy",
)
}

#' @rdname geom_joy
#' @rdname geom_density_ridges
#' @format NULL
#' @usage NULL
#' @export
GeomJoy2 <- ggproto("GeomJoy2", GeomJoy,
GeomDensityRidges2 <- ggproto("GeomDensityRidges2", GeomDensityRidges,
make_group_grob = function(munched_line, munched_poly, aes) {
ggname("geom_joy2",
ggname("geom_density_ridges2",
grid::polygonGrob(
munched_poly$x, munched_poly$y, id = munched_poly$id,
default.units = "native",
Expand Down
2 changes: 1 addition & 1 deletion R/geomsv.R
Expand Up @@ -178,7 +178,7 @@ GeomVRidgeline <- ggproto("GeomVRidgeline", Geom,
positions <- plyr::summarise(data, y = y, x = xmax, id = ids)
munched_line <- ggplot2::coord_munch(coord, positions, panel_params)

# placing the actual grob generation into a separate function allows us to override for geom_joy2
# placing the actual grob generation into a separate function allows us to override for geom_density_ridges2
self$make_group_grob(munched_line, munched_poly, aes)
},

Expand Down
4 changes: 2 additions & 2 deletions R/ggjoy.R → R/ggridges.R
@@ -1,6 +1,6 @@
#' ggjoy.
#' ggridges.
#'
#' @name ggjoy
#' @name ggridges
#' @docType package
#' @import ggplot2
NULL
8 changes: 4 additions & 4 deletions R/scale-cyclical.R
@@ -1,6 +1,6 @@
#' Create a discrete scale that cycles between values
#'
#' The readability of joyplots can often be improved by alternating between fill colors and
#' The readability of ridgeline plots can often be improved by alternating between fill colors and
#' other aesthetics. The various cyclical scales make it easy to create plots with this feature,
#' simply map your grouping variable to the respective aesthetic (e.g., `fill`) and then use
#' `scale_fill_cyclical` to define the fill colors between you want to alternate. Note that the
Expand All @@ -17,12 +17,12 @@
#' # By default, scale_cyclical sets `guide = "none"`, i.e., no legend
#' # is drawn
#' ggplot(diamonds, aes(x = price, y = cut, fill = cut)) +
#' geom_joy(scale = 4) +
#' geom_density_ridges(scale = 4) +
#' scale_fill_cyclical(values = c("#3030D0", "#9090F0"))
#'
#' # However, legends can be turned on by setting `guide = "legend"`
#' ggplot(diamonds, aes(x = price, y = cut, fill = cut)) +
#' geom_joy(scale = 4) +
#' geom_density_ridges(scale = 4) +
#' scale_fill_cyclical(values = c("#3030D0", "#9090F0"),
#' guide = "legend", name = "Fill colors",
#' labels = c("dark blue", "light blue"))
Expand All @@ -31,7 +31,7 @@
#' ggplot(diamonds, aes(x = price, y = cut, fill = cut,
#' color = cut, size = cut,
#' alpha = cut, linetype = cut)) +
#' geom_joy(scale = 4, fill = "blue") +
#' geom_density_ridges(scale = 4, fill = "blue") +
#' scale_fill_cyclical(values = c("blue", "green")) +
#' scale_color_cyclical(values = c("black", "white")) +
#' scale_size_cyclical(values = c(2, 1)) +
Expand Down

0 comments on commit 7267395

Please sign in to comment.