|
1 | 1 | #' Bar charts
|
2 | 2 | #'
|
3 | 3 | #' 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 |
9 | 8 | #' default: it counts the number of cases at each x position. `geom_col()`
|
10 | 9 | #' uses `stat_identity()`: it leaves the data as is.
|
11 | 10 | #'
|
12 | 11 | #' 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. |
15 | 20 | #'
|
16 | 21 | #' By default, multiple bars occupying the same `x` position will be stacked
|
17 | 22 | #' atop one another by [position_stack()]. If you want them to be dodged
|
18 | 23 | #' 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. |
21 | 26 | #'
|
22 | 27 | #' @eval rd_orientation()
|
23 | 28 | #'
|
|
36 | 41 | #' rare event that this fails it can be given explicitly by setting `orientation`
|
37 | 42 | #' to either `"x"` or `"y"`. See the *Orientation* section for more detail.
|
38 | 43 | #' @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 |
41 | 46 | #' [geom_histogram()] instead.
|
42 | 47 | #' @param geom,stat Override the default connection between `geom_bar()` and
|
43 | 48 | #' `stat_count()`.
|
|
0 commit comments