- H. Wickham: Official ggplot2 documentation
- H. Wickham: ggplot2 book
- W. Chang: R graphics cookbook and Cookbook for R
- Z. Ross: Beautiful plotting in R: A ggplot2 cheatsheet
- D. Koffman: Introduction to ggplot2
- R. Saccilotto: Tutorial: ggplot2
- R. Hartman: How to format plots for publication using ggplot2
- G. Williams: Visualising data with ggplot2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Untitled" | |
author: "Francisco Rodriguez-Sanchez" | |
date: "Thursday, January 22, 2015" | |
output: html_document | |
--- | |
<style type="text/css"> | |
body, td { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Spatial reference systems I often use | |
## Source this gist from R: | |
# source("https://gist.githubusercontent.com/Pakillo/23212b72a02b9d524073/raw/b73b28354f61d381b5614a2254cf128b93e11c8a/projections.R") | |
# or using devtools: | |
# devtools::source_gist("https://gist.github.com/Pakillo/23212b72a02b9d524073") | |
# EPSG codes: | |
geo <- 4326 # Geographic, datum WGS84 | |
laea.etrs89 <- 3035 # Lambert Azimuthal Equal Area - ETRS89 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
polygonizer <- function(x, outshape=NULL, gdalformat = 'ESRI Shapefile', | |
pypath=NULL, readpoly=TRUE, quietish=TRUE) { | |
# x: an R Raster layer, or the file path to a raster file recognised by GDAL | |
# outshape: the path to the output shapefile (if NULL, a temporary file will be created) | |
# gdalformat: the desired OGR vector format | |
# pypath: the path to gdal_polygonize.py (if NULL, an attempt will be made to determine the location | |
# readpoly: should the polygon shapefile be read back into R, and returned by this function? (logical) | |
# quietish: should (some) messages be suppressed? (logical) | |
if (isTRUE(readpoly)) require(rgdal) | |
if (is.null(pypath)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Function to use GDAL to project coordinate reference system | |
# See http://www.gdal.org/gdalwarp.html for additional details | |
# `resampling` can be 'near' (nearest neighbour), 'bilinear', 'cubic', or | |
# 'lanczos' (Lanczos windowed sinc resampling). | |
# `extent` should be a bbox object or a vector of c(xmin, ymin, xmax, ymax) | |
# `of` is the output format (use GDAL short name as given by the name field of | |
# gdalDrivers(), or at http://www.gdal.org/formats_list.html) | |
# `extension` is the output extension corresponding to the primary file | |
# `ot` is the output type (see http://www.gdal.org/gdal_translate.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swatch <- function(x) { | |
# x: a vector of colours (hex, numeric, or string) | |
par(mai=c(0.2, max(strwidth(x, "inch") + 0.4, na.rm = TRUE), 0.2, 0.4)) | |
barplot(rep(1, length(x)), col=rev(x), space = 0.1, axes=FALSE, | |
names.arg=rev(x), cex.names=0.8, horiz=T, las=1) | |
} | |
# Example: | |
# swatch(colours()[1:10]) | |
# swatch(iwanthue(5)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Title: Back to basics: High quality plots using base R graphics | |
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015 | |
### | |
### Date created: 20150418 | |
### Last updated: 20150423 | |
### | |
### Author: Michael Koontz | |
### Email: mikoontz@gmail.com | |
### Twitter: @michaeljkoontz | |
### |