Compare commits

...

3 Commits

  1. 11
      DESCRIPTION
  2. 10
      NAMESPACE
  3. 353
      R/coord_proj.r
  4. 4
      R/fortify.r
  5. 152
      R/geom_cartogram.r
  6. 62
      R/geom_dumbbell.R
  7. 9
      R/ggalt-package.r
  8. 41
      R/position-jitter-on-equal.R
  9. 14
      README.Rmd
  10. 32
      README.md
  11. BIN
      README_figs/README-annoticks-1.png
  12. BIN
      README_figs/README-annoticks-2.png
  13. BIN
      README_figs/README-annoticks-3.png
  14. BIN
      README_figs/README-bkde2d-1.png
  15. BIN
      README_figs/README-bkde2d-2.png
  16. BIN
      README_figs/README-bkde_ash-1.png
  17. BIN
      README_figs/README-bkde_ash-2.png
  18. BIN
      README_figs/README-bkde_ash-3.png
  19. BIN
      README_figs/README-bkde_ash-4.png
  20. BIN
      README_figs/README-bkde_ash-5.png
  21. BIN
      README_figs/README-bkde_ash-6.png
  22. BIN
      README_figs/README-bkde_ash-7.png
  23. BIN
      README_figs/README-bkde_ash-8.png
  24. BIN
      README_figs/README-dumbbell-1.png
  25. BIN
      README_figs/README-dumbbell2-1.png
  26. BIN
      README_figs/README-encircle-1.png
  27. BIN
      README_figs/README-encircle-2.png
  28. BIN
      README_figs/README-encircle-3.png
  29. BIN
      README_figs/README-encircle-4.png
  30. BIN
      README_figs/README-encircle-5.png
  31. BIN
      README_figs/README-encircle-6.png
  32. BIN
      README_figs/README-encircle-7.png
  33. BIN
      README_figs/README-horizon-1.png
  34. BIN
      README_figs/README-lollipop-1.png
  35. BIN
      README_figs/README-spikelines-1.png
  36. BIN
      README_figs/README-splines-1.png
  37. BIN
      README_figs/README-splines-2.png
  38. BIN
      README_figs/README-splines-3.png
  39. BIN
      README_figs/README-splines-4.png
  40. BIN
      README_figs/README-splines-5.png
  41. BIN
      README_figs/README-splines-6.png
  42. BIN
      README_figs/README-splines-7.png
  43. BIN
      README_figs/README-splines-8.png
  44. BIN
      README_figs/README-stateface-1.png
  45. BIN
      README_figs/README-stepribbon-1.png
  46. BIN
      README_figs/README-stepribbon-2.png
  47. 10
      man/absoluteGrob.Rd
  48. 22
      man/annotate_textp.Rd
  49. 19
      man/annotation_ticks.Rd
  50. 3
      man/byte_format.Rd
  51. 88
      man/coord_proj.Rd
  52. 53
      man/geom_bkde.Rd
  53. 57
      man/geom_bkde2d.Rd
  54. 132
      man/geom_cartogram.Rd
  55. 67
      man/geom_dumbbell.Rd
  56. 13
      man/geom_encircle.Rd
  57. 30
      man/geom_horizon.Rd
  58. 27
      man/geom_lollipop.Rd
  59. 32
      man/geom_spikelines.Rd
  60. 45
      man/geom_stateface.Rd
  61. 26
      man/geom_ubar.Rd
  62. 54
      man/geom_xspline.Rd
  63. 31
      man/geom_xspline2.Rd
  64. 9
      man/ggalt-ggproto.Rd
  65. 1
      man/ggalt.Rd
  66. 5
      man/ggplot2-ggproto.Rd
  67. 5
      man/load_stateface.Rd
  68. 16
      man/position_jitter_on_equal.Rd
  69. 5
      man/show_stateface.Rd
  70. 32
      man/stat_ash.Rd
  71. 29
      man/stat_stepribbon.Rd

11
DESCRIPTION

@ -1,7 +1,7 @@
Package: ggalt
Title: Extra Coordinate Systems, 'Geoms', Statistical Transformations, Scales
and Fonts for 'ggplot2'
Version: 0.6.2
Version: 0.7.0
Maintainer: Bob Rudis <bob@rud.is>
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
@ -44,35 +44,30 @@ Imports:
graphics,
grDevices,
plyr,
dplyr,
RColorBrewer,
KernSmooth,
proj4,
scales,
grid,
gtable,
ash,
maps,
MASS,
extrafont,
tibble,
plotly (>= 3.4.1)
RoxygenNote: 6.1.1
RoxygenNote: 7.1.1
VignetteBuilder: knitr
Collate:
'annotate_textp.r'
'annotation_ticks.r'
'coord_proj.r'
'formatters.r'
'fortify.r'
'position-dodgev.R'
'position-jitter-on-equal.R'
'geom2plotly.r'
'geom_ash.r'
'geom_bkde.r'
'geom_bkde2d.r'
'geom_spikelines.R'
'geom_dumbbell.R'
'geom_cartogram.r'
'geom_encircle.r'
'geom_horizon.r'
'geom_lollipop.r'

10
NAMESPACE

@ -6,11 +6,9 @@ S3method(grobHeight,absoluteGrob)
S3method(grobWidth,absoluteGrob)
S3method(grobX,absoluteGrob)
S3method(grobY,absoluteGrob)
export(CoordProj)
export(Gb)
export(GeomBkde)
export(GeomBkde2d)
export(GeomCartogram)
export(GeomDumbbell)
export(GeomEncircle)
export(GeomHorizon)
@ -24,6 +22,7 @@ export(GeomXspline)
export(Kb)
export(Mb)
export(PositionDodgev)
export(PositionJitterOnEqual)
export(StatAsh)
export(StatBkde)
export(StatBkde2d)
@ -34,10 +33,8 @@ export(annotate_textp)
export(annotation_ticks)
export(byte_format)
export(bytes)
export(coord_proj)
export(geom_bkde)
export(geom_bkde2d)
export(geom_cartogram)
export(geom_dumbbell)
export(geom_encircle)
export(geom_horizon)
@ -48,6 +45,7 @@ export(geom_ubar)
export(geom_xspline)
export(load_stateface)
export(position_dodgev)
export(position_jitter_on_equal)
export(show_stateface)
export(stat_ash)
export(stat_bkde)
@ -65,11 +63,8 @@ import(ggplot2)
import(grDevices)
import(graphics)
import(grid)
import(maps)
import(proj4)
import(utils)
importFrom(RColorBrewer,brewer.pal)
importFrom(dplyr,filter)
importFrom(extrafont,fonts)
importFrom(extrafont,loadfonts)
importFrom(extrafont,ttf_import)
@ -96,4 +91,3 @@ importFrom(gtable,gtable_width)
importFrom(scales,comma)
importFrom(scales,expand_range)
importFrom(scales,rescale)
importFrom(tibble,as_tibble)

353
R/coord_proj.r

