Skip to content

Commit c358000

Browse files
authored
Improve quantile docs (#6654)
* interpret logical `linewidth` as integer * clarify documentation * add news bullet
1 parent 276c5a9 commit c358000

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

NEWS.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# ggplot2 (development version)
22

3-
### Bug fixes
4-
3+
* Logical values for the linetype aesthetic will be interpreted numerically,
4+
so that `linetype = FALSE` becomes 0/'blank' and `linetype = TRUE` becomes
5+
1/'solid' (@teunbrand, #6641)
56
* Out-of-bounds datapoints used as padding by `stat_align()` now get removed
67
silently rather than verbosely (@teunbrand, #6667)
78
* Fixed bug where `stat_bin(boundary)` was ignored (#6682).

R/geom-violin.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
#' @param quantile.colour,quantile.color,quantile.linewidth,quantile.linetype
2525
#' Default aesthetics for the quantile lines. Set to `NULL` to inherit from
2626
#' the data's aesthetics. By default, quantile lines are hidden and can be
27-
#' turned on by changing `quantile.linetype`.
27+
#' turned on by changing `quantile.linetype`. Quantile values can be set
28+
#' using the `quantiles` argument when using `stat = "ydensity"` (default).
2829
#' @param draw_quantiles `r lifecycle::badge("deprecated")` Previous
2930
#' specification of drawing quantiles.
3031
#' @export

R/stat-ydensity.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,11 @@ StatYdensity <- ggproto(
137137
#' @param drop Whether to discard groups with less than 2 observations
138138
#' (`TRUE`, default) or keep such groups for position adjustment purposes
139139
#' (`FALSE`).
140-
#' @param quantiles If not `NULL` (default), compute the `quantile` variable
141-
#' and draw horizontal lines at the given quantiles in `geom_violin()`.
140+
#' @param quantiles A numeric vector with numbers between 0 and 1 to indicate
141+
#' quantiles marked by the `quantile` computed variable. The default marks the
142+
#' 25th, 50th and 75th percentiles. The display of quantiles can be
143+
#' turned on by setting `quantile.linetype` to non-blank when using
144+
#' `geom = "violin"` (default).
142145
#'
143146
#' @eval rd_computed_vars(
144147
#' density = "Density estimate.",

R/utilities-grid.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ gg_par <- function(..., stroke = NULL, pointsize = NULL) {
4141
stroke[is.na(stroke)] <- 0
4242
args$fontsize <- pointsize * .pt + stroke * .stroke / 2
4343
}
44-
if (!is.null(args$lty) && anyNA(args$lty)) {
45-
args$lty[is.na(args$lty)] <- if (is.character(args$lty)) "blank" else 0
44+
if (!is.null(args$lty)) {
45+
if (is.logical(args$lty)) {
46+
args$lty <- as.integer(args$lty)
47+
}
48+
if (anyNA(args$lty)) {
49+
args$lty[is.na(args$lty)] <- if (is.character(args$lty)) "blank" else 0
50+
}
4651
}
4752

4853
inject(gpar(!!!args))

man/geom_violin.Rd

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)