diff --git a/DESCRIPTION b/DESCRIPTION index d1d21a6..4973669 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,11 @@ Package: ggalt Title: Extra Coordinate Systems, 'Geoms', Statistical Transformations, Scales and Fonts for 'ggplot2' Version: 0.2.0.9000 +Maintainer: Bob Rudis Authors@R: c( person("Bob", "Rudis", email = "bob@rudis.net", role = c("aut", "cre")), + person("Ben", "Bolder", role = c("aut", "ctb")), + person("Jan", "Schulz", role = c("aut", "ctb")), person("Ingemar", role="dtc", comment="Pokémon javascript color palette"), person("ProPublica", role="dtc", comment="StateFace font") ) diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..3ddaf8f --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,73 @@ +# Generated by roxygen2: do not edit by hand + +S3method(grid.draw,absoluteGrob) +S3method(grobHeight,absoluteGrob) +S3method(grobWidth,absoluteGrob) +S3method(grobX,absoluteGrob) +S3method(grobY,absoluteGrob) +export(CoordProj) +export(Gb) +export(GeomBkde) +export(GeomBkde2d) +export(GeomEncircle) +export(GeomStateface) +export(GeomTable) +export(GeomXSpline2) +export(GeomXspline) +export(Kb) +export(Mb) +export(StatAsh) +export(StatBkde) +export(StatBkde2d) +export(StatXspline) +export(byte_format) +export(bytes) +export(coord_proj) +export(geom_bkde) +export(geom_bkde2d) +export(geom_encircle) +export(geom_stateface) +export(geom_xspline) +export(list_avatars) +export(load_stateface) +export(pokemon_pal) +export(scale_color_pokemon) +export(scale_colour_pokemon) +export(scale_fill_pokemon) +export(show_stateface) +export(stat_ash) +export(stat_bkde) +export(stat_bkde2d) +export(stat_xspline) +import(KernSmooth) +import(MASS) +import(ash) +import(ggplot2) +import(grDevices) +import(graphics) +import(maps) +import(proj4) +importFrom(RColorBrewer,brewer.pal) +importFrom(dplyr,filter) +importFrom(extrafont,fonts) +importFrom(extrafont,loadfonts) +importFrom(extrafont,ttf_import) +importFrom(grid,gList) +importFrom(grid,gTree) +importFrom(grid,gpar) +importFrom(grid,grid.draw) +importFrom(grid,grobHeight) +importFrom(grid,grobName) +importFrom(grid,grobTree) +importFrom(grid,grobWidth) +importFrom(grid,grobX) +importFrom(grid,grobY) +importFrom(grid,textGrob) +importFrom(grid,unit.c) +importFrom(grid,viewport) +importFrom(gtable,gtable_col) +importFrom(gtable,gtable_height) +importFrom(gtable,gtable_row) +importFrom(gtable,gtable_width) +importFrom(scales,expand_range) +importFrom(scales,rescale) diff --git a/NEWS b/NEWS index ffcb230..b3e937d 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 0.2.0 ===================== * Incorporated ProPublica StateFace font +* `geom_encircle()` contributed by Ben Bolker 0.1.5 ===================== diff --git a/R/geom_encircle.r b/R/geom_encircle.r index 2ea097c..a423aa0 100644 --- a/R/geom_encircle.r +++ b/R/geom_encircle.r @@ -1,3 +1,7 @@ +#' @rdname ggalt-ggproto +#' @format NULL +#' @usage NULL +#' @export GeomEncircle <- ggproto("GeomEncircle", Geom, required_aes = c("x", "y"), default_aes = aes(colour = "black", @@ -23,14 +27,14 @@ GeomEncircle <- ggproto("GeomEncircle", Geom, coords <- coords[ch,] ## FIXME: using grid:: a lot. importFrom instead? - + ## convert from lengths to physical units, for computing *directions* cc <- function(x,dir="x") grid::convertUnit(grid::unit(x,"native"),"mm",typeFrom="dimension", axisFrom=dir,valueOnly=TRUE) ## convert back to native (e.g. native + snpc offset) - cc_inv <- function(x,dir="x") + cc_inv <- function(x,dir="x") grid::convertUnit(x,"native",typeFrom="location", axisFrom=dir,valueOnly=TRUE) @@ -102,7 +106,7 @@ if (FALSE) { cc <- function(x,dir="x") grid::convertUnit(grid::unit(x,"native"),"mm",typeFrom="dimension", axisFrom=dir,valueOnly=TRUE) - cc_inv <- function(x,dir="x") + cc_inv <- function(x,dir="x") grid::convertUnit(x,"native",typeFrom="location", axisFrom=dir,valueOnly=TRUE) @@ -116,7 +120,7 @@ if (FALSE) { r <- sqrt(dx*dx+dy*dy) list(x=dx/r,y=dy/r) } - + dd <- c(rot %*% unlist(normFun(coords[1,],coords[2,])))* coords$spread z <- with(coords, { @@ -136,46 +140,54 @@ if (FALSE) { print(grid::convertWidth(unit(1,'npc'),'native')) print(grid::convertHeight(unit(1,'npc'),'native')) -} - - - -##' encircle -##' -##' @title encircle -##' @param mapping mapping -##' @param data data -##' @param stat stat -##' @param position position -##' @param na.rm na.rm -##' @param show.legend show.legend -##' @param inherit.aes inherit.aes -##' @param ... dots -##' @return adds a circle around the specified points -##' @author Ben Bolker -##' @export -##' @examples -##' d <- data.frame(x=c(1,1,2),y=c(1,2,2)*100) -##' (g0 <- ggplot(d,aes(x,y))+geom_point()+ -##' geom_encircle(s_shape=1,expand=0)+ -##' geom_encircle(s_shape=1,expand=0.1,colour="red")+ -##' scale_x_continuous(expand=c(0.5,1))+ -##' scale_y_continuous(expand=c(0.5,1))+ -##' geom_encircle(s_shape=0.5,expand=0.1,colour="purple")) -##' g0 + geom_encircle(data=subset(d,x==1),colour="blue",spread=0.02)+ -##' geom_encircle(data=subset(d,x==2),colour="cyan",spread=0.04) -##' -##' g0 <- ggplot(mpg, aes(displ, hwy)) + geom_point() -##' (g1 <- g0 + geom_encircle(data=subset(mpg,hwy>40))) -##' ss <- subset(mpg,hwy>31 & displ<2) -##' g1 + geom_point(data=ss,colour="blue")+ -##' geom_encircle(data=ss,colour="blue",s_shape=0.9, -##' expand=0.07) +} + + +#' Automatically enclose points in a polygon +#' +#' @param mapping mapping +#' @param data data +#' @param stat stat +#' @param position position +#' @param na.rm na.rm +#' @param show.legend show.legend +#' @param inherit.aes inherit.aes +#' @param ... dots +#' @return adds a circle around the specified points +#' @author Ben Bolker +#' @export +#' @examples +#' d <- data.frame(x=c(1,1,2),y=c(1,2,2)*100) +#' +#' gg <- ggplot(d,aes(x,y)) +#' gg <- gg + scale_x_continuous(expand=c(0.5,1)) +#' gg <- gg + scale_y_continuous(expand=c(0.5,1)) +#' +#' gg + geom_encircle(s_shape=1, expand=0) + geom_point() +#' +#' gg + geom_encircle(s_shape=1, expand=0.1, colour="red") + geom_point() +#' +#' gg + geom_encircle(s_shape=0.5, expand=0.1, colour="purple") + geom_point() +#' +#' gg + geom_encircle(data=subset(d, x==1), colour="blue", spread=0.02) + +#' geom_point() +#' +#' gg +geom_encircle(data=subset(d, x==2), colour="cyan", spread=0.04) + +#' geom_point() +#' +#' gg <- ggplot(mpg, aes(displ, hwy)) +#' gg + geom_encircle(data=subset(mpg, hwy>40)) + geom_point() +#' +#' ss <- subset(mpg,hwy>31 & displ<2) +#' +#' gg + geom_encircle(data=ss, colour="blue", s_shape=0.9, expand=0.07) + +#' geom_point() + geom_point(data=ss, colour="blue") geom_encircle <- function(mapping = NULL, data = NULL, stat = "identity", - position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) { + position = "identity", na.rm = FALSE, show.legend = NA, + inherit.aes = TRUE, ...) { layer( - geom = GeomEncircle, mapping = mapping, data = data, stat = stat, + geom = GeomEncircle, mapping = mapping, data = data, stat = stat, position = position, show.legend = show.legend, inherit.aes = inherit.aes, params = list(na.rm = na.rm, ...) ) diff --git a/R/geom_table.r b/R/geom_table.r new file mode 100644 index 0000000..7b6f022 --- /dev/null +++ b/R/geom_table.r @@ -0,0 +1,94 @@ +#' @rdname ggalt-ggproto +#' @format NULL +#' @usage NULL +#' @export +GeomTable <- ggproto( + "GeomTable", + Geom, + required_aes = c("x", "y", "table"), + default_aes = aes( + widthx = 10, + widthy = 10, + rownames = NA + ), + draw_key = draw_key_blank, + + draw_panel = function(data, panel_scales, coord) { + if (nrow(data) != 1) { + stop( + sprintf( + "only one table per panel allowed, got %s (%s)", + nrow(data), + as.character(data) + ), + call. = FALSE + ) + } + wy = data$widthy / 2 + wx = data$widthx / 2 + + corners <- + data.frame(x = c(data$x - wx, data$x + wx), + y = c(data$y - wy, data$y + wy)) + d <- coord$transform(corners, panel_scales) + + # gross hack, but I've found no other way to get a table/matrix/dataframe to this point :-( + table = read.csv(text = data$table, header = TRUE) + if (!is.na(data$rownames)) { + rownames(table) <- + unlist(strsplit(data$rownames, "|", fixed = TRUE)) + } + + x_rng <- range(d$x, na.rm = TRUE) + y_rng <- range(d$y, na.rm = TRUE) + + vp <- + viewport( + x = mean(x_rng), + y = mean(y_rng), + width = diff(x_rng), + height = diff(y_rng), + just = c("center", "center") + ) + + grob <- + tableGrob(table, theme = ttheme_minimal()) + # add a line across the header + grob <- gtable_add_grob( + grob, + grobs = segmentsGrob(y1 = unit(0, "npc"), + gp = gpar(lwd = 2.0)), + t = 1, + b = 1, + l = 1, + r = ncol(d) + 1 + ) + editGrob(grob, vp = vp, name = paste(grob$name, facet_id())) + } +) + +facet_id <- local({ + i <- 1 + function() { + i <<- i + 1 + i + } +}) + +#' Add a table to a ggplot2 plot +#' +#' @author Jan Schulz +geom_table <- function(mapping = NULL, data = NULL, stat = "identity", + position = "identity", na.rm = FALSE, + show.legend = NA, inherit.aes = TRUE, ...) { + layer( + geom = GeomTable, + mapping = mapping, + data = data, + stat = stat, + position = position, + show.legend = show.legend, + inherit.aes = inherit.aes, + params = list(na.rm = na.rm, ...) + ) + } diff --git a/R/geom_xspline.r b/R/geom_xspline.r index 1cac4ba..e56dc13 100644 --- a/R/geom_xspline.r +++ b/R/geom_xspline.r @@ -73,6 +73,7 @@ #' Designed for the End User", in \emph{Proceedings of SIGGRAPH 95}, #' pp. 377-386. \url{http://dept-info.labri.fr/~schlick/DOC/sig1.html} #' @export +#' @family xspline implementations #' @examples #' set.seed(1492) #' dat <- data.frame(x=c(1:10, 1:10, 1:10), diff --git a/R/geom_xspline2.r b/R/geom_xspline2.r index 0e25bba..7ef2b55 100644 --- a/R/geom_xspline2.r +++ b/R/geom_xspline2.r @@ -1,3 +1,7 @@ +#' @rdname ggalt-ggproto +#' @format NULL +#' @usage NULL +#' @export GeomXSpline2 <- ggproto("GeomXSpline", Geom, required_aes = c("x", "y"), default_aes = aes(colour = "black", s_shape=1, s_open=FALSE), @@ -14,24 +18,18 @@ GeomXSpline2 <- ggproto("GeomXSpline", Geom, } ) -##' Xspline -##' -##' @title xsplines -##' @param mapping mapping -##' @param data data -##' @param stat stat -##' @param position position -##' @param na.rm na.rm -##' @param show.legend show.legend -##' @param inherit.aes inherit.aes -##' @param ... stuff -##' @return creates a spline curve -##' @author Ben Bolker +#' Alternative implemenation for connecting control points/observations +#' with an X-spline +#' +#' @inheritParams geom_xspline +#' @return creates a spline curve +#' @author Ben Bolker +#' @family xspline implementations geom_xspline2 <- function(mapping = NULL, data = NULL, stat = "identity", position = "identity", na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) { layer( - geom = GeomXSpline2, mapping = mapping, data = data, stat = stat, + geom = GeomXSpline2, mapping = mapping, data = data, stat = stat, position = position, show.legend = show.legend, inherit.aes = inherit.aes, params = list(na.rm = na.rm, ...) ) diff --git a/R/pokemon.r b/R/pokemon.r index 4e30a38..b28f184 100644 --- a/R/pokemon.r +++ b/R/pokemon.r @@ -6,7 +6,7 @@ #' @note Pokémon & Pokémon character names are trademarks of Nintendo. #' @inheritParams ggplot2::scale_colour_hue #' @inheritParams pokemon_pal -#' @family colour pokemon +#' @family pokemon aeshetics #' @rdname scale_pokemon #' @export scale_colour_pokemon <- function(avatar="bulbasaur", ...) { @@ -28,6 +28,7 @@ scale_fill_pokemon <- function(avatar=FALSE, ...) { #' @references \href{http://www.pokegraphs.com/}{Original JSON color list}. #' @note Pokémon & Pokémon character names are trademarks of Nintendo. #' @param avatar avatar name. Use \code{list_avatars()} to see them all! +#' @family pokemon aeshetics #' @export pokemon_pal <- function(avatar="bulbasaur") { @@ -54,6 +55,7 @@ pokemon_pal <- function(avatar="bulbasaur") { #' @note Warning: huge! list\cr #' \cr #' Pokémon & Pokémon character names are trademarks of Nintendo. +#' @family pokemon aeshetics #' @export list_avatars <- function() { sort(names(pokemon)) diff --git a/R/stateface.r b/R/stateface.r index d414e00..ad55cc3 100644 --- a/R/stateface.r +++ b/R/stateface.r @@ -14,13 +14,16 @@ state_tbl <- setNames(toupper(state.abb), tolower(state.name)) #' Displays the path to the StateFace font. For the font to work #' in the on-screen plot device for ggplot2, you need to install #' the font on your system +#' +#' @family StateFace operations #' @export show_stateface <- function() { - path = normalizePath(file.path(system.file("fonts/", package="ggalt"))) - + path <- normalizePath(file.path(system.file("fonts/", package="ggalt"))) print(path) + if (!interactive) return() + if (.Platform$OS.type == "windows") { shell(sprintf("explorer %s", path), intern=TRUE) } else if(.Platform$OS.type == "unix") { @@ -33,6 +36,10 @@ show_stateface <- function() { #' Load stateface font #' +#' Makes the ProPublica StateFace font available to PDF, PostScript, +#' et. al. devices. +#' +#' @family StateFace operations #' @export load_stateface <- function() { if (interactive()) message("Loading stateface device fonts...") @@ -62,6 +69,7 @@ load_stateface <- function() { #' abels by. Useful for offsetting text from points, particularly #' on discrete scales. #' @inheritParams ggplot2::geom_text +#' @family StateFace operations #' @export #' @examples #' library(ggplot2) diff --git a/README.Rmd b/README.Rmd index b2dd321..e75c8bd 100644 --- a/README.Rmd +++ b/README.Rmd @@ -33,27 +33,15 @@ The following functions are implemented: - `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`) -- `stat_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`) +-- `geom_stateface`: Use ProPublica's StateFace font in ggplot2 plots- `stat_bkde` : Display a smooth density estimate (uses `KernSmooth::bkde`) - `geom_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`) - `stat_bkde2d` : Contours from a 2d density estimate. (uses `KernSmooth::bkde2D`) - `stat_ash` : Compute and display a univariate averaged shifted histogram (polynomial kernel) (uses `ash::ash1`/`ash::bin1`) -- `scale_color_pokemon` : +-- `geom_encircle`: Automatically enclose points in a polygon + `scale_color_pokemon` : - `scale_fill_pokemon` : discrete pokemon scales (data taken from the hard work by the ) - `byte_format`: + helpers. e.g. turn `10000` into `10 Kb` - -### News - -- Version 0.1.5.9000 - Pokemon discrete color scales! -- Version 0.1.2.9000 - Fixed bug with limits not working in coord_proj thx to @mstrimas -- Version 0.1.1 - CRAN! -- Version 0.1.0.9000 - Tweaks for ggplot2 2.0 release -- Version 0.0.4.9000 - `stat_ash` -- Version 0.0.3.9000 - `coord_proj`! (requires my github copy of ggplot2 for now) -- Version 0.0.2.9005 - cleanup before blog post -- Version 0.0.2.9002 - working 2D density plots -- Version 0.0.2.9000 initial release - ### Installation ```{r eval=FALSE} @@ -223,6 +211,36 @@ gg <- gg + scale_size_identity() gg ``` +### Encircling points automagically + +```{r encircle} +d <- data.frame(x=c(1,1,2),y=c(1,2,2)*100) + +gg <- ggplot(d,aes(x,y)) +gg <- gg + scale_x_continuous(expand=c(0.5,1)) +gg <- gg + scale_y_continuous(expand=c(0.5,1)) + +gg + geom_encircle(s_shape=1, expand=0) + geom_point() + +gg + geom_encircle(s_shape=1, expand=0.1, colour="red") + geom_point() + +gg + geom_encircle(s_shape=0.5, expand=0.1, colour="purple") + geom_point() + +gg + geom_encircle(data=subset(d, x==1), colour="blue", spread=0.02) + + geom_point() + +gg +geom_encircle(data=subset(d, x==2), colour="cyan", spread=0.04) + + geom_point() + +gg <- ggplot(mpg, aes(displ, hwy)) +gg + geom_encircle(data=subset(mpg, hwy>40)) + geom_point() + +ss <- subset(mpg,hwy>31 & displ<2) + +gg + geom_encircle(data=ss, colour="blue", s_shape=0.9, expand=0.07) + + geom_point() + geom_point(data=ss, colour="blue") +``` + ### Code of Conduct Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). diff --git a/README.html b/README.html index 2bee75f..0de9585 100644 --- a/README.html +++ b/README.html @@ -112,7 +112,7 @@ $(document).ready(function () { -

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Travis-CI Build Status CRAN_Status_Badge downloads