@ -1,353 +0,0 @@
#' Similar to \code{coord_map} but uses the PROJ.4 library/package for projection
#' transformation
#'
#' The representation of a portion of the earth, which is approximately
#' spherical, onto a flat 2D plane requires a projection. This is what
#' \code{coord_proj} does, using the \code{proj4::project()} function from
#' the \code{proj4} package.
#'
#' \if{html}{
#' A sample of the output from \code{coord_proj()} using the Winkel-Tripel projection:
#'
#' \figure{coordproj01.png}{options: width="100\%" alt="Figure: coordproj01.png"}
#' }
#'
#' \if{latex}{
#' A sample of the output from \code{coord_proj()} using the Winkel-Tripel projection:
#'``
#' \figure{coordproj01.png}{options: width=10cm}
#' }
#'
#' @note It is recommended that you use \code{geom_cartogram} with this coordinate system
#' @param proj projection definition. If left \code{NULL} will default to
#' a Robinson projection
#' @param inverse if \code{TRUE} inverse projection is performed (from a
#' cartographic projection into lat/long), otherwise projects from
#' lat/long into a cartographic projection.
#' @param degrees if \code{TRUE} then the lat/long data is assumed to be in
#' degrees, otherwise in radians
#' @param ellps.default default ellipsoid that will be added if no datum or
#' ellipsoid parameter is specified in proj. Older versions of PROJ.4
#' didn't require a datum (and used sphere by default), but 4.5.0 and
#' higher always require a datum or an ellipsoid. Set to \code{NA} if no
#' datum should be added to proj (e.g. if you specify an ellipsoid
#' directly).
#' @param xlim manually specify x limits (in degrees of longitude)
#' @param ylim manually specify y limits (in degrees of latitude)
#' @note When \code{inverse} is \code{FALSE} \code{coord_proj} makes a fairly
#' large assumption that the coordinates being transformed are within
#' -180:180 (longitude) and -90:90 (latitude). As such, it truncates
#' all longitude & latitude input to fit within these ranges. More updates
#' to this new \code{coord_} are planned.
#' @export
#' @examples \dontrun{
#' # World in Winkel-Tripel
# world <- map_data("world")
# world <- world[world$region != "Antarctica",]
#
# gg <- ggplot()
# gg <- gg + geom_cartogram(data=world, map=world,
# aes(x=long, y=lat, map_id=region))
# gg <- gg + coord_proj("+proj=wintri")
# gg
#'
#' # U.S.A. Albers-style
#' usa <- world[world$region == "USA",]
#' usa <- usa[!(usa$subregion %in% c("Alaska", "Hawaii")),]
#'
#' gg <- ggplot()
#' gg <- gg + geom_cartogram(data=usa, map=usa,
#' aes(x=long, y=lat, map_id=region))
#' gg <- gg + coord_proj(
#' paste0("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96",
#' " +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"))
#' gg
#'
#' # Showcase Greenland (properly)
#' greenland <- world[world$region == "Greenland",]
#'
#' gg <- ggplot()
#' gg <- gg + geom_cartogram(data=greenland, map=greenland,
#' aes(x=long, y=lat, map_id=region))
#' gg <- gg + coord_proj(
#' paste0("+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0",
#' " +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))
#' gg
#' }
coord_proj <- function(proj=NULL, inverse = FALSE, degrees = TRUE,
ellps.default="sphere", xlim = NULL, ylim = NULL) {
if (is.null(proj)) {
proj <- paste0(c("+proj=robin +lon_0=0 +x_0=0 +y_0=0",
"+ellps=WGS84 +datum=WGS84 +units=m +no_defs"),
collapse=" ")
}
ggproto(NULL, CoordProj,
proj = proj,
inverse = inverse,
ellps.default = ellps.default,
degrees = degrees,
limits = list(x = xlim, y = ylim),
params= list() # parameters are encoded in the proj4 string
)
}
#' Geom Proto
#' @rdname ggalt-ggproto
#' @format NULL
#' @usage NULL
#' @keywords internal
#' @export
CoordProj <- ggproto("CoordProj", Coord,
transform = function(self, data, panel_params) {
trans <- project4(self, data$x, data$y)
out <- cunion(trans[c("x", "y")], data)
out$x <- rescale(out$x, 0:1, panel_params$x.proj)
out$y <- rescale(out$y, 0:1, panel_params$y.proj)
out
},
distance = function(x, y, panel_params) {
max_dist <- dist_central_angle(panel_params$x.range, panel_params$y.range)
dist_central_angle(x, y) / max_dist
},
aspect = function(ranges) {
diff(ranges$y.proj) / diff(ranges$x.proj)
},
train = function(self, scale_details) {
# range in scale
ranges <- list()
for (n in c("x", "y")) {
scale <- scale_details[[n]]
limits <- self$limits[[n]]
if (is.null(limits)) {
range <- scale$dimension(expand_default(scale))
} else {
range <- range(scale$transform(limits))
}
ranges[[n]] <- range
}
orientation <- self$orientation %||% c(90, 0, mean(ranges$x))
# Increase chances of creating valid boundary region
grid <- expand.grid(
x = seq(ranges$x[1], ranges$x[2], length.out = 50),
y = seq(ranges$y[1], ranges$y[2], length.out = 50)
)
ret <- list(x = list(), y = list())
# range in map
proj <- project4(self, grid$x, grid$y)$range
ret$x$proj <- proj[1:2]
ret$y$proj <- proj[3:4]
for (n in c("x", "y")) {
out <- scale_details[[n]]$break_info(ranges[[n]])
ret[[n]]$range <- out$range
ret[[n]]$major <- out$major_source
ret[[n]]$minor <- out$minor_source
ret[[n]]$labels <- out$labels
}
details <- list(
orientation = orientation,
x.range = ret$x$range, y.range = ret$y$range,
x.proj = ret$x$proj, y.proj = ret$y$proj,
x.major = ret$x$major, x.minor = ret$x$minor, x.labels = ret$x$labels,
y.major = ret$y$major, y.minor = ret$y$minor, y.labels = ret$y$labels
)
details
},
setup_panel_params = function(self, scale_x, scale_y, params = list()) {
# range in scale
ranges <- list()
for (n in c("x", "y")) {
scale <- get(paste0("scale_", n))
limits <- self$limits[[n]]
if (is.null(limits)) {
range <- scale$dimension(expand_default(scale))
} else {
range <- range(scale$transform(limits))
}
ranges[[n]] <- range
}
orientation <- self$orientation %||% c(90, 0, mean(ranges$x))
# Increase chances of creating valid boundary region
grid <- expand.grid(
x = seq(ranges$x[1], ranges$x[2], length.out = 50),
y = seq(ranges$y[1], ranges$y[2], length.out = 50)
)
ret <- list(x = list(), y = list())
# range in map
proj <- project4(self, grid$x, grid$y)$range
ret$x$proj <- proj[1:2]
ret$y$proj <- proj[3:4]
for (n in c("x", "y")) {
out <- get(paste0("scale_", n))$break_info(ranges[[n]])
# out <- panel_params[[n]]$break_info(ranges[[n]])
ret[[n]]$range <- out$range
ret[[n]]$major <- out$major_source
ret[[n]]$minor <- out$minor_source
ret[[n]]$labels <- out$labels
}
details <- list(
orientation = orientation,
x.range = ret$x$range, y.range = ret$y$range,
x.proj = ret$x$proj, y.proj = ret$y$proj,
x.major = ret$x$major, x.minor = ret$x$minor, x.labels = ret$x$labels,
y.major = ret$y$major, y.minor = ret$y$minor, y.labels = ret$y$labels
)
details
},
render_bg = function(self, panel_params, theme) {
xrange <- expand_range(panel_params$x.range, 0.2)
yrange <- expand_range(panel_params$y.range, 0.2)
# Limit ranges so that lines don't wrap around globe
xmid <- mean(xrange)
ymid <- mean(yrange)
xrange[xrange < xmid - 180] <- xmid - 180
xrange[xrange > xmid + 180] <- xmid + 180
yrange[yrange < ymid - 90] <- ymid - 90
yrange[yrange > ymid + 90] <- ymid + 90
xgrid <- with(panel_params, expand.grid(
y = c(seq(yrange[1], yrange[2], length.out = 50), NA),
x = x.major
))
ygrid <- with(panel_params, expand.grid(
x = c(seq(xrange[1], xrange[2], length.out = 50), NA),
y = y.major
))
xlines <- self$transform(xgrid, panel_params)
ylines <- self$transform(ygrid, panel_params)
if (nrow(xlines) > 0) {
grob.xlines <- element_render(
theme, "panel.grid.major.x",
xlines$x, xlines$y, default.units = "native"
)
} else {
grob.xlines <- zeroGrob()
}
if (nrow(ylines) > 0) {
grob.ylines <- element_render(
theme, "panel.grid.major.y",
ylines$x, ylines$y, default.units = "native"
)
} else {
grob.ylines <- zeroGrob()
}
ggname("grill", grobTree(
element_render(theme, "panel.background"),
grob.xlines, grob.ylines
))
},
render_axis_h = function(self, panel_params, theme) {
arrange <- panel_params$x.arrange %||% c("primary", "secondary")
if (is.null(panel_params$x.major)) {
return(list(
top = zeroGrob(),
bottom = zeroGrob()
))
}
x_intercept <- with(panel_params, data.frame(
x = x.major,
y = y.range[1]
))
pos <- self$transform(x_intercept, panel_params)
axes <- list(
bottom = guide_axis(pos$x, panel_params$x.labels, "bottom", theme),
top = guide_axis(pos$x, panel_params$x.labels, "top", theme)
)
axes[[which(arrange == "secondary")]] <- zeroGrob()
axes
},
render_axis_v = function(self, panel_params, theme) {
arrange <- panel_params$y.arrange %||% c("primary", "secondary")
if (is.null(panel_params$y.major)) {
return(list(
left = zeroGrob(),
right = zeroGrob()
))
}
x_intercept <- with(panel_params, data.frame(
x = x.range[1],
y = y.major
))
pos <- self$transform(x_intercept, panel_params)
axes <- list(
left = guide_axis(pos$y, panel_params$y.labels, "left", theme),
right = guide_axis(pos$y, panel_params$y.labels, "right", theme)
)
axes[[which(arrange == "secondary")]] <- zeroGrob()
axes
}
)
project4 <- function(coord, x, y) {
df <- data.frame(x=x, y=y)
if (!coord$inverse) {
# map extremes cause issues with projections both with proj4 &
# spTransform. this compensates for them.
df$x <- ifelse(df$x <= -180, -179.99999999999, df$x)
df$x <- ifelse(df$x >= 180, 179.99999999999, df$x)
df$y <- ifelse(df$y <= -90, -89.99999999999, df$y)
df$y <- ifelse(df$y >= 90, 89.99999999999, df$y)
}
suppressWarnings({
res <- proj4::project(list(x=df$x, y=df$y),
proj = coord$proj,
inverse = coord$inverse,
degrees = coord$degrees,
ellps.default = coord$ellps.default)
res$range <- c(range(res$x, na.rm=TRUE), range(res$y, na.rm=TRUE))
res$error <- 0
res
})
}

