Browse Source

Updated examples in `coord_map()` to use `geom_cartogram()`

tags/v0.4.0
boB Rudis 7 years ago
parent
commit
ef012685cb
  1. 4
      DESCRIPTION
  2. 6
      R/coord_proj.r
  3. 13
      R/geom_cartogram.r
  4. 6
      man/coord_proj.Rd
  5. 13
      man/geom_cartogram.Rd

4
DESCRIPTION

@ -26,8 +26,8 @@ URL: https://github.com/hrbrmstr/ggalt
BugReports: https://github.com/hrbrmstr/ggalt/issues BugReports: https://github.com/hrbrmstr/ggalt/issues
Encoding: UTF-8 Encoding: UTF-8
Depends: Depends:
R (>= 3.0.0), R (>= 3.2.0),
ggplot2 (>= 2.2.0) ggplot2 (>= 2.2.1)
Suggests: Suggests:
testthat, testthat,
gridExtra, gridExtra,

6
R/coord_proj.r

@ -45,7 +45,7 @@
#' world <- world[world$region != "Antarctica",] #' world <- world[world$region != "Antarctica",]
#' #'
#' gg <- ggplot() #' gg <- ggplot()
#' gg <- gg + geom_map(data=world, map=world, #' gg <- gg + geom_cartogram(data=world, map=world,
#' aes(x=long, y=lat, map_id=region)) #' aes(x=long, y=lat, map_id=region))
#' gg <- gg + coord_proj("+proj=wintri") #' gg <- gg + coord_proj("+proj=wintri")
#' gg #' gg
@ -55,7 +55,7 @@
#' usa <- usa[!(usa$subregion %in% c("Alaska", "Hawaii")),] #' usa <- usa[!(usa$subregion %in% c("Alaska", "Hawaii")),]
#' #'
#' gg <- ggplot() #' gg <- ggplot()
#' gg <- gg + geom_map(data=usa, map=usa, #' gg <- gg + geom_cartogram(data=usa, map=usa,
#' aes(x=long, y=lat, map_id=region)) #' aes(x=long, y=lat, map_id=region))
#' gg <- gg + coord_proj( #' gg <- gg + coord_proj(
#' paste0("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96", #' paste0("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96",
@ -66,7 +66,7 @@
#' greenland <- world[world$region == "Greenland",] #' greenland <- world[world$region == "Greenland",]
#' #'
#' gg <- ggplot() #' gg <- ggplot()
#' gg <- gg + geom_map(data=greenland, map=greenland, #' gg <- gg + geom_cartogram(data=greenland, map=greenland,
#' aes(x=long, y=lat, map_id=region)) #' aes(x=long, y=lat, map_id=region))
#' gg <- gg + coord_proj( #' gg <- gg + coord_proj(
#' paste0("+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0", #' paste0("+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0",

13
R/geom_cartogram.r

@ -4,7 +4,18 @@
#' \code{x} and \code{y} aesthetics. #' \code{x} and \code{y} aesthetics.
#' #'
#' @section Aesthetics: #' @section Aesthetics:
#' \aesthetics{geom}{cartogram} #' \code{geom_cartogram} understands the following aesthetics (required aesthetics are in bold):
#' \itemize{
#' \item \code{\strong{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 #' @export
#' @param map Data frame that contains the map coordinates. This will #' @param map Data frame that contains the map coordinates. This will

6
man/coord_proj.Rd

@ -62,7 +62,7 @@ world <- map_data("world")
world <- world[world$region != "Antarctica",] world <- world[world$region != "Antarctica",]
gg <- ggplot() gg <- ggplot()
gg <- gg + geom_map(data=world, map=world, gg <- gg + geom_cartogram(data=world, map=world,
aes(x=long, y=lat, map_id=region)) aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj("+proj=wintri") gg <- gg + coord_proj("+proj=wintri")
gg gg
@ -72,7 +72,7 @@ usa <- world[world$region == "USA",]
usa <- usa[!(usa$subregion \%in\% c("Alaska", "Hawaii")),] usa <- usa[!(usa$subregion \%in\% c("Alaska", "Hawaii")),]
gg <- ggplot() gg <- ggplot()
gg <- gg + geom_map(data=usa, map=usa, gg <- gg + geom_cartogram(data=usa, map=usa,
aes(x=long, y=lat, map_id=region)) aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj( gg <- gg + coord_proj(
paste0("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96", paste0("+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96",
@ -83,7 +83,7 @@ gg
greenland <- world[world$region == "Greenland",] greenland <- world[world$region == "Greenland",]
gg <- ggplot() gg <- ggplot()
gg <- gg + geom_map(data=greenland, map=greenland, gg <- gg + geom_cartogram(data=greenland, map=greenland,
aes(x=long, y=lat, map_id=region)) aes(x=long, y=lat, map_id=region))
gg <- gg + coord_proj( gg <- gg + coord_proj(
paste0("+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0", paste0("+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0",

13
man/geom_cartogram.Rd

@ -58,7 +58,18 @@ This replicates the old behaviour of \code{geom_map()}, enabling specifying of
} }
\section{Aesthetics}{ \section{Aesthetics}{
\aesthetics{geom}{cartogram} \code{geom_cartogram} understands the following aesthetics (required aesthetics are in bold):
\itemize{
\item \code{\strong{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{ \examples{

Loading…
Cancel
Save