Functions for displaying multiple images with a color scale, i.e., heat maps, possibly with projected coordinates. The package relies on the base graphics system, so graphics are rendered rapidly.
knitr::opts_chunk$set(fig.path = "tools/README/")
The goal of the autoimage package is to easily plot a sequence of images with corresponding color scales, i.e., a sequence of heatmaps, with straightforward, native options for projection of geographical coordinates. The package makes it simple to add lines, points, and other graphics features to these image plots, even when the coordinates are projected. The package allows for seamless creation of heat maps for data on regular or irregular grids, as well as that is not on a grid.
The release version of autoimage can be installed in R using the command
The development version of
autoimage can be installed in R using the command:
The most important functions in autoimage are the
pimage creates a heat map with a color scale for data on a regular or irregular grid, and even non-gridded data (by automatically interpolating onto a grid). The
autoimage function generalizes the
pimage function to allow for multiple images in the same plot.
The autoimage package makes it easy to add lines and points to the images plots, with several common world maps being provided automatically through the maps package.
We illustrate some basic usage of the
We begin by creating image plots for data on an irregular grid while also including national boundaries and a legend. The coordinates are projected in the second plot by specifying the desired projection via the
proj argument and the relevant projection parameters via the
# display some narccap data on an irregular griddata(narccap)# heat map for data on an irregular grid with national boundariespimage(lon, lat, tasmax[,,1], map = "world", legend = "h")
# same plot but with projectionpimage(lon, lat, tasmax[,,1], map = "world", legend = "v",proj = "bonne", parameters = 45)
We next display an image for data that is not on a grid. Specifically, we create image plots for Colorado geochemical measurements. We also include the Colorado border in the image and the locations of the observed coordinates. Note that the
points.args arguments are used to customize the appearance of the lines and points.
# colorado data not on a grid# show observed locations on image,# along with Colorado borderdata(co, package = "gear") # load colorado geochemical measurementsdata(copoly) # load colorado borders# create list with observed pointscopoints <- list(x = co$lon, y = co$lat)pimage(co$longitude, co$latitude, co$Al,lines = copoly,lines.args = list(lwd = 2, col = "grey"),points = copoints,points.args = list(pch = 21, bg = "white"),xlim = c(-109.1, -102),ylim = c(36.8, 41.1))
autoimage function generalizes the
pimage function to allow for a sequence of images in a single graphic. We display two images, first with a common legend, then with individual legends for each image.
# plot images with USA state borders and common vertical scaleautoimage(lon, lat, tasmax[,,1:2], legend = "v", map = "usa")
# with separate scalesautoimage(lon, lat, tasmax[,,1:2], common.legend = FALSE, map = "usa")
Create autolegend to manually add legend to image created by pimage. Update autoimage to rely on pimage and autolegend. Add plines, ppoints, etc., functions to add lines, points, etc., to existing images created by pimage. Create helper function to make plot similar to autoimage using ggplot2. Introduce incompatibilities with version 0.3.1. Add vignette with examples of package capabilities. Update License because of importation of akima package.
reasons. User must install akima manually.
error in climate models.
vignette comparing autoimage and ggplot2. Improve blank.plot() by reducing margins before plotting, returning to previous margins. Changed behavior of lratio in autoimage to adapt to number of images being plotted.