Description Usage Arguments Details Value Author(s) See Also Examples
Function to plot country-level maps. Requires the
countrycode
, ggplot2
, mapproj
and
maps
packages.
1 2 3 4 5 |
data |
a data frame. |
variable |
a variable name. |
t |
the time period to plot from, as specified in
the |
ncol |
if the plot is faceted by time periods, the number of facet columns |
nrow |
if the plot is faceted by time periods, the number of facet rows |
continents |
a vector of continent names to subset the map to. |
regions |
a vector of region names to subset the map to. |
name |
a name to give to the color scale |
title |
a title to give to the map |
quantize |
how many quantiles to cut the variable
into. Defaults to |
quantize.t |
how many time periods to cut the time
variable into. Defaults to |
text.size |
the size for text elements. |
iso3n |
the ISO-3N variable name, if you are using
the function on cross-sectional data (which will return a
warning), or if you are overriding the
|
simplify |
the threshold of points under which to
remove a geographic subregion. Set to something like
|
... |
other arguments passed to
|
The function is intended as a helper to map country-year
data. It falls back to mapping the data as a
cross-section if the data carries no xtdata
attribute or if t
is left unspecified, in which
case it will map the values of variable
for the
most recent time period (usually years).
When the data carries an xtdata
attribute
and t
is specified, the function returns facet
maps of the data, by time period. Use ncol
and
nrow
to arrange the disposition of the maps. If
quantize.t
is specified, the time period is cut to
quantiles and the mean value of variable
are
plotted, in order to plot things like average values of a
variable over several decades.
a ggplot2
object
Francois Briatte f.briatte@ed.ac.uk
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Load QOG demo datasets.
data(qog.demo)
# Fertility rates in Africa, most recent year.
xtmap(qog.ts.demo, "wdi_fr", continent = "Africa")
# Fertility rates in Africa, 1995.
xtmap(qog.ts.demo, "wdi_fr", 1995, continent = "Africa")
# Political regimes in Asia, excluding Russia, using cross-sectional data.
xtmap(subset(qog.cs.demo, ccode != 643), "chga_hinst", continent = "Asia",
iso3n = "ccode") +
geom_polygon(color = "grey25") +
scale_fill_brewer("", palette = "Accent")
# Grayscale version.
xtmap(subset(qog.cs.demo, ccode != 643), "chga_hinst", continent = "Asia",
iso3n = "ccode") +
geom_polygon(color = "white") +
scale_fill_grey("")
# Gross domestic product per capita in Asia, 1980-2009.
xtmap(qog.ts.demo, "wdi_gdpc", t = 1980:2009, continent = "Asia",
quantize = 10, quantize.t = 4, text.size = 16)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.