Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@
* Fixed a compatibility issue with `ggproto` and R versions prior to 3.1.2.
(#1444)

* Fixed issue where `coord_map()` fails when given an explicit `parameters`
argument (@tdmcarthur, #1729)

# ggplot2 2.0.0

## Major changes
Expand Down
21 changes: 16 additions & 5 deletions R/coord-map.r
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
#' @export
#' @param projection projection to use, see
#' \code{\link[mapproj]{mapproject}} for list
#' @param ... other arguments passed on to
#' \code{\link[mapproj]{mapproject}}
#' @param ... other arguments passed on to \code{\link[mapproj]{mapproject}}.
#' Ignored if the \code{parameters} argument is present.
#' @param parameters optional numeric vector of parameters for use
#' with the projection argument. This argument is optional only in
#' the sense that certain projections do not require additional
#' parameters. Passed to \code{\link[mapproj]{mapproject}}.
#' @param orientation projection orientation, which defaults to
#' \code{c(90, 0, mean(range(x)))}. This is not optimal for many
#' projections, so you will have to supply your own. See
Expand All @@ -46,7 +50,8 @@
#'
#' # Other projections
#' nzmap + coord_map("cylindrical")
#' nzmap + coord_map("azequalarea", orientation = c(-36.92,174.6,0))
#' nzmap + coord_map("azequalarea", orientation = c(-36.92, 174.6, 0))
#' nzmap + coord_map("lambert", parameters = c(-37, -44))
#'
#' states <- map_data("state")
#' usamap <- ggplot(states, aes(long, lat, group = group)) +
Expand Down Expand Up @@ -83,12 +88,18 @@
#' # Centered on New York (currently has issues with closing polygons)
#' worldmap + coord_map("ortho", orientation = c(41, -74, 0))
#' }
coord_map <- function(projection="mercator", ..., orientation = NULL, xlim = NULL, ylim = NULL) {
coord_map <- function(projection="mercator", ..., parameters = NULL, orientation = NULL, xlim = NULL, ylim = NULL) {
if (is.null(parameters)) {
params <- list(...)
} else {
params <- parameters
}

ggproto(NULL, CoordMap,
projection = projection,
orientation = orientation,
limits = list(x = xlim, y = ylim),
params = list(...)
params = params
)
}

Expand Down
16 changes: 11 additions & 5 deletions man/coord_map.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.