get_density_map2: Creates a map with two gradients in the same scale.

Description Usage Arguments Value Examples

View source: R/get_density_map2.R

Description

This is a very similar function to get_density_map, but this one plots a similar map with two gradients in the same scale with a break set to the value zero and changes the default values of the arguments gradmin and gradmax.

This function creates a map based on the dataframe assigned to argument data that creates a map showing the values of the column assigned to the fill_by argument with two gradients in the same scale.

Usage

1
get_density_map2(data, fill_by, legend = "", title = "", gradmin = -32, gradmax = 42, gradnum = 4, colors = c("#a32424", "#FFFFFF", "#224d77"))

Arguments

data

The dataframe with the polygon data and other data.

fill_by

The column that with the desired info to be shown in the map.

legend

The string to be used as legend of the map.

title

The string to be used as title of map.

gradmin

Lowest value shown in the gradient scale. Default: -32.

gradmax

Highest value shown in the gradient scale. Default: 42.

gradnum

Number of intervals shown in the gradient scale. Default: 4.

colors

The color gradient of "fill_by" info. Default: "#a32424",#FFFFFF","#224d77".

Value

Plots a map with two gradients in the same scale with a break around zero. The map uses epsg: 3035 as a projection (Azimuthal equal area focused on the European Union) showing the values of the selected column from the selected dataframe.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Country <- c("Austria", "Belgium", "Bulgaria", "Croatia")
EPP <- c(7,22,31,-27)
SD <- c(41,-15,28,-30)
Other <- c(35,22,-10,-5)
IN <- c(-25,34,42,-14)
df.data <- data.frame(Country, EPP, SD, Other, IN)
library("rnaturalearth")
library("rnaturalearthdata")
library("ggplot2")
world <- ne_countries(scale = "medium", returnclass = "sf")

t_world <- merge(world, df.data, by.x="name_long", by.y="Country")

get_density_map2(t_world, t_world$SD, legend="Gains/Losses", title= "Seats Gained or Lost by SD")

bclroger/euparliament documentation built on Jan. 26, 2020, 12:56 a.m.