4
R/fortify.r

@ -5,5 +5,7 @@
#' @param ... (unused)
#' @export
fortify.table <- function(model, data, ...) {
as_tibble(as.data.frame(model, stringsAsFactors=FALSE))
out <- as.data.frame(model, stringsAsFactors=FALSE)
class(out) <- c("tbl_df", "tbl", "data.frame")
out
}

152
R/geom_cartogram.r

@ -1,152 +0,0 @@
#' Map polygons layer enabling the display of show statistical information
#'
#' This replicates the old behaviour of \code{geom_map()}, enabling specifying of
#' \code{x} and \code{y} aesthetics.
#'
#' @section Aesthetics:
#' \code{geom_cartogram} understands the following aesthetics (required aesthetics are in bold):
#' \itemize{
#' \item \code{map_id}
#' \item \code{alpha}
#' \item \code{colour}
#' \item \code{fill}
#' \item \code{group}
#' \item \code{linetype}
#' \item \code{size}
#' \item \code{x}
#' \item \code{y}
#' }
#'
#' @export
#' @param map Data frame that contains the map coordinates. This will
#' typically be created using \code{\link{fortify}} on a spatial object.
#' It must contain columns \code{x}, \code{long} or \code{longitude},
#' \code{y}, \code{lat} or \code{latitude} and \code{region} or \code{id}.
#' @inheritParams ggplot2::layer
#' @inheritParams ggplot2::geom_point
#' @examples \dontrun{
#' # When using geom_polygon, you will typically need two data frames:
#' # one contains the coordinates of each polygon (positions), and the
#' # other the values associated with each polygon (values). An id
#' # variable links the two together
#'
#' ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))
#'
#' values <- data.frame(
#' id = ids,
#' value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5)
#' )
#'
#' positions <- data.frame(
#' id = rep(ids, each = 4),
#' x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
#' 0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3),
#' y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
#' 2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2)
#' )
#'
#' ggplot() +
#' geom_cartogram(aes(x, y, map_id = id), map = positions, data=positions)
#'
#' ggplot() +
#' geom_cartogram(aes(x, y, map_id = id), map = positions, data=positions) +
#' geom_cartogram(data=values, map=positions, aes(fill = value, map_id=id))
#'
#' ggplot() +
#' geom_cartogram(aes(x, y, map_id = id), map = positions, data=positions) +
#' geom_cartogram(data=values, map=positions, aes(fill = value, map_id=id)) +
#' ylim(0, 3)
#'
#' # Better example
#' crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
#' crimesm <- reshape2::melt(crimes, id = 1)
#'
#' if (require(maps)) {
#'
#' states_map <- map_data("state")
#'
#' ggplot() +
#' geom_cartogram(aes(long, lat, map_id = region), map = states_map, data=states_map) +
#' geom_cartogram(aes(fill = Murder, map_id = state), map=states_map, data=crimes)
#'
#' last_plot() + coord_map("polyconic")
#'
#' ggplot() +
#' geom_cartogram(aes(long, lat, map_id=region), map = states_map, data=states_map) +
#' geom_cartogram(aes(fill = value, map_id=state), map = states_map, data=crimesm) +
#' coord_map("polyconic") +
#' facet_wrap( ~ variable)
#' }
#' }
geom_cartogram <- function(mapping = NULL, data = NULL,
stat = "identity",
...,
map,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE) {
# Get map input into correct form
stopifnot(is.data.frame(map))
if (!is.null(map$latitude)) map$y <- map$latitude
if (!is.null(map$lat)) map$y <- map$lat
if (!is.null(map$longitude)) map$x <- map$longitude
if (!is.null(map$long)) map$x <- map$long
if (!is.null(map$region)) map$id <- map$region
stopifnot(all(c("x", "y", "id") %in% names(map)))
layer(
data = data,
mapping = mapping,
stat = stat,
geom = GeomCartogram,
position = PositionIdentity,
show.legend = show.legend,
inherit.aes = inherit.aes,
params = list(
map = map,
na.rm = na.rm,
...
)
)
}
#' Geom Cartogram
#' @rdname ggplot2-ggproto
#' @format NULL
#' @usage NULL
#' @export
GeomCartogram <- ggproto("GeomCartogram", GeomPolygon,
draw_panel = function(data, panel_scales, coord, map) {
# Only use matching data and map ids
common <- intersect(data$map_id, map$id)
data <- data[data$map_id %in% common, , drop = FALSE]
map <- map[map$id %in% common, , drop = FALSE]
# Munch, then set up id variable for polygonGrob -
# must be sequential integers
coords <- coord_munch(coord, map, panel_scales)
coords$group <- coords$group %||% coords$id
grob_id <- match(coords$group, unique(coords$group))
# Align data with map
data_rows <- match(coords$id[!duplicated(grob_id)], data$map_id)
data <- data[data_rows, , drop = FALSE]
grid::polygonGrob(coords$x, coords$y, default.units = "native", id = grob_id,
gp = gpar(
col = data$colour, fill = alpha(data$fill, data$alpha),
lwd = data$size * .pt
)
)
},
optional_aes = c("x", "y"),
required_aes = c("map_id")
)

62
R/geom_dumbbell.R

