Skip to content

Commit 14325b4

Browse files
authored
Improve geom_bar documentation (#3751) (#3769)
* Improve geom_bar documentation (#3751) * Writing changes and grammar error
1 parent fc2dfbc commit 14325b4

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed

R/geom-bar.r

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
#' Bar charts
22
#'
33
#' There are two types of bar charts: `geom_bar()` and `geom_col()`.
4-
#' `geom_bar()` makes the height of the
5-
#' bar proportional to the number of cases in each group (or if the
6-
#' `weight` aesthetic is supplied, the sum of the weights). If you want the
7-
#' heights of the bars to represent values in the data, use
8-
#' `geom_col()` instead. `geom_bar()` uses `stat_count()` by
4+
#' `geom_bar()` makes the height of the bar proportional to the number of
5+
#' cases in each group (or if the `weight` aesthetic is supplied, the sum
6+
#' of the weights). If you want the heights of the bars to represent values
7+
#' in the data, use `geom_col()` instead. `geom_bar()` uses `stat_count()` by
98
#' default: it counts the number of cases at each x position. `geom_col()`
109
#' uses `stat_identity()`: it leaves the data as is.
1110
#'
1211
#' A bar chart uses height to represent a value, and so the base of the
13-
#' bar must always be shown to produce a valid visual comparison. This is why
14-
#' it doesn't make sense to use a log-scaled y axis with a bar chart.
12+
#' bar must always be shown to produce a valid visual comparison.
13+
#' Proceed with caution when using transformed scales with a bar chart.
14+
#' It's important to always use a meaningful reference point for the base of the bar.
15+
#' For example, for log transformations the reference point is 1. In fact, when
16+
#' using a log scale, `geom_bar()` automatically places the base of the bar at 1.
17+
#' Furthermore, never use stacked bars with a transformed scale, because scaling
18+
#' happens before stacking. As a consequence, the height of bars will be wrong
19+
#' when stacking occurs with a transformed scale.
1520
#'
1621
#' By default, multiple bars occupying the same `x` position will be stacked
1722
#' atop one another by [position_stack()]. If you want them to be dodged
1823
#' side-to-side, use [position_dodge()] or [position_dodge2()]. Finally,
19-
#' [position_fill()] shows relative proportions at each `x` by stacking the bars
20-
#' and then standardising each bar to have the same height.
24+
#' [position_fill()] shows relative proportions at each `x` by stacking the
25+
#' bars and then standardising each bar to have the same height.
2126
#'
2227
#' @eval rd_orientation()
2328
#'
@@ -36,8 +41,8 @@
3641
#' rare event that this fails it can be given explicitly by setting `orientation`
3742
#' to either `"x"` or `"y"`. See the *Orientation* section for more detail.
3843
#' @param width Bar width. By default, set to 90% of the resolution of the data.
39-
#' @param binwidth `geom_bar()` no longer has a binwidth argument - if
40-
#' you use it you'll get an warning telling to you use
44+
#' @param binwidth `geom_bar()` no longer has a binwidth argument---if
45+
#' you use it you'll get a warning telling to you use
4146
#' [geom_histogram()] instead.
4247
#' @param geom,stat Override the default connection between `geom_bar()` and
4348
#' `stat_count()`.

man/geom_bar.Rd

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

0 commit comments

Comments
 (0)