Description Usage Arguments Details Value Examples
This function is the main function of the eumaps
package. It
creates a choropleth map of the European Union (EU). It breaks down the
process of making a map into three basic steps: (1) specifying the
geography to plot, (2) specifying the color palette to use, and (3)
specifying a theme that defines the aesthetics of the map. The make_map()
function has three inputs, one for each step: an object created by
create_geography()
that the specifies geography to plot, an object
created by create_palette()
that specifies the color palette to use, and
an object created by create_theme()
that specifies the theme.
The data for the country borders comes from Natural Earth, a public domain database.
1 |
geography |
An object of class |
palette |
An object of class |
theme |
An object of class |
title |
String. Optional. The title of the map. The default value is
|
The choropleth maps created by make_map()
visually differentiate
between four groups of countries: member states without missing data,
member states with missing data, member states that are coded as not
applicable, and non-member states.
Member states without missing data are shaded according to a color ramp with a fixed number of colors. Each color in the color ramp maps to a bin of values in the data. The color ramp can be linear or diverging. The legend always includes all colors in the color ramp, regardless of whether the corresponding bin actually appears in the data. That way, if you use the same palette across multiple maps, the legend stays the same.
The other three groups of countries (member states with missing data, member state that are coded as not applicable, and non-member states) each have their own colors (by default, shades of gray) and labels, which you can customize. These colors only appear in the legend when applicable.
Distinguishing between member states where the data is and is not applicable is useful in many applications. For example, if you're making a map of the Eurozone, you may only want to plot data for Eurozone members (some of which could have missing data), but still want to visually differentiate between member states that are not members of the Eurozone and countries that are not EU member states. Here, the data would not be applicable for member states that are not members of the Eurozone.
The geography
input, which needs to be an object of class
eumaps.geography
created by create_geography()
, specifies the geography
to plot. The appropriate geography to plot is influenced by which countries
are member states on the date of the data, whether the map should center on
a subset of member states, the aspect ratio of the map, how zoomed out the
map should be, whether the map should include non-member states, whether
there should be insets for some member states, what projection the map
should use, and whether the map should use high or low resolution border
data.
The palette
input, which needs to be an object of class eumaps.palette
created by create_palette()
, specifies a mapping between a continuous
variable and a color ramp with a fixed number of colors. It also specifies
the colors and labels to use for member states with missing data, for
member states where the data is not applicable, and for non-member states.
The theme
input, which needs to be an object of class eumaps.theme
created by create_theme()
, specifies the aesthetics of the map, including
the style of the map border, the country borders, the title, the legend,
and any insets.
This function returns a standard ggplot
object.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # simulate data
data <- simulate_data()
# create the geography using the default values
geography <- create_geography()
# create the palette using the default values
palette <- create_palette(
member_states = data$member_state,
values = data$value,
value_min = 0,
value_max = 1,
count_colors = 8,
color_low = "#E74C3C",
color_high = "#3498DB",
color_mid = "#FFFFFF"
)
# create the theme using the default values
theme <- create_theme()
# make the map
map <- make_map(
geography = geography,
palette = palette,
theme = theme
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.