Description Usage Arguments Value Examples
Simplified plotting utilitity for spatial polygons dataframes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | PolygonMap(map, id, variable = NULL, data = NULL, verbose = F,
map_colors = wpal("earth"), map_NAcolor = "grey", map_transparency = 1,
map_colors_limits = NULL, map_colors_breaks = NULL,
map_diverging_centervalue = NULL, map_outline_color = NULL,
map_outline_size = NULL, return_objects = FALSE, pdf_path = NULL,
include_titles = NULL, histogram = FALSE, histogram_fill_color = NULL,
histogram_stats = NULL, histogram_stats_mean_color = "red",
histogram_stats_quantile_color = "black", outline = NULL,
outline_size = 0.1, outline_color = "white", font_family = "serif",
font_size = 12, map_title = NULL, map_subtitle = NULL,
map_title_justification = 0.5, map_title_font_size = NULL,
map_title_font_face = "plain", series_dimension = NULL,
series_sequence = NULL, legend_title = NULL, legend_position = "bottom",
legend_font_size = NULL, legend_font_face = "plain",
legend_orientation = "horizontal", legend_bar_width = unit(0.03, "snpc"),
legend_bar_length = unit(0.75, "snpc"), legend_label_breaks = NULL,
legend_label_values = NULL, legend_patch_width = 0.25,
legend_patch_height = 0.25, legend_patch_label_position = "right")
|
map |
A SpatialPolygonsDataFrame with a column in the @data slot that contains a unique geographic ID (passed as the parameter id) that is a primary (unique) key to the geometry/polygon boundaries you plan to use. |
id |
string; the column name for the unique geogrpahic ID |
variable |
string; the name of the column with values you wich to plot. Default is NULL, which will allow the user to create a layer with a single fill and outline color for the main map. |
data |
A data.table that contains the data you want to map (must contain id, and the variable of interest, if specified. If a series dimension and/or series sequence is defined, those must also exist in this data set) |
verbose |
logical; Whether you want print statements from the function |
map_colors |
A list of colors that will serve as the colors you "stretch" through based on your data values. This will default to a color scheme described in woodson pallettes called "earth" that displays variation well when there are many geographic units. See woodson palletes for more options, or create your own. When no variable is defined: Fill color is default set to dark grey. |
map_NAcolor |
The color data values that are NA are portrayed as. Default="grey". |
map_transparency |
Transparency/alpha of map and map outline. Must be between 0 (entirely transparent) to 1 (entirely opaque). Default=1. |
map_colors_limits |
Values that will be used to stretch the color ramp instead of the min/max values present in the entire data set. Should either be structured "c(min,max)", with numeric values, or be "each_dimension", which will create a map series where each individual map in a series will based on the min/max from that subset of data. |
map_colors_breaks |
How you want the colors "stretched" across the range of minimum/maximum values. Default is NULL/ uniform distribution stretched across the color ramp from the minimum and maximum data values provided. Vector must begin with 0 and end with 1. |
map_diverging_centervalue |
Accepts any numeric value between the minimum and maximum of your data set. Sets the center of your color scheme to the value defined. This is meant to be used with diverging color schemes. It will override any previously defined map_colors_breaks. Default=NULL. |
map_outline_color |
Color of outline of the "map" spatial object. When a variable is specified: Default is NA/no outline. When a variable is not specified: Default is "white". |
map_outline_size |
Width of outline of the "map" spatial object. When a variable is specified: Default is 0.0 When a variable is not specified: Default is .5 |
return_objects |
This will return a list with named objects- $maps, $hists (if histogram==T), $titles, and $subtitles. Each of these lists if one ins included), as well as an outline (if one is included). This will never return a histogram at the bottom of the map, if one is desired. If you need to modify the map, and you also would like a histogram using the same color scheme, see the function histogram_colorstats(), also within the Woodson library. |
pdf_path |
A string file path to generate a PDF of the maps. If this argument is provided, the map(s) will be printed to the PDF. |
include_titles |
Default=NULL. If unspecified, and return_objects=F, include_titles will be set to T, and titles will be plotted. If unspecified, and return_objects=T, titles will not be plotted (but will be included within the resulting object within the $title and $subtitle slots). |
histogram |
logical; the plot will contain a histogram of the values |
histogram_fill_color |
If a character string for a color (or colors) are entered (ex:"grey"), the histogram will be that color rather than the color ramp used for the main map. |
histogram_stats |
Vertical lines on the histogram plot showing summary statistics. To show this, provide a vector of numeric values (between 0 and 1) to serve as quantiles, and the options "mean" and "sd" can also be included. example: c("mean","sd",.1,.5,.9). Default=NULL. |
histogram_stats_mean_color |
The color of lines you want to represent mean and standard deviation statistics, only relevant if histogram_stats!=NULL. Default="red". |
histogram_stats_quantile_color |
The color of lines you want to represent the median and quantile lines on the histogram, only relevant if histogram_stats!=NULL. |
outline |
A SpatialPolygons object that you want to use the outlines from. Make sure your outline map and main map have the same projection. |
outline_size |
A numeric value that specifies how large you want your white outlines to be if you have specified an outline you want shown on your map. Default value is .1. |
outline_color |
What color you want the outline of the additional geography to be (if provided). This can be any color r recognizes suggestions might be "black","yellow", or "white". Default is white. |
font_family |
The name of the font family you want to use for the text on the plot. Default is 'serif'. |
font_size |
The base/minimum size of the text on your graphic. Default is NULL. |
map_title |
String; the title of your map. |
map_subtitle |
String; Default=NULL. Subtitle of your map. If there is no series being plotted, the map_subtitle will serve as the subtitle. If you are mapping over a dimension, the map subtitle will automatically be set to the series_dimension being plotted. If you are mapping over a dimension, entering text for "map_subtitle" will become the prefix for the specific dimension being mapped. For example, if mapping over time, c(1990,2000), and the map_subtitle was "Year: ", the full subtitle would be "Year: 1990", and "Year: 2000", respectively. |
map_title_justification |
Numeric from 0 (left) to 1 (right). Default is center (.5). |
map_title_font_size |
How large you want the title font to be. No default; default values based on ggthemes tufte()'s default. |
map_title_font_face |
Special properties of the title font. Options include "plain", "bold", "italic". Default is plain. |
series_dimension |
A string– the name of the column that will serve as the variable you loop through to create a series map. For example, year. |
series_sequence |
A vector c(x,y,z...) that specifies a subset of the series dimensions you want to map. For example, if you have a data set that contains all years between 1980-2014, you can specify that you only want to plot out every other year by setting series sequence to be seq(1980,2014,2). This function will make sure all of the items you speficy actually exist within your series_dimension. |
legend_title |
Title above the legend. Default is NULL. |
legend_position |
Where you want the legend to go. Options are "top","bottom","right","left", and "none". Default is "bottom". |
legend_font_size |
How large you want the legend font to be. Default is NULL, which corresponds to the scaling of the base-font. |
legend_font_face |
Special properties of the legend font. Options include "plain", "bold", "italic". Default is plain. |
legend_label_breaks |
An optional vector of the values you want to label in your legend's color scale. |
legend_label_values |
An optional vector of the character strings you want to use to label your legend's color scale (must be same length as legend_label_breaks) |
legend_patch_width |
How fat you want the color bar that serves as the legend to be. Default value is unit(.03,"snpc"), or 3 percent of the viewport |
legend_patch_height |
height of color swatches in legend when categorical data is used. Default is .25. |
legend_patch_label_position |
Position of category labels in legend when categorical data is used. Default= "right". |
legend_patch_length |
How long you want the color bar that serves as the legend to be. Default value is unit(.75,"snpc"), or 75 percent of the viewport |
legend_patch_width |
width of color swatches in legend when categorical data is used. Default is .25. |
ggplot object or None (plots written to pdf)
1 | see https://rpubs.com/BeccaStubbs/introduction_to_woodson_mapping_suite for more info.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.