@ -14,12 +14,15 @@
#' often aesthetics, used to set an aesthetic to a fixed value, like
#' \code{color = "red"} or \code{size = 3}. They may also be parameters
#' to the paired geom/stat.
#' @param size_x the size of the start point
#' @param colour_x the colour of the start point
#' @param size_xend the size of the end point
#' @param colour_xend the colour of the end point
#' @param size_x,size_xend the size of the x/xend; defaults to 0.5
#' @param colour_x,colour_xend the colour of x/xend; defaults to colour aes
#' @param shape_x,shape_xend shape to use for x/xend; defaults to 19
#' @param fill_x,fill_xend fill for x/xend if the shape is hollow; defaults to fill aes
#' @param dot_guide if \code{TRUE}, a leading dotted line will be placed before the left-most dumbbell point
#' @param dot_guide_size,dot_guide_colour singe-value aesthetics for \code{dot_guide}
#' @param dot_guide_size,dot_guide_colour singe-value ahesthetics for \code{dot_guide}
#' @param jitter_on_equal_values numeric value [0..1], default is 0. If non-zero and if both
#' values are equal, jitter the points vertically by the amount specified so
#' they don't fully overlap.
#' @param position Position adjustment, either as a string, or the result of a
#' call to a position adjustment function.
#' @inheritParams ggplot2::layer
@ -27,7 +30,11 @@
#' @examples
#' library(ggplot2)
#'
#' df <- data.frame(trt=LETTERS[1:5], l=c(20, 40, 10, 30, 50), r=c(70, 50, 30, 60, 80))
#' data.frame(
#' trt = factor(LETTERS[1:5], levels = LETTERS[5:1]),
#' l = c(20, 40, 30, 30, 50),
#' r = c(70, 50, 10, 60, 80)
#' ) -> df
#'
#' ggplot(df, aes(y=trt, x=l, xend=r)) +
#' geom_dumbbell(size=3, color="#e3e2e1",
@ -37,6 +44,14 @@
#' theme_minimal() +
#' theme(panel.grid.major.x=element_line(size=0.05))
#'
#' ggplot(df, aes(y=trt, x=l, xend=r)) +
#' geom_dumbbell(size=3, color="#e3e2e1",
#' colour_x = "#5b8124", colour_xend = "#bad744", shape_x = 15,
#' dot_guide=TRUE, dot_guide_size=0.25) +
#' labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") +
#' theme_minimal() +
#' theme(panel.grid.major.x=element_line(size=0.05))
#'
#' ## with vertical dodging
#' df2 <- data.frame(trt = c(LETTERS[1:5], "D"),
#' l = c(20, 40, 10, 30, 50, 40),
@ -51,10 +66,10 @@
#' theme_minimal() +
#' theme(panel.grid.major.x=element_line(size=0.05))
geom_dumbbell <- function(mapping = NULL, data = NULL, ...,
colour_x = NULL, size_x = NULL,
colour_xend = NULL, size_xend = NULL,
colour_x = NULL, size_x = NULL, shape_x = NULL, fill_x = NULL,
colour_xend = NULL, size_xend = NULL, shape_xend = NULL, fill_xend = NULL,
dot_guide = FALSE, dot_guide_size = NULL,
dot_guide_colour = NULL,
dot_guide_colour = NULL, jitter_on_equal_values = 0,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,
position = "identity") {
@ -70,11 +85,16 @@ geom_dumbbell <- function(mapping = NULL, data = NULL, ...,
na.rm = na.rm,
colour_x = colour_x,
size_x = size_x,
shape_x = shape_x,
fill_x = fill_x,
colour_xend = colour_xend,
size_xend = size_xend,
shape_xend = shape_xend,
fill_xend = fill_xend,
dot_guide = dot_guide,
dot_guide_size = dot_guide_size,
dot_guide_colour = dot_guide_colour,
jitter_on_equal_values = jitter_on_equal_values,
...
)
)
@ -87,37 +107,46 @@ geom_dumbbell <- function(mapping = NULL, data = NULL, ...,
GeomDumbbell <- ggproto("GeomDumbbell", Geom,
required_aes = c("x", "xend", "y"),
non_missing_aes = c("size", "shape",
"colour_x", "size_x",
"colour_xend", "size_xend",
"dot_guide", "dot_guide_size", "dot_guide_colour"),
"colour_x", "size_x", "shape_x", "fill_x",
"colour_xend", "size_xend", "shape_xend", "fill_xend",
"dot_guide", "dot_guide_size", "dot_guide_colour",
"jitter_on_equal_values"),
default_aes = aes(
shape = 19, colour = "black", size = 0.5, fill = NA,
alpha = NA, stroke = 0.5
),
setup_data = function(data, params) {
transform(data, yend = y)
transform(data, point_y = y, yend = y, dot_yend = y)
},
draw_group = function(data, panel_scales, coord,
colour_x = NULL, size_x = NULL,
colour_xend = NULL, size_xend = NULL,
colour_x = NULL, size_x = NULL, shape_x = NULL, fill_x = NULL,
colour_xend = NULL, size_xend = NULL, shape_xend = NULL, fill_xend = NULL,
dot_guide = NULL, dot_guide_size = NULL,
dot_guide_colour = NULL) {
dot_guide_colour = NULL, jitter_on_equal_values) {
points.x <- data
points.x$y <- points.x$point_y
points.x$colour <- colour_x %||% data$colour
points.x$fill <- fill_x %||% data$fill
points.x$shape <- shape_x %||% 19
points.x$xend <- NULL
points.x$size <- size_x %||% (data$size * 1.2)
points.xend <- data
points.xend.y <- points.xend$yend
points.xend$x <- points.xend$xend
points.xend$colour <- colour_xend %||% data$colour
points.xend$fill <- fill_xend %||% data$fill
points.xend$xend <- NULL
points.xend$shape <- shape_xend %||% 19
points.xend$colour <- colour_xend %||% data$colour
points.xend$size <- size_xend %||% (data$size * 1.25)
dot_df <- data
dot_df$xend <- ifelse(data$xend < data$x, data$xend, data$x)
dot_df$yend <- dot_df$dot_yend
dot_df$x <- -Inf
dot_df$linetype <- "11"
dot_df$size <- dot_guide_size %||% (data$size * 0.5)
@ -145,6 +174,7 @@ GeomDumbbell <- ggproto("GeomDumbbell", Geom,
},
draw_key = draw_key_point
)

9
R/ggalt-package.r

@ -6,15 +6,12 @@
#' @name ggalt
#' @docType package
#' @author Bob Rudis (@@hrbrmstr)
#' @import maps ggplot2 graphics grDevices KernSmooth proj4 ash MASS
#' @importFrom dplyr filter
#' @import ggplot2 graphics grDevices KernSmooth ash MASS utils
#' @importFrom scales rescale expand_range comma
#' @importFrom grid grobName grobTree unit.c grobHeight grobWidth viewport
#' grid.draw grobX grobY gTree gList textGrob gpar pointsGrob
#' segmentsGrob polygonGrob
#' grid.draw grobX grobY gTree gList textGrob gpar pointsGrob
#' segmentsGrob polygonGrob
#' @importFrom gtable gtable_col gtable_height gtable_width gtable_row gtable_col
#' @importFrom RColorBrewer brewer.pal
#' @importFrom extrafont loadfonts fonts ttf_import
#' @import utils
#' @importFrom tibble as_tibble
NULL

41
R/position-jitter-on-equal.R

@ -0,0 +1,41 @@
#' Jitter points to avoid overplotting
#'
#' Designed primarily for [geom_dumbbell()] to jitter the second point vertically
#' when both x values are equal.
#'
#' @family position adjustments
#' @param amount Amount of vertical jitter (0..1)
#' @export
position_jitter_on_equal <- function(amount = 0) {
ggproto(
NULL,
PositionJitterOnEqual,
amount = amount
)
}
#' @rdname ggplot2-ggproto
#' @format NULL
#' @usage NULL
#' @export
PositionJitterOnEqual <- ggproto(
"PositionJitterOnEqual", Position,
required_aes = c("x", "y"),
setup_params = function(self, data) {
list(
amount = self$amount
)
},
compute_layer = function(self, data, params, layout) {
data[data$x == data$xend,]$point_y <-
data[data$x == data$xend,]$point_y + (data[data$x == data$xend,]$point_y * params$amount)
data
}
)

14
README.Rmd

@ -22,7 +22,6 @@ The following functions are implemented:
- `geom_ubar` : Uniform width bar charts
- `geom_horizon` : Horizon charts (modified from <https://github.com/AtherEnergy/ggTimeSeries>)
- `coord_proj` : Like `coord_map`, only better (prbly shld use this with `geom_cartogram` as `geom_map`'s new defaults are ugh)
- `geom_xspline` : Connect control points/observations with an X-spline
- `stat_xspline` : Connect control points/observations with an X-spline
- `geom_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`)
@ -223,19 +222,6 @@ m + stat_bkde2d(bandwidth=c(0.5, 4), aes(fill = ..level..), geom = "polygon")
```
### `coord_proj` LIVES! (still needs a teensy bit of work)
```{r coord_proj}
world <- map_data("world")
world <- world[world$region != "Antarctica",]
gg <- ggplot()
gg <- gg + geom_cartogram(data=world, map=world,
aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj("+proj=wintri")
gg
```
### ProPublica StateFace
```{r stateface}

32
README.md

@ -26,9 +26,6 @@ The following functions are implemented:
- `geom_horizon` : Horizon charts (modified from
<https://github.com/AtherEnergy/ggTimeSeries>)
- `coord_proj` : Like `coord_map`, only better (prbly shld use this
with `geom_cartogram` as `geom_map`’s new defaults are ugh)
- `geom_xspline` : Connect control points/observations with an
X-spline
@ -86,10 +83,17 @@ install.packages("ggalt")
library(ggplot2)
library(gridExtra)
library(ggalt)
## Registered S3 methods overwritten by 'ggalt':
## method from
## grid.draw.absoluteGrob ggplot2
## grobHeight.absoluteGrob ggplot2
## grobWidth.absoluteGrob ggplot2
## grobX.absoluteGrob ggplot2
## grobY.absoluteGrob ggplot2
# current verison
packageVersion("ggalt")
## [1] '0.6.1'
## [1] '0.7.0'
set.seed(1492)
dat <- data.frame(x=c(1:10, 1:10, 1:10),
@ -350,26 +354,6 @@ m + stat_bkde2d(bandwidth=c(0.5, 4), aes(fill = ..level..), geom = "polygon")
<img src="README_figs/README-bkde2d-2.png" width="672" />
### `coord_proj` LIVES\! (still needs a teensy bit of work)
``` r
world <- map_data("world")
##
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
##
## map
world <- world[world$region != "Antarctica",]
gg <- ggplot()
gg <- gg + geom_cartogram(data=world, map=world,
aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj("+proj=wintri")
gg
```
<img src="README_figs/README-coord_proj-1.png" width="672" />
### ProPublica StateFace
``` r

BIN
README_figs/README-annoticks-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

BIN
README_figs/README-annoticks-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

BIN
README_figs/README-annoticks-3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

BIN
README_figs/README-bkde2d-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 KiB

After

Width:  |  Height:  |  Size: 235 KiB

BIN
README_figs/README-bkde2d-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 112 KiB

BIN
README_figs/README-bkde_ash-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

BIN
README_figs/README-bkde_ash-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

BIN
README_figs/README-bkde_ash-3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

BIN
README_figs/README-bkde_ash-4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

BIN
README_figs/README-bkde_ash-5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

BIN
README_figs/README-bkde_ash-6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 73 KiB

BIN
README_figs/README-bkde_ash-7.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 88 KiB

BIN
README_figs/README-bkde_ash-8.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 85 KiB

BIN
README_figs/README-dumbbell-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 120 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
README_figs/README-dumbbell2-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 37 KiB

BIN
README_figs/README-encircle-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 48 KiB

BIN
README_figs/README-encircle-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 57 KiB

BIN
README_figs/README-encircle-3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 61 KiB

BIN
README_figs/README-encircle-4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 53 KiB

BIN
README_figs/README-encircle-5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 46 KiB

BIN
README_figs/README-encircle-6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

BIN
README_figs/README-encircle-7.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

BIN
README_figs/README-horizon-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 795 KiB

After

Width:  |  Height:  |  Size: 809 KiB

BIN
README_figs/README-lollipop-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

After

Width:  |  Height:  |  Size: 147 KiB

BIN
README_figs/README-spikelines-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 136 KiB

BIN
README_figs/README-splines-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 120 KiB

BIN
README_figs/README-splines-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 140 KiB

BIN
README_figs/README-splines-3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 147 KiB

BIN
README_figs/README-splines-4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 146 KiB

BIN
README_figs/README-splines-5.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 142 KiB

BIN
README_figs/README-splines-6.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 137 KiB

BIN
README_figs/README-splines-7.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 144 KiB

BIN
README_figs/README-splines-8.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 148 KiB

BIN
README_figs/README-stateface-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 109 KiB

BIN
README_figs/README-stepribbon-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

BIN
README_figs/README-stepribbon-2.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 38 KiB

10
man/absoluteGrob.Rd

@ -4,8 +4,14 @@
\alias{absoluteGrob}
\title{Absolute grob}
\usage{
absoluteGrob(grob, width = NULL, height = NULL, xmin = NULL,
ymin = NULL, vp = NULL)
absoluteGrob(
grob,
width = NULL,
height = NULL,
xmin = NULL,
ymin = NULL,
vp = NULL
)
}
\description{
This grob has fixed dimensions and position.

22
man/annotate_textp.Rd

@ -4,10 +4,22 @@
\alias{annotate_textp}
\title{Text annotations in plot coordinate system}
\usage{
annotate_textp(label, x, y, facets = NULL, hjust = 0, vjust = 0,
color = "black", alpha = NA, family = theme_get()$text$family,
size = theme_get()$text$size, fontface = 1, lineheight = 1,
box_just = ifelse(c(x, y) < 0.5, 0, 1), margin = unit(size/2, "pt"))
annotate_textp(
label,
x,
y,
facets = NULL,
hjust = 0,
vjust = 0,
color = "black",
alpha = NA,
family = theme_get()$text$family,
size = theme_get()$text$size,
fontface = 1,
lineheight = 1,
box_just = ifelse(c(x, y) < 0.5, 0, 1),
margin = unit(size/2, "pt")
)
}
\arguments{
\item{label}{text annotation to be placed on the plot}
@ -39,5 +51,5 @@ instead of data coordinates.
\examples{
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p <- p + geom_smooth(method = "lm", se = FALSE)
p + annotate_textp(x = 0.9, y = 0.35, label="A relative linear\\nrelationship", hjust=1, color="red")
p + annotate_textp(x = 0.9, y = 0.35, label="A relative linear\nrelationship", hjust=1, color="red")
}

19
man/annotation_ticks.Rd

@ -4,10 +4,21 @@
\alias{annotation_ticks}
\title{Annotation: tick marks}
\usage{
annotation_ticks(sides = "b", scale = "identity", scaled = TRUE,
short = unit(0.1, "cm"), mid = unit(0.2, "cm"), long = unit(0.3,
"cm"), colour = "black", size = 0.5, linetype = 1, alpha = 1,
color = NULL, ticks_per_base = NULL, ...)
annotation_ticks(
sides = "b",
scale = "identity",
scaled = TRUE,
short = unit(0.1, "cm"),
mid = unit(0.2, "cm"),
long = unit(0.3, "cm"),
colour = "black",
size = 0.5,
linetype = 1,
alpha = 1,
color = NULL,
ticks_per_base = NULL,
...
)
}
\arguments{
\item{sides}{a string that controls which sides of the plot the log ticks appear on.

3
man/byte_format.Rd

@ -16,8 +16,7 @@ Mb(x)
Gb(x)
bytes(x, symbol = "auto", units = c("binary", "si"),
only_highest = FALSE)
bytes(x, symbol = "auto", units = c("binary", "si"), only_highest = FALSE)
}
\arguments{
\item{symbol}{byte symbol to use. If "\code{auto}" the symbol used will be

88
man/coord_proj.Rd

@ -1,88 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coord_proj.r
\name{coord_proj}
\alias{coord_proj}
\title{Similar to \code{coord_map} but uses the PROJ.4 library/package for projection
transformation}
\usage{
coord_proj(proj = NULL, inverse = FALSE, degrees = TRUE,
ellps.default = "sphere", xlim = NULL, ylim = NULL)
}
\arguments{
\item{proj}{projection definition. If left \code{NULL} will default to
a Robinson projection}
\item{inverse}{if \code{TRUE} inverse projection is performed (from a
cartographic projection into lat/long), otherwise projects from
lat/long into a cartographic projection.}
\item{degrees}{if \code{TRUE} then the lat/long data is assumed to be in
degrees, otherwise in radians}
\item{ellps.default}{default ellipsoid that will be added if no datum or
ellipsoid parameter is specified in proj. Older versions of PROJ.4
didn't require a datum (and used sphere by default), but 4.5.0 and
higher always require a datum or an ellipsoid. Set to \code{NA} if no
datum should be added to proj (e.g. if you specify an ellipsoid
directly).}
\item{xlim}{manually specify x limits (in degrees of longitude)}
\item{ylim}{manually specify y limits (in degrees of latitude)}
}
\description{
The representation of a portion of the earth, which is approximately
spherical, onto a flat 2D plane requires a projection. This is what
\code{coord_proj} does, using the \code{proj4::project()} function from
the \code{proj4} package.
}
\details{
\if{html}{
A sample of the output from \code{coord_proj()} using the Winkel-Tripel projection:
\figure{coordproj01.png}{options: width="100\%" alt="Figure: coordproj01.png"}
}
\if{latex}{
A sample of the output from \code{coord_proj()} using the Winkel-Tripel projection:
``
\figure{coordproj01.png}{options: width=10cm}
}
}
\note{
It is recommended that you use \code{geom_cartogram} with this coordinate system
When \code{inverse} is \code{FALSE} \code{coord_proj} makes a fairly
large assumption that the coordinates being transformed are within
-180:180 (longitude) and -90:90 (latitude). As such, it truncates
all longitude & latitude input to fit within these ranges. More updates
to this new \code{coord_} are planned.
}
\examples{
\dontrun{
# World in Winkel-Tripel
# U.S.A. Albers-style
usa <- world[world$region == "USA",]
usa <- usa[!(usa$subregion \%in\% c("Alaska", "Hawaii")),]
gg <- ggplot()
gg <- gg + geom_cartogram(data=usa, map=usa,
aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj(
paste0("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96",
" +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"))
gg
# Showcase Greenland (properly)
greenland <- world[world$region == "Greenland",]
gg <- ggplot()
gg <- gg + geom_cartogram(data=greenland, map=greenland,
aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj(
paste0("+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0",
" +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))
gg
}
}

53
man/geom_bkde.Rd

@ -5,19 +5,39 @@
\alias{stat_bkde}
\title{Display a smooth density estimate.}
\usage{
geom_bkde(mapping = NULL, data = NULL, stat = "bkde",
position = "identity", bandwidth = NULL, range.x = NULL,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...)
stat_bkde(mapping = NULL, data = NULL, geom = "area",
position = "stack", kernel = "normal", canonical = FALSE,
bandwidth = NULL, gridsize = 410, range.x = NULL,
truncate = TRUE, na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE, ...)
geom_bkde(
mapping = NULL,
data = NULL,
stat = "bkde",
position = "identity",
bandwidth = NULL,
range.x = NULL,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
stat_bkde(
mapping = NULL,
data = NULL,
geom = "area",
position = "stack",
kernel = "normal",
canonical = FALSE,
bandwidth = NULL,
gridsize = 410,
range.x = NULL,
truncate = TRUE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -25,15 +45,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{position}{Position adjustment, either as a string, or the result of
a call to a position adjustment function.}
@ -58,9 +79,9 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}

57
man/geom_bkde2d.Rd

@ -5,20 +5,42 @@
\alias{stat_bkde2d}
\title{Contours from a 2d density estimate.}
\usage{
geom_bkde2d(mapping = NULL, data = NULL, stat = "bkde2d",
position = "identity", bandwidth = NULL, range.x = NULL,
lineend = "butt", contour = TRUE, linejoin = "round",
linemitre = 1, na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE, ...)
stat_bkde2d(mapping = NULL, data = NULL, geom = "density2d",
position = "identity", contour = TRUE, bandwidth = NULL,
grid_size = c(51, 51), range.x = NULL, truncate = TRUE,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...)
geom_bkde2d(
mapping = NULL,
data = NULL,
stat = "bkde2d",
position = "identity",
bandwidth = NULL,
range.x = NULL,
lineend = "butt",
contour = TRUE,
linejoin = "round",
linemitre = 1,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
stat_bkde2d(
mapping = NULL,
data = NULL,
geom = "density2d",
position = "identity",
contour = TRUE,
bandwidth = NULL,
grid_size = c(51, 51),
range.x = NULL,
truncate = TRUE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -26,15 +48,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{stat}{The statistical transformation to use on the data for this
layer, as a string.}
@ -72,9 +95,9 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}

132
man/geom_cartogram.Rd

@ -1,132 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geom_cartogram.r
\name{geom_cartogram}
\alias{geom_cartogram}
\title{Map polygons layer enabling the display of show statistical information}
\usage{
geom_cartogram(mapping = NULL, data = NULL, stat = "identity", ...,
map, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
\item{data}{The data to be displayed in this layer. There are three
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
\item{stat}{The statistical transformation to use on the data for this
layer, as a string.}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
\item{map}{Data frame that contains the map coordinates. This will
typically be created using \code{\link{fortify}} on a spatial object.
It must contain columns \code{x}, \code{long} or \code{longitude},
\code{y}, \code{lat} or \code{latitude} and \code{region} or \code{id}.}
\item{na.rm}{If \code{FALSE}, the default, missing values are removed with
a warning. If \code{TRUE}, missing values are silently removed.}
\item{show.legend}{logical. Should this layer be included in the legends?
\code{NA}, the default, includes if any aesthetics are mapped.
\code{FALSE} never includes, and \code{TRUE} always includes.
It can also be a named logical vector to finely select the aesthetics to
display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
}
\description{
This replicates the old behaviour of \code{geom_map()}, enabling specifying of
\code{x} and \code{y} aesthetics.
}
\section{Aesthetics}{
\code{geom_cartogram} understands the following aesthetics (required aesthetics are in bold):
\itemize{
\item \code{map_id}
\item \code{alpha}
\item \code{colour}
\item \code{fill}
\item \code{group}
\item \code{linetype}
\item \code{size}
\item \code{x}
\item \code{y}
}
}
\examples{
\dontrun{
# When using geom_polygon, you will typically need two data frames:
# one contains the coordinates of each polygon (positions), and the
# other the values associated with each polygon (values). An id
# variable links the two together
ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))
values <- data.frame(
id = ids,
value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5)
)
positions <- data.frame(
id = rep(ids, each = 4),
x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3),
y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2)
)
ggplot() +
geom_cartogram(aes(x, y, map_id = id), map = positions, data=positions)
ggplot() +
geom_cartogram(aes(x, y, map_id = id), map = positions, data=positions) +
geom_cartogram(data=values, map=positions, aes(fill = value, map_id=id))
ggplot() +
geom_cartogram(aes(x, y, map_id = id), map = positions, data=positions) +
geom_cartogram(data=values, map=positions, aes(fill = value, map_id=id)) +
ylim(0, 3)
# Better example
crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
crimesm <- reshape2::melt(crimes, id = 1)
if (require(maps)) {
states_map <- map_data("state")
ggplot() +
geom_cartogram(aes(long, lat, map_id = region), map = states_map, data=states_map) +
geom_cartogram(aes(fill = Murder, map_id = state), map=states_map, data=crimes)
last_plot() + coord_map("polyconic")
ggplot() +
geom_cartogram(aes(long, lat, map_id=region), map = states_map, data=states_map) +
geom_cartogram(aes(fill = value, map_id=state), map = states_map, data=crimesm) +
coord_map("polyconic") +
facet_wrap( ~ variable)
}
}
}

67
man/geom_dumbbell.Rd

@ -4,15 +4,31 @@
\alias{geom_dumbbell}
\title{Dumbbell charts}
\usage{
geom_dumbbell(mapping = NULL, data = NULL, ..., colour_x = NULL,
size_x = NULL, colour_xend = NULL, size_xend = NULL,
dot_guide = FALSE, dot_guide_size = NULL, dot_guide_colour = NULL,
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE,
position = "identity")
geom_dumbbell(
mapping = NULL,
data = NULL,
...,
colour_x = NULL,
size_x = NULL,
shape_x = NULL,
fill_x = NULL,
colour_xend = NULL,
size_xend = NULL,
shape_xend = NULL,
fill_xend = NULL,
dot_guide = FALSE,
dot_guide_size = NULL,
dot_guide_colour = NULL,
jitter_on_equal_values = 0,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
position = "identity"
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -20,32 +36,37 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{...}{other arguments passed on to \code{\link{layer}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{color = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
\item{colour_x}{the colour of the start point}
\item{colour_x, colour_xend}{the colour of x/xend; defaults to colour aes}
\item{size_x}{the size of the start point}
\item{size_x, size_xend}{the size of the x/xend; defaults to 0.5}
\item{colour_xend}{the colour of the end point}
\item{shape_x, shape_xend}{shape to use for x/xend; defaults to 19}
\item{size_xend}{the size of the end point}
\item{fill_x, fill_xend}{fill for x/xend if the shape is hollow; defaults to fill aes}
\item{dot_guide}{if \code{TRUE}, a leading dotted line will be placed before the left-most dumbbell point}
\item{dot_guide_size, dot_guide_colour}{singe-value aesthetics for \code{dot_guide}}
\item{dot_guide_size, dot_guide_colour}{singe-value ahesthetics for \code{dot_guide}}
\item{jitter_on_equal_values}{numeric value [0..1], default is 0. If non-zero and if both
values are equal, jitter the points vertically by the amount specified so
they don't fully overlap.}
\item{na.rm}{If \code{FALSE} (the default), removes missing values with
a warning. If \code{TRUE} silently removes missing values.}
@ -59,7 +80,7 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{position}{Position adjustment, either as a string, or the result of a
call to a position adjustment function.}
@ -79,7 +100,11 @@ alternative to the clustered bar chart or slope graph.
\examples{
library(ggplot2)
df <- data.frame(trt=LETTERS[1:5], l=c(20, 40, 10, 30, 50), r=c(70, 50, 30, 60, 80))
data.frame(
trt = factor(LETTERS[1:5], levels = LETTERS[5:1]),
l = c(20, 40, 30, 30, 50),
r = c(70, 50, 10, 60, 80)
) -> df
ggplot(df, aes(y=trt, x=l, xend=r)) +
geom_dumbbell(size=3, color="#e3e2e1",
@ -89,6 +114,14 @@ ggplot(df, aes(y=trt, x=l, xend=r)) +
theme_minimal() +
theme(panel.grid.major.x=element_line(size=0.05))
ggplot(df, aes(y=trt, x=l, xend=r)) +
geom_dumbbell(size=3, color="#e3e2e1",
colour_x = "#5b8124", colour_xend = "#bad744", shape_x = 15,
dot_guide=TRUE, dot_guide_size=0.25) +
labs(x=NULL, y=NULL, title="ggplot2 geom_dumbbell with dot guide") +
theme_minimal() +
theme(panel.grid.major.x=element_line(size=0.05))
## with vertical dodging
df2 <- data.frame(trt = c(LETTERS[1:5], "D"),
l = c(20, 40, 10, 30, 50, 40),

13
man/geom_encircle.Rd

@ -4,9 +4,16 @@
\alias{geom_encircle}
\title{Automatically enclose points in a polygon}
\usage{
geom_encircle(mapping = NULL, data = NULL, stat = "identity",
position = "identity", na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE, ...)
geom_encircle(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
}
\arguments{
\item{mapping}{mapping}

30
man/geom_horizon.Rd

@ -7,16 +7,34 @@
\alias{stat_horizon}
\alias{StatHorizon}
\title{Plot a time series as a horizon plot}
\format{An object of class \code{GeomHorizon} (inherits from \code{GeomArea}, \code{GeomRibbon}, \code{Geom}, \code{ggproto}, \code{gg}) of length 4.}
\format{
An object of class \code{GeomHorizon} (inherits from \code{GeomArea}, \code{GeomRibbon}, \code{Geom}, \code{ggproto}, \code{gg}) of length 4.
An object of class \code{StatHorizon} (inherits from \code{Stat}, \code{ggproto}, \code{gg}) of length 5.
}
\usage{
geom_horizon(mapping = NULL, data = NULL, show.legend = TRUE,
inherit.aes = TRUE, na.rm = TRUE, bandwidth = NULL, ...)
geom_horizon(
mapping = NULL,
data = NULL,
show.legend = TRUE,
inherit.aes = TRUE,
na.rm = TRUE,
bandwidth = NULL,
...
)
GeomHorizon
stat_horizon(mapping = NULL, data = NULL, geom = "horizon",
show.legend = TRUE, inherit.aes = TRUE, na.rm = TRUE,
bandwidth = NULL, ...)
stat_horizon(
mapping = NULL,
data = NULL,
geom = "horizon",
show.legend = TRUE,
inherit.aes = TRUE,
na.rm = TRUE,
bandwidth = NULL,
...
)
StatHorizon
}

27
man/geom_lollipop.Rd

@ -4,13 +4,21 @@
\alias{geom_lollipop}
\title{Lollipop charts}
\usage{
geom_lollipop(mapping = NULL, data = NULL, ..., horizontal = FALSE,
point.colour = NULL, point.size = NULL, na.rm = FALSE,
show.legend = NA, inherit.aes = TRUE)
geom_lollipop(
mapping = NULL,
data = NULL,
...,
horizontal = FALSE,
point.colour = NULL,
point.size = NULL,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -18,15 +26,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{...}{other arguments passed on to \code{\link{layer}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
@ -56,7 +65,7 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
}
\description{
The lollipop geom is used to create lollipop charts.

32
man/geom_spikelines.Rd

@ -4,14 +4,23 @@
\alias{geom_spikelines}
\title{Draw spikelines on a plot}
\usage{
geom_spikelines(mapping = NULL, data = NULL, stat = "identity",
position = "identity", ..., arrow = NULL, lineend = "butt",
linejoin = "round", na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE)
geom_spikelines(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
arrow = NULL,
lineend = "butt",
linejoin = "round",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -19,15 +28,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{stat}{The statistical transformation to use on the data for this
layer, as a string.}
@ -35,7 +45,7 @@ layer, as a string.}
\item{position}{Position adjustment, either as a string, or the result of
a call to a position adjustment function.}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
@ -58,7 +68,7 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
}
\description{
Segment reference lines that originate at an point

45
man/geom_stateface.Rd

@ -4,14 +4,24 @@
\alias{geom_stateface}
\title{Use ProPublica's StateFace font in ggplot2 plots}
\usage{
geom_stateface(mapping = NULL, data = NULL, stat = "identity",
position = "identity", ..., parse = FALSE, nudge_x = 0,
nudge_y = 0, check_overlap = FALSE, na.rm = FALSE,
show.legend = NA, inherit.aes = TRUE)
geom_stateface(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
parse = FALSE,
nudge_x = 0,
nudge_y = 0,
check_overlap = FALSE,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -19,23 +29,25 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{stat}{The statistical transformation to use on the data for this
layer, as a string.}
\item{position}{Position adjustment, either as a string, or the result of
a call to a position adjustment function.}
a call to a position adjustment function. Cannot be jointy specified with
\code{nudge_x} or \code{nudge_y}.}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
@ -48,7 +60,9 @@ abels by. Useful for offsetting text from points, particularly
on discrete scales.}
\item{check_overlap}{If \code{TRUE}, text that overlaps previous text in the
same layer will not be plotted.}
same layer will not be plotted. \code{check_overlap} happens at draw time and in
the order of the data. Therefore data should be arranged by the label
column before calling \code{geom_label()} or \code{geom_text()}.}
\item{na.rm}{If \code{FALSE}, the default, missing values are removed with
a warning. If \code{TRUE}, missing values are silently removed.}
@ -62,7 +76,7 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
}
\description{
The \code{label} parameter can be either a 2-letter state abbreviation
@ -113,7 +127,8 @@ gg
}
}
\seealso{
Other StateFace operations: \code{\link{load_stateface}},
\code{\link{show_stateface}}
Other StateFace operations:
\code{\link{load_stateface}()},
\code{\link{show_stateface}()}
}
\concept{StateFace operations}

26
man/geom_ubar.Rd

@ -4,13 +4,20 @@
\alias{geom_ubar}
\title{Uniform "bar" charts}
\usage{
geom_ubar(mapping = NULL, data = NULL, stat = "identity",
position = "identity", ..., na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE)
geom_ubar(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -18,15 +25,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{stat}{The statistical transformation to use on the data for this
layer, as a string.}
@ -51,7 +59,7 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
}
\description{
I've been using \code{geom_segment} more to make "bar" charts, setting

54
man/geom_xspline.Rd

@ -5,19 +5,37 @@
\alias{stat_xspline}
\title{Connect control points/observations with an X-spline}
\usage{
geom_xspline(mapping = NULL, data = NULL, stat = "xspline",
position = "identity", na.rm = TRUE, show.legend = NA,
inherit.aes = TRUE, spline_shape = -0.25, open = TRUE,
rep_ends = TRUE, ...)
stat_xspline(mapping = NULL, data = NULL, geom = "line",
position = "identity", na.rm = TRUE, show.legend = NA,
inherit.aes = TRUE, spline_shape = -0.25, open = TRUE,
rep_ends = TRUE, ...)
geom_xspline(
mapping = NULL,
data = NULL,
stat = "xspline",
position = "identity",
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE,
spline_shape = -0.25,
open = TRUE,
rep_ends = TRUE,
...
)
stat_xspline(
mapping = NULL,
data = NULL,
geom = "line",
position = "identity",
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE,
spline_shape = -0.25,
open = TRUE,
rep_ends = TRUE,
...
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -25,15 +43,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{position}{Position adjustment, either as a string, or the result of
a call to a position adjustment function.}
@ -50,7 +69,7 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{spline_shape}{A numeric vector of values between -1 and 1, which
control the shape of the spline relative to the control points.}
@ -62,7 +81,7 @@ closed shape.}
first and last control points should be replicated for drawing the
curve. Ignored for closed X-splines.}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
@ -193,6 +212,7 @@ Blanc, C. and Schlick, C. (1995), "X-splines : A Spline Model
\code{\link[graphics]{xspline}};
\code{\link[grid]{grid.xspline}}
Other xspline implementations: \code{\link{geom_xspline2}}
Other xspline implementations:
\code{\link{geom_xspline2}()}
}
\concept{xspline implementations}

31
man/geom_xspline2.Rd

@ -5,13 +5,20 @@
\title{Alternative implemenation for connecting control points/observations
with an X-spline}
\usage{
geom_xspline2(mapping = NULL, data = NULL, stat = "identity",
position = "identity", na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE, ...)
geom_xspline2(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -19,15 +26,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{stat}{Use to override the default connection between
\code{geom_xspline} and \code{stat_xspline}.}
@ -47,9 +55,9 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}
@ -62,7 +70,8 @@ Alternative implemenation for connecting control points/observations
with an X-spline
}
\seealso{
Other xspline implementations: \code{\link{geom_xspline}}
Other xspline implementations:
\code{\link{geom_xspline}()}
}
\author{
Ben Bolker

9
man/ggalt-ggproto.Rd

@ -1,11 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/coord_proj.r, R/geom_ash.r, R/geom_bkde.r,
% R/geom_bkde2d.r, R/geom_spikelines.R, R/geom_dumbbell.R, R/geom_encircle.r,
% Please edit documentation in R/geom_ash.r, R/geom_bkde.r, R/geom_bkde2d.r,
% R/geom_spikelines.R, R/geom_dumbbell.R, R/geom_encircle.r,
% R/geom_lollipop.r, R/geom_xspline.r, R/geom_xspline2.r, R/geom_ubar.r,
% R/stat-stepribbon.r, R/stateface.r
\docType{data}
\name{CoordProj}
\alias{CoordProj}
\name{StatAsh}
\alias{StatAsh}
\alias{GeomBkde}
\alias{StatBkde}
@ -30,8 +29,6 @@ Geom Proto
Geom Proto
Geom Proto
Geom Proto
}
\references{
\url{https://groups.google.com/forum/?fromgroups=#!topic/ggplot2/9cFWHaH1CPs}

1
man/ggalt.Rd

@ -3,7 +3,6 @@
\docType{package}
\name{ggalt}
\alias{ggalt}
\alias{ggalt-package}
\title{Extra Geoms, Stats, Coords, Scales & Fonts for 'ggplot2'}
\description{
A package containing additional geoms, coords, stats, scales & fonts

5
man/ggplot2-ggproto.Rd

@ -1,9 +1,10 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/annotation_ticks.r, R/geom_cartogram.r
% Please edit documentation in R/annotation_ticks.r,
% R/position-jitter-on-equal.R
\docType{data}
\name{GeomTicks}
\alias{GeomTicks}
\alias{GeomCartogram}
\alias{PositionJitterOnEqual}
\title{Base ggproto classes for ggplot2}
\description{
If you are creating a new geom, stat, position, or scale in another package,

5
man/load_stateface.Rd

@ -11,7 +11,8 @@ Makes the ProPublica StateFace font available to PDF, PostScript,
et. al. devices.
}
\seealso{
Other StateFace operations: \code{\link{geom_stateface}},
\code{\link{show_stateface}}
Other StateFace operations:
\code{\link{geom_stateface}()},
\code{\link{show_stateface}()}
}
\concept{StateFace operations}

16
man/position_jitter_on_equal.Rd

@ -0,0 +1,16 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/position-jitter-on-equal.R
\name{position_jitter_on_equal}
\alias{position_jitter_on_equal}
\title{Jitter points to avoid overplotting}
\usage{
position_jitter_on_equal(amount = 0)
}
\arguments{
\item{amount}{Amount of vertical jitter (0..1)}
}
\description{
Designed primarily for [geom_dumbbell()] to jitter the second point vertically
when both x values are equal.
}
\concept{position adjustments}

5
man/show_stateface.Rd

@ -12,7 +12,8 @@ in the on-screen plot device for ggplot2, you need to install
the font on your system
}
\seealso{
Other StateFace operations: \code{\link{geom_stateface}},
\code{\link{load_stateface}}
Other StateFace operations:
\code{\link{geom_stateface}()},
\code{\link{load_stateface}()}
}
\concept{StateFace operations}

32
man/stat_ash.Rd

@ -4,13 +4,24 @@
\alias{stat_ash}
\title{Compute and display a univariate averaged shifted histogram (polynomial kernel)}
\usage{
stat_ash(mapping = NULL, data = NULL, geom = "area",
position = "stack", ab = NULL, nbin = 50, m = 5, kopt = c(2,
2), na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...)
stat_ash(
mapping = NULL,
data = NULL,
geom = "area",
position = "stack",
ab = NULL,
nbin = 50,
m = 5,
kopt = c(2, 2),
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -18,15 +29,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{geom}{Use to override the default Geom}
@ -57,9 +69,9 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}

29
man/stat_stepribbon.Rd

@ -4,13 +4,21 @@
\alias{stat_stepribbon}
\title{Step ribbon statistic}
\usage{
stat_stepribbon(mapping = NULL, data = NULL, geom = "ribbon",
position = "identity", na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE, direction = "hv", ...)
stat_stepribbon(
mapping = NULL,
data = NULL,
geom = "ribbon",
position = "identity",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
direction = "hv",
...
)
}
\arguments{
\item{mapping}{Set of aesthetic mappings created by \code{\link[=aes]{aes()}} or
\code{\link[=aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
\item{mapping}{Set of aesthetic mappings created by \code{\link[ggplot2:aes]{aes()}} or
\code{\link[ggplot2:aes_]{aes_()}}. If specified and \code{inherit.aes = TRUE} (the
default), it is combined with the default mapping at the top level of the
plot. You must supply \code{mapping} if there is no plot mapping.}
@ -18,15 +26,16 @@ plot. You must supply \code{mapping} if there is no plot mapping.}
options:
If \code{NULL}, the default, the data is inherited from the plot
data as specified in the call to \code{\link[=ggplot]{ggplot()}}.
data as specified in the call to \code{\link[ggplot2:ggplot]{ggplot()}}.
A \code{data.frame}, or other object, will override the plot
data. All objects will be fortified to produce a data frame. See
\code{\link[=fortify]{fortify()}} for which variables will be created.
\code{\link[ggplot2:fortify]{fortify()}} for which variables will be created.
A \code{function} will be called with a single argument,
the plot data. The return value must be a \code{data.frame}, and
will be used as the layer data.}
will be used as the layer data. A \code{function} can be created
from a \code{formula} (e.g. \code{~ head(.x, 10)}).}
\item{geom}{which geom to use; defaults to "\code{ribbon}"}
@ -45,12 +54,12 @@ display.}
\item{inherit.aes}{If \code{FALSE}, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. \code{\link[=borders]{borders()}}.}
the default plot specification, e.g. \code{\link[ggplot2:borders]{borders()}}.}
\item{direction}{\code{hv} for horizontal-veritcal steps, \code{vh} for
vertical-horizontal steps}
\item{...}{Other arguments passed on to \code{\link[=layer]{layer()}}. These are
\item{...}{Other arguments passed on to \code{\link[ggplot2:layer]{layer()}}. These are
often aesthetics, used to set an aesthetic to a fixed value, like
\code{colour = "red"} or \code{size = 3}. They may also be parameters
to the paired geom/stat.}

Loading…
Cancel
Save