+

Project Status: Active - The project has reached a stable, usable state and is being actively developed. Travis-CI Build Status CRAN_Status_Badge downloads

ggalt : Extra Coordinate Systems, Geoms and Statistical Transformations for ‘ggplot2’

A compendium of ‘geoms’, ‘coords’ and ‘stats’ for ‘ggplot2’, including splines, 1d and 2d densities, univariate average shifted histograms and a new map coordinate system based on the ‘PROJ.4’-library.

The first three forays into this brave, new ggplot2 world are splines! and being able to use the (much better) KernSmooth::bkde and KernSmooth::bkde2D for density plots and an initial port of the (still needing work) coord_proj.

@@ -329,6 +329,41 @@ gg <- gg + scale_size_identity() gg

+
+

Encircling points automagically

+
d <- data.frame(x=c(1,1,2),y=c(1,2,2)*100)
+
+gg <- ggplot(d,aes(x,y))
+gg <- gg + scale_x_continuous(expand=c(0.5,1))
+gg <- gg + scale_y_continuous(expand=c(0.5,1))
+
+gg + geom_encircle(s_shape=1, expand=0) + geom_point()
+

+

+gg + geom_encircle(s_shape=1, expand=0.1, colour="red") + geom_point()
+

+

+gg + geom_encircle(s_shape=0.5, expand=0.1, colour="purple") + geom_point()
+

