Plot a world heat map based on a categorical variable.
worldplotCat(
data,
ColName,
CountryName,
CountryNameType = "isoa2",
longitude = c(-180, 180),
latitude = c(-90, 90),
crs = 4326,
title = "",
legendTitle = as.character(ColName),
legend.position = "right",
Categories = levels(factor(map_df$MapFiller)),
na.as.category = TRUE,
label.color = "white",
label.size = 2,
annote = FALSE,
div = 1,
palette_option = "D",
na_colour = "grey80",
transform_limits = TRUE,
shadows = TRUE,
UK_as_GB = TRUE
)a map
Data set containing the list of nations and the variable that we want to plot.
Character variable with the name of the variable of interest.
Character variable with the name of the country names column.
Character variable with the coding for CountryName. One of isoa2 (default, standing for ISO 3166-1 alpha-2 code), isoa3, or name.
Longitude limits. Default is c(-180, 180) (whole world with crs as EPSG::4326).
Latitude limits. Default is c(-90, 90) (whole world with crs as EPSG::4326).
Coordinate reference system (EPSG). By default the value is 4326, which corresponds to EPSG::4326 (WGS84)
Title of the plot. Default is no title.
Title of the legend. Default is the name of the filling variable.
Position of the legend. If set to "none", no legend is displayed
categories labels to be plotted in the legend.
Treat NA as a separate category? If `TRUE, NA will also appear in the legend as one of the categories.
Color of the labels if annote = TRUE. Default is white
Size of the labels if annote = TRUE
Do you want to plot country labels (ISO 3166-1 alpha-2 code) on the map? Default is set to FALSE.
Parameter for modifying the elements dimensions in the map. Usually, it does not need to be modified. Default value is 1.
Character string indicating the palette to be used. Available options range between "A" and "H". You can also enter a string with a colour for each category
The colour to be used for countries with missing information. Default is grey80
Only if crs is specified and different from 4326. If TRUE (the default) the program expects to receive values of longitude and latitude as in EPSG 4326, (i.e., within -180, +180 for longitude and within -90, +90 for latitude) and automatically updates to the new crs. Set to FALSE if you want to define longitude and latitude limits based on the new crs
If TRUE, add shadows to the country labels (only if annote = TRUE)
Argument passed to countrycoord_data if annote is set to TRUE. Do you want to translate the GB isoa2 code to UK? If FALSE, GB is returned in the output data.frame. If TRUE (default), UK is returned.
data(testdata1b)
worldplotCat(data = testdata1b,
div = 1,
ColName = "VCat",
CountryName = "Cshort",
CountryNameType = "isoa2",
annote = FALSE)
Run the code above in your browser using DataLab