Skip to content

Updating most visited docs (#2553) #2727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 10, 2018
Merged
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
4 changes: 2 additions & 2 deletions R/aes.r
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ NULL
#'
#' This function also standardises aesthetic names by performing partial
#' matching, converting color to colour, and translating old style R names to
#' ggplot names (eg. pch to shape, cex to size).
#' ggplot names (e.g. pch to shape, cex to size).
#'
#' @section Quasiquotation:
#'
Expand Down Expand Up @@ -186,7 +186,7 @@ is_position_aes <- function(vars) {
aes_to_scale(vars) %in% c("x", "y")
}

#' Define aesthetic mappings programatically
#' Define aesthetic mappings programmatically
#'
#' Aesthetic mappings describe how variables in the data are mapped to visual
#' properties (aesthetics) of geoms. [aes()] uses non-standard
Expand Down
4 changes: 2 additions & 2 deletions R/facet-.r
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ NULL
#'
#' - `draw_labels`: Given the gtable returned by `draw_panels`,
#' add axis titles to the gtable. The default is to add one title at each side
#' depending on the position and existance of axes.
#' depending on the position and existence of axes.
#'
#' All extension methods recieve the content of the params field as the params
#' All extension methods receive the content of the params field as the params
#' argument, so the constructor function will generally put all relevant
#' information into this field. The only exception is the `shrink`
#' parameter which is used to determine if scales are retrained after Stat
Expand Down
2 changes: 1 addition & 1 deletion R/facet-grid-.r
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ NULL
#'
#' # Margins ----------------------------------------------------------
#' \donttest{
#' # Margins can be specified by logically (all yes or all no) or by specific
#' # Margins can be specified logically (all yes or all no) or for specific
#' # variables as (character) variable names
#' mg <- ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point()
#' mg + facet_grid(vs + am ~ gear, margins = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/fortify-map.r
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
#' @param regions map region
#' @param fill fill colour
#' @param colour border colour
#' @param xlim,ylim latitudinal and logitudinal range for extracting map
#' @param xlim,ylim latitudinal and longitudinal ranges for extracting map
#' polygons, see [maps::map()] for details.
#' @inheritDotParams geom_polygon
#' @export
Expand Down
17 changes: 9 additions & 8 deletions R/geom-bar.r
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#' Bar charts
#'
#' There are two types of bar charts: `geom_bar` makes the height of the
#' There are two types of bar charts: `geom_bar()` and `geom_col()`.
#' `geom_bar()` makes the height of the
#' bar proportional to the number of cases in each group (or if the
#' `weight` aesthetic is supplied, the sum of the weights). If you want the
#' heights of the bars to represent values in the data, use
#' \link{geom_col} instead. `geom_bar` uses `stat_count` by
#' default: it counts the number of cases at each x position. `geom_col`
#' uses `stat_identity`: it leaves the data as is.
#' `geom_col()` instead. `geom_bar()` uses `stat_count()` by
#' default: it counts the number of cases at each x position. `geom_col()`
#' uses `stat_identity()`: it leaves the data as is.
#'
#' A bar chart uses height to represent a value, and so the base of the
#' bar must always be shown to produce a valid visual comparison. Naomi Robbins
Expand All @@ -25,16 +26,16 @@
#' @seealso
#' [geom_histogram()] for continuous data,
#' [position_dodge()] and [position_dodge2()] for creating side-by-side
#' barcharts.
#' bar charts.
#' @export
#' @inheritParams layer
#' @inheritParams geom_point
#' @param width Bar width. By default, set to 90\% of the resolution of the data.
#' @param binwidth `geom_bar` no longer has a binwidth argument - if
#' @param binwidth `geom_bar()` no longer has a binwidth argument - if
#' you use it you'll get an warning telling to you use
#' [geom_histogram()] instead.
#' @param geom,stat Override the default connection between `geom_bar` and
#' `stat_count`.
#' @param geom,stat Override the default connection between `geom_bar()` and
#' `stat_count()`.
#' @examples
#' # geom_bar is designed to make it easy to create bar charts that show
#' # counts (or sums of weights)
Expand Down
2 changes: 1 addition & 1 deletion R/geom-boxplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#' if the notches of two boxes do not overlap, this suggests that the medians
#' are significantly different.
#' @param notchwidth For a notched box plot, width of the notch relative to
#' the body (default 0.5)
#' the body (defaults to `notchwidth = 0.5`).
#' @param varwidth If `FALSE` (default) make a standard box plot. If
#' `TRUE`, boxes are drawn with widths proportional to the
#' square-roots of the number of observations in the groups (possibly
Expand Down
2 changes: 1 addition & 1 deletion R/geom-linerange.r
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' `geom_pointrange()`.
#' @seealso
#' [stat_summary()] for examples of these guys in use,
#' [geom_smooth()] for continuous analog,
#' [geom_smooth()] for continuous analogue,
#' [geom_errorbarh()] for a horizontal error bar.
#' @export
#' @inheritParams layer
Expand Down
10 changes: 2 additions & 8 deletions R/geom-point.r
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#' There is no one solution to this problem, but there are some techniques
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section starting "The bubblechart" seems a bit weak.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to fill this PR just with minor edits and go back through for bigger changes to text in separate PRs. For instance here with "bubblechart", and with theme, etc.

#' that can help. You can add additional information with
#' [geom_smooth()], [geom_quantile()] or
#' [geom_density_2d()]. If you have few unique x values,
#' [geom_density_2d()]. If you have few unique `x` values,
#' [geom_boxplot()] may also be useful.
#'
#' Alternatively, you can
Expand All @@ -36,7 +36,7 @@
#' a warning. If `TRUE`, missing values are silently removed.
#' @param ... Other arguments passed on to [layer()]. These are
#' often aesthetics, used to set an aesthetic to a fixed value, like
#' `color = "red"` or `size = 3`. They may also be parameters
#' `colour = "red"` or `size = 3`. They may also be parameters
#' to the paired geom/stat.
#' @inheritParams layer
#' @export
Expand Down Expand Up @@ -76,12 +76,6 @@
#' geom_point(colour = "pink", size = 4) +
#' geom_point(aes(shape = factor(cyl)))
#'
#' # These extra layers don't usually appear in the legend, but we can
#' # force their inclusion
#' p + geom_point(colour = "black", size = 4.5, show.legend = TRUE) +
#' geom_point(colour = "pink", size = 4, show.legend = TRUE) +
#' geom_point(aes(shape = factor(cyl)))
#'
#' # geom_point warns when missing values have been dropped from the data set
#' # and not plotted, you can turn this off by setting na.rm = TRUE
#' mtcars2 <- transform(mtcars, mpg = ifelse(runif(32) < 0.2, NA, mpg))
Expand Down
2 changes: 1 addition & 1 deletion R/geom-ribbon.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' by `ymin` and `ymax`. `geom_area` is a special case of
#' `geom_ribbon`, where the `ymin` is fixed to 0.
#'
#' An area plot is the continuous analog of a stacked bar chart (see
#' An area plot is the continuous analogue of a stacked bar chart (see
#' [geom_bar()]), and can be used to show how composition of the
#' whole varies over the range of x. Choosing the order in which different
#' components is stacked is very important, as it becomes increasing hard to
Expand Down
2 changes: 1 addition & 1 deletion R/geom-segment.r
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @inheritParams layer
#' @inheritParams geom_point
#' @param arrow specification for arrow heads, as created by arrow().
#' @param arrow.fill fill color to use for the arrow head (if closed). `NULL`
#' @param arrow.fill fill colour to use for the arrow head (if closed). `NULL`
#' means use `colour` aesthetic.
#' @param lineend Line end style (round, butt, square).
#' @param linejoin Line join style (round, mitre, bevel).
Expand Down
20 changes: 10 additions & 10 deletions R/geom-smooth.r
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#'
#' Calculation is performed by the (currently undocumented)
#' `predictdf` generic and its methods. For most methods the standard
#' error bounds are computed using the [predict()] method - the
#' exceptions are `loess` which uses a t-based approximation, and
#' `glm` where the normal confidence interval is constructed on the link
#' scale, and then back-transformed to the response scale.
#' error bounds are computed using the [predict()] method -- the
#' exceptions are `loess`, which uses a t-based approximation, and
#' `glm`, where the normal confidence interval is constructed on the link
#' scale and then back-transformed to the response scale.
#'
#' @eval rd_aesthetics("geom", "smooth")
#' @inheritParams layer
Expand All @@ -19,15 +19,15 @@
#' `geom_smooth` and `stat_smooth`.
#' @seealso See individual modelling functions for more details:
#' [lm()] for linear smooths,
#' [glm()] for generalised linear smooths,
#' [loess()] for local smooths
#' [glm()] for generalised linear smooths, and
#' [loess()] for local smooths.
#' @export
#' @examples
#' ggplot(mpg, aes(displ, hwy)) +
#' geom_point() +
#' geom_smooth()
#'
#' # Use span to control the "wiggliness" of the default loess smoother
#' # Use span to control the "wiggliness" of the default loess smoother.
#' # The span is the fraction of points used to fit each local regression:
#' # small numbers make a wigglier curve, larger numbers make a smoother curve.
#' ggplot(mpg, aes(displ, hwy)) +
Expand All @@ -43,8 +43,8 @@
#' geom_point() +
#' geom_smooth(method = lm, formula = y ~ splines::bs(x, 3), se = FALSE)
#'
#' # Smoothes are automatically fit to each group (defined by categorical
#' # aesthetics or the group aesthetic) and for each facet
#' # Smooths are automatically fit to each group (defined by categorical
#' # aesthetics or the group aesthetic) and for each facet.
#'
#' ggplot(mpg, aes(displ, hwy, colour = class)) +
#' geom_point() +
Expand Down Expand Up @@ -73,7 +73,7 @@
#' binomial_smooth(formula = y ~ splines::ns(x, 2))
#'
#' # But in this case, it's probably better to fit the model yourself
#' # so you can exercise more control and see whether or not it's a good model
#' # so you can exercise more control and see whether or not it's a good model.
#' }
geom_smooth <- function(mapping = NULL, data = NULL,
stat = "smooth", position = "identity",
Expand Down
8 changes: 4 additions & 4 deletions R/geom-text.r
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' data, even if coordinates x, y are set to single values in the call
#' to `geom_label` or `geom_text`.
#' To add labels at specified points use [annotate()] with
#' `annotate(geom = "text", ...)` or `annotate(geom = "label", ...)`
#' `annotate(geom = "text", ...)` or `annotate(geom = "label", ...)`.
#'
#' @eval rd_aesthetics("geom", "text")
#' @section `geom_label`:
Expand All @@ -28,12 +28,12 @@
#' 1 (top/left) or a character (`"left"`, `"middle"`, `"right"`, `"bottom"`,
#' `"center"`, `"top"`). There are two special alignments: `"inward"` and
#' `"outward"`. Inward always aligns text towards the center, and outward
#' aligns it away from the center
#' aligns it away from the center.
#'
#' @inheritParams layer
#' @inheritParams geom_point
#' @param parse If `TRUE`, the labels will be parsed into expressions and
#' displayed as described in ?plotmath
#' displayed as described in `?plotmath`.
#' @param nudge_x,nudge_y Horizontal and vertical adjustment to nudge labels by.
#' Useful for offsetting text from points, particularly on discrete scales.
#' @param check_overlap If `TRUE`, text that overlaps previous text in the
Expand Down Expand Up @@ -97,7 +97,7 @@
#' ggplot(data = df, aes(x, y, group = grp)) +
#' geom_col(aes(fill = grp), position = "dodge") +
#' geom_text(aes(label = y), position = position_dodge(0.9))
#' # Use you can't nudge and dodge text, so instead adjust the y postion
#' # Use you can't nudge and dodge text, so instead adjust the y position
#' ggplot(data = df, aes(x, y, group = grp)) +
#' geom_col(aes(fill = grp), position = "dodge") +
#' geom_text(
Expand Down
58 changes: 29 additions & 29 deletions R/guide-colorbar.r
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
#' Continuous colour bar guide
#'
#' Colour bar guide shows continuous color scales mapped onto values.
#' Colour bar guide shows continuous colour scales mapped onto values.
#' Colour bar is available with `scale_fill` and `scale_colour`.
#' For more information, see the inspiration for this function:
#' \href{http://www.mathworks.com/help/techdoc/ref/colorbar.html}{Matlab's colorbar function}.
#'
#' Guides can be specified in each `scale_*` or in [guides()].
#' `guide="legend"` in `scale_*` is syntactic sugar for
#' `guide=guide_legend()` (e.g. `scale_color_manual(guide = "legend")`).
#' `guide=guide_legend()` (e.g. `scale_colour_manual(guide = "legend")`).
#' As for how to specify the guide for each scale in more detail,
#' see [guides()].
#'
#' @inheritParams guide_legend
#' @param barwidth A numeric or a [grid::unit()] object specifying
#' the width of the colorbar. Default value is `legend.key.width` or
#' the width of the colourbar. Default value is `legend.key.width` or
#' `legend.key.size` in [theme()] or theme.
#' @param barheight A numeric or a [grid::unit()] object specifying
#' the height of the colorbar. Default value is `legend.key.height` or
#' the height of the colourbar. Default value is `legend.key.height` or
#' `legend.key.size` in [theme()] or theme.
#' @param frame.colour A string specifying the colour of the frame
#' drawn around the bar. If `NULL` (the default), no frame is drawn.
#' @param frame.linewidth A numeric specifying the width of the frame
#' drawn around the bar.
#' @param frame.linetype A numeric specifying the linetype of the frame
#' drawn around the bar.
#' @param nbin A numeric specifying the number of bins for drawing colorbar. A
#' smoother colorbar for a larger value.
#' @param raster A logical. If `TRUE` then the colorbar is rendered as a
#' raster object. If `FALSE` then the colorbar is rendered as a set of
#' @param nbin A numeric specifying the number of bins for drawing the
#' colourbar. A smoother colourbar results from a larger value.
#' @param raster A logical. If `TRUE` then the colourbar is rendered as a
#' raster object. If `FALSE` then the colourbar is rendered as a set of
#' rectangles. Note that not all graphics devices are capable of rendering
#' raster image.
#' @param ticks A logical specifying if tick marks on colorbar should be
#' @param ticks A logical specifying if tick marks on the colourbar should be
#' visible.
#' @param ticks.colour A string specifying the color of the tick marks.
#' @param ticks.colour A string specifying the colour of the tick marks.
#' @param ticks.linewidth A numeric specifying the width of the tick marks.
#' @param draw.ulim A logical specifying if the upper limit tick marks should
#' be visible.
Expand All @@ -42,10 +42,10 @@
#' One of "horizontal" or "vertical."
#' @param default.unit A character string indicating [grid::unit()]
#' for `barwidth` and `barheight`.
#' @param reverse logical. If `TRUE` the colorbar is reversed. By default,
#' @param reverse logical. If `TRUE` the colourbar is reversed. By default,
#' the highest value is on the top and the lowest value is on the bottom
#' @param available_aes A vector of charater strings listing the aesthetics
#' for which a colorbar can be drawn.
#' @param available_aes A vector of character strings listing the aesthetics
#' for which a colourbar can be drawn.
#' @param ... ignored.
#' @return A guide object
#' @export
Expand All @@ -57,45 +57,45 @@
#' p2 <- p1 + geom_point(aes(size = value))
#'
#' # Basic form
#' p1 + scale_fill_continuous(guide = "colorbar")
#' p1 + scale_fill_continuous(guide = guide_colorbar())
#' p1 + guides(fill = guide_colorbar())
#' p1 + scale_fill_continuous(guide = "colourbar")
#' p1 + scale_fill_continuous(guide = guide_colourbar())
#' p1 + guides(fill = guide_colourbar())
#'
#' # Control styles
#'
#' # bar size
#' p1 + guides(fill = guide_colorbar(barwidth = 0.5, barheight = 10))
#' p1 + guides(fill = guide_colourbar(barwidth = 0.5, barheight = 10))
#'
#' # no label
#' p1 + guides(fill = guide_colorbar(label = FALSE))
#' p1 + guides(fill = guide_colourbar(label = FALSE))
#'
#' # no tick marks
#' p1 + guides(fill = guide_colorbar(ticks = FALSE))
#' p1 + guides(fill = guide_colourbar(ticks = FALSE))
#'
#' # label position
#' p1 + guides(fill = guide_colorbar(label.position = "left"))
#' p1 + guides(fill = guide_colourbar(label.position = "left"))
#'
#' # label theme
#' p1 + guides(fill = guide_colorbar(label.theme = element_text(colour = "blue", angle = 0)))
#' p1 + guides(fill = guide_colourbar(label.theme = element_text(colour = "blue", angle = 0)))
#'
#' # small number of bins
#' p1 + guides(fill = guide_colorbar(nbin = 3))
#' p1 + guides(fill = guide_colourbar(nbin = 3))
#'
#' # large number of bins
#' p1 + guides(fill = guide_colorbar(nbin = 100))
#' p1 + guides(fill = guide_colourbar(nbin = 100))
#'
#' # make top- and bottom-most ticks invisible
#' p1 + scale_fill_continuous(limits = c(0,20), breaks = c(0, 5, 10, 15, 20),
#' guide = guide_colorbar(nbin=100, draw.ulim = FALSE, draw.llim = FALSE))
#' guide = guide_colourbar(nbin=100, draw.ulim = FALSE, draw.llim = FALSE))
#'
#' # guides can be controlled independently
#' p2 +
#' scale_fill_continuous(guide = "colorbar") +
#' scale_fill_continuous(guide = "colourbar") +
#' scale_size(guide = "legend")
#' p2 + guides(fill = "colorbar", size = "legend")
#' p2 + guides(fill = "colourbar", size = "legend")
#'
#' p2 +
#' scale_fill_continuous(guide = guide_colorbar(direction = "horizontal")) +
#' scale_fill_continuous(guide = guide_colourbar(direction = "horizontal")) +
#' scale_size(guide = guide_legend(direction = "vertical"))
guide_colourbar <- function(

Expand Down Expand Up @@ -195,12 +195,12 @@ guide_train.colorbar <- function(guide, scale, aesthetic = NULL) {

# do nothing if scale are inappropriate
if (length(intersect(scale$aesthetics, guide$available_aes)) == 0) {
warning("colorbar guide needs appropriate scales: ",
warning("colourbar guide needs appropriate scales: ",
paste(guide$available_aes, collapse = ", "))
return(NULL)
}
if (scale$is_discrete()) {
warning("colorbar guide needs continuous scales.")
warning("colourbar guide needs continuous scales.")
return(NULL)
}

Expand Down
Loading