+

+gg + geom_encircle(data=subset(d, x==1), colour="blue", spread=0.02) +
+  geom_point()
+

+

+gg +geom_encircle(data=subset(d, x==2), colour="cyan", spread=0.04) + 
+  geom_point()
+

+

+gg <- ggplot(mpg, aes(displ, hwy))
+gg + geom_encircle(data=subset(mpg, hwy>40)) + geom_point()
+

+

+ss <- subset(mpg,hwy>31 & displ<2)
+
+gg + geom_encircle(data=ss, colour="blue", s_shape=0.9, expand=0.07) +
+  geom_point() + geom_point(data=ss, colour="blue")
+

+

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

diff --git a/README.md b/README.md index da09da3..eba3b0a 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,69 @@ gg +### Encircling points automagically + + +```r +d <- data.frame(x=c(1,1,2),y=c(1,2,2)*100) + +gg <- ggplot(d,aes(x,y)) +gg <- gg + scale_x_continuous(expand=c(0.5,1)) +gg <- gg + scale_y_continuous(expand=c(0.5,1)) + +gg + geom_encircle(s_shape=1, expand=0) + geom_point() +``` + + + +```r + +gg + geom_encircle(s_shape=1, expand=0.1, colour="red") + geom_point() +``` + + + +```r + +gg + geom_encircle(s_shape=0.5, expand=0.1, colour="purple") + geom_point() +``` + + + +```r + +gg + geom_encircle(data=subset(d, x==1), colour="blue", spread=0.02) + + geom_point() +``` + + + +```r + +gg +geom_encircle(data=subset(d, x==2), colour="cyan", spread=0.04) + + geom_point() +``` + + + +```r + +gg <- ggplot(mpg, aes(displ, hwy)) +gg + geom_encircle(data=subset(mpg, hwy>40)) + geom_point() +``` + + + +```r + +ss <- subset(mpg,hwy>31 & displ<2) + +gg + geom_encircle(data=ss, colour="blue", s_shape=0.9, expand=0.07) + + geom_point() + geom_point(data=ss, colour="blue") +``` + + + ### Code of Conduct Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). diff --git a/README_figs/README-encircle-1.png b/README_figs/README-encircle-1.png new file mode 100644 index 0000000..e6ceab1 Binary files /dev/null and b/README_figs/README-encircle-1.png differ diff --git a/README_figs/README-encircle-2.png b/README_figs/README-encircle-2.png new file mode 100644 index 0000000..bf21d23 Binary files /dev/null and b/README_figs/README-encircle-2.png differ diff --git a/README_figs/README-encircle-3.png b/README_figs/README-encircle-3.png new file mode 100644 index 0000000..e51c1d2 Binary files /dev/null and b/README_figs/README-encircle-3.png differ diff --git a/README_figs/README-encircle-4.png b/README_figs/README-encircle-4.png new file mode 100644 index 0000000..ba10969 Binary files /dev/null and b/README_figs/README-encircle-4.png differ diff --git a/README_figs/README-encircle-5.png b/README_figs/README-encircle-5.png new file mode 100644 index 0000000..fae3554 Binary files /dev/null and b/README_figs/README-encircle-5.png differ diff --git a/README_figs/README-encircle-6.png b/README_figs/README-encircle-6.png new file mode 100644 index 0000000..02d7aeb Binary files /dev/null and b/README_figs/README-encircle-6.png differ diff --git a/README_figs/README-encircle-7.png b/README_figs/README-encircle-7.png new file mode 100644 index 0000000..3d13221 Binary files /dev/null and b/README_figs/README-encircle-7.png differ diff --git a/man/geom_encircle.Rd b/man/geom_encircle.Rd index fbfb460..c4ed2b9 100644 --- a/man/geom_encircle.Rd +++ b/man/geom_encircle.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/geom_encircle.r \name{geom_encircle} \alias{geom_encircle} -\title{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, @@ -29,25 +29,34 @@ geom_encircle(mapping = NULL, data = NULL, stat = "identity", adds a circle around the specified points } \description{ -encircle +Automatically enclose points in a polygon } \examples{ - d <- data.frame(x=c(1,1,2),y=c(1,2,2)*100) - (g0 <- ggplot(d,aes(x,y))+geom_point()+ - geom_encircle(s_shape=1,expand=0)+ - geom_encircle(s_shape=1,expand=0.1,colour="red")+ - scale_x_continuous(expand=c(0.5,1))+ - scale_y_continuous(expand=c(0.5,1))+ - geom_encircle(s_shape=0.5,expand=0.1,colour="purple")) - g0 + geom_encircle(data=subset(d,x==1),colour="blue",spread=0.02)+ - geom_encircle(data=subset(d,x==2),colour="cyan",spread=0.04) - - g0 <- ggplot(mpg, aes(displ, hwy)) + geom_point() - (g1 <- g0 + geom_encircle(data=subset(mpg,hwy>40))) - ss <- subset(mpg,hwy>31 & displ<2) - g1 + geom_point(data=ss,colour="blue")+ - geom_encircle(data=ss,colour="blue",s_shape=0.9, - expand=0.07) +d <- data.frame(x=c(1,1,2),y=c(1,2,2)*100) + +gg <- ggplot(d,aes(x,y)) +gg <- gg + scale_x_continuous(expand=c(0.5,1)) +gg <- gg + scale_y_continuous(expand=c(0.5,1)) + +gg + geom_encircle(s_shape=1, expand=0) + geom_point() + +gg + geom_encircle(s_shape=1, expand=0.1, colour="red") + geom_point() + +gg + geom_encircle(s_shape=0.5, expand=0.1, colour="purple") + geom_point() + +gg + geom_encircle(data=subset(d, x==1), colour="blue", spread=0.02) + + geom_point() + +gg +geom_encircle(data=subset(d, x==2), colour="cyan", spread=0.04) + + geom_point() + +gg <- ggplot(mpg, aes(displ, hwy)) +gg + geom_encircle(data=subset(mpg, hwy>40)) + geom_point() + +ss <- subset(mpg,hwy>31 & displ<2) + +gg + geom_encircle(data=ss, colour="blue", s_shape=0.9, expand=0.07) + + geom_point() + geom_point(data=ss, colour="blue") } \author{ Ben Bolker diff --git a/man/geom_stateface.Rd b/man/geom_stateface.Rd index 1c57dca..68de4db 100644 --- a/man/geom_stateface.Rd +++ b/man/geom_stateface.Rd @@ -96,4 +96,8 @@ gg <- gg + scale_color_identity() gg <- gg + scale_size_identity() gg } +\seealso{ +Other StateFace operations: \code{\link{load_stateface}}, + \code{\link{show_stateface}} +} diff --git a/man/geom_table.Rd b/man/geom_table.Rd new file mode 100644 index 0000000..70ec1e5 --- /dev/null +++ b/man/geom_table.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/geom_table.r +\name{geom_table} +\alias{geom_table} +\title{Add a table to a ggplot2 plot} +\usage{ +geom_table(mapping = NULL, data = NULL, stat = "identity", + position = "identity", na.rm = FALSE, show.legend = NA, + inherit.aes = TRUE, ...) +} +\description{ +Add a table to a ggplot2 plot +} +\author{ +Jan Schulz +} + diff --git a/man/geom_xspline.Rd b/man/geom_xspline.Rd index 72676fd..f47ea5f 100644 --- a/man/geom_xspline.Rd +++ b/man/geom_xspline.Rd @@ -189,5 +189,7 @@ Blanc, C. and Schlick, C. (1995), "X-splines : A Spline Model \code{\link[ggplot2]{geom_segment}}: Line segments; \code{\link[graphics]{xspline}}; \code{\link[grid]{grid.xspline}} + +Other xspline implementations: \code{\link{geom_xspline2}} } diff --git a/man/geom_xspline2.Rd b/man/geom_xspline2.Rd index 79300e6..8e2ec92 100644 --- a/man/geom_xspline2.Rd +++ b/man/geom_xspline2.Rd @@ -2,36 +2,67 @@ % Please edit documentation in R/geom_xspline2.r \name{geom_xspline2} \alias{geom_xspline2} -\title{xsplines} +\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, ...) } \arguments{ -\item{mapping}{mapping} +\item{mapping}{Set of aesthetic mappings created by \code{\link{aes}} or +\code{\link{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}{data} +\item{data}{The data to be displayed in this layer. There are three + options: -\item{stat}{stat} + If \code{NULL}, the default, the data is inherited from the plot + data as specified in the call to \code{\link{ggplot}}. -\item{position}{position} + 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}} for which variables will be created. -\item{na.rm}{na.rm} + 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{show.legend}{show.legend} +\item{stat}{Use to override the default connection between +\code{geom_xspline} and \code{stat_xspline}.} -\item{inherit.aes}{inherit.aes} +\item{position}{Position adjustment, either as a string, or the result of +a call to a position adjustment function.} -\item{...}{stuff} +\item{na.rm}{If \code{FALSE} (the default), removes missing values with +a warning. If \code{TRUE} silently removes missing values.} + +\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.} + +\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}}.} + +\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.} } \value{ creates a spline curve } \description{ -Xspline +Alternative implemenation for connecting control points/observations +with an X-spline } \author{ Ben Bolker } +\seealso{ +Other xspline implementations: \code{\link{geom_xspline}} +} diff --git a/man/ggalt-ggproto.Rd b/man/ggalt-ggproto.Rd index 6fc07eb..cd6a3be 100644 --- a/man/ggalt-ggproto.Rd +++ b/man/ggalt-ggproto.Rd @@ -1,11 +1,14 @@ % 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_xspline.r, R/stateface.r +% Please edit documentation in R/coord_proj.r, R/geom_ash.r, R/geom_bkde.r, R/geom_bkde2d.r, R/geom_encircle.r, R/geom_table.r, R/geom_xspline.r, R/geom_xspline2.r, R/stateface.r \docType{data} \name{CoordProj} \alias{CoordProj} \alias{GeomBkde} \alias{GeomBkde2d} +\alias{GeomEncircle} \alias{GeomStateface} +\alias{GeomTable} +\alias{GeomXSpline2} \alias{GeomXspline} \alias{StatAsh} \alias{StatBkde} diff --git a/man/list_avatars.Rd b/man/list_avatars.Rd index bd92f05..4d16f26 100644 --- a/man/list_avatars.Rd +++ b/man/list_avatars.Rd @@ -17,4 +17,8 @@ Warning: huge! list\cr \references{ \href{http://www.pokegraphs.com/}{Original JSON color list}. } +\seealso{ +Other pokemon aeshetics: \code{\link{pokemon_pal}}, + \code{\link{scale_colour_pokemon}} +} diff --git a/man/load_stateface.Rd b/man/load_stateface.Rd index 834303f..abcbb60 100644 --- a/man/load_stateface.Rd +++ b/man/load_stateface.Rd @@ -7,6 +7,11 @@ load_stateface() } \description{ -Load stateface font +Makes the ProPublica StateFace font available to PDF, PostScript, +et. al. devices. +} +\seealso{ +Other StateFace operations: \code{\link{geom_stateface}}, + \code{\link{show_stateface}} } diff --git a/man/pokemon_pal.Rd b/man/pokemon_pal.Rd index 6177c29..e0cdc3e 100644 --- a/man/pokemon_pal.Rd +++ b/man/pokemon_pal.Rd @@ -18,4 +18,8 @@ Pokémon & Pokémon character names are trademarks of Nintendo. \references{ \href{http://www.pokegraphs.com/}{Original JSON color list}. } +\seealso{ +Other pokemon aeshetics: \code{\link{list_avatars}}, + \code{\link{scale_colour_pokemon}} +} diff --git a/man/scale_pokemon.Rd b/man/scale_pokemon.Rd index 8856177..7146086 100644 --- a/man/scale_pokemon.Rd +++ b/man/scale_pokemon.Rd @@ -27,4 +27,8 @@ Pokémon & Pokémon character names are trademarks of Nintendo. \references{ \href{http://www.pokegraphs.com/}{Original JSON color list}. } +\seealso{ +Other pokemon aeshetics: \code{\link{list_avatars}}, + \code{\link{pokemon_pal}} +} diff --git a/man/show_stateface.Rd b/man/show_stateface.Rd index f0e27e9..bea072d 100644 --- a/man/show_stateface.Rd +++ b/man/show_stateface.Rd @@ -11,4 +11,8 @@ Displays the path to the StateFace font. For the font to work 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}} +}