|
- ---
- title: "Minard"
- author: "Antoine Neuraz"
- date: "18/11/2019"
- output: html_document
- ---
-
- ```{r, include=FALSE}
- knitr::opts_chunk$set(echo = TRUE)
- ```
-
- ```{r}
- library(tidyverse)
- library(lubridate)
- library(ggmap)
- library(ggrepel)
- library(gridExtra)
- library(pander)
- library(ggmap)
- library(vizoR)
-
-
-
- data("minard_cities")
-
- data("minard_troops")
-
- data('minard_temps')
-
- temps.nice <- minard_temps %>%
- mutate(nice.label = paste0(temp, "°, ", month, ". ", day))
-
- ```
-
- ```{r, fig.asp=.4}
-
- font_family = "Helvetica"
- color_cities = "black"
-
- color_troops_fw = "#DFC17E"
- color_troops_bw = "#252523"
-
- march.1812.plot.simple <- ggplot() +
- geom_path(data = minard_troops, aes(x = long, y = lat, group = group,
- color = direction, size = survivors),
- lineend = "round") +
- geom_point(data = minard_cities, aes(x = long, y = lat),
- color = color_cities) +
- geom_text_repel(data = minard_cities, aes(x = long, y = lat, label = city),
- color = color_cities, family = font_family) +
- scale_size(range = c(0.5, 15)) +
- scale_colour_manual(values = c(color_troops_fw,color_troops_bw )) +
- guides(color = FALSE, size = FALSE) +
- theme_nothing()
-
-
- temps.1812.plot <- ggplot(data = temps.nice, aes(x = long, y = temp)) +
- geom_line() +
- geom_label(aes(label = nice.label),
- family = font_family, size = 2.5) +
- labs(x = NULL, y = "° Celsius") +
- scale_x_continuous(limits = ggplot_build(march.1812.plot.simple)$layout$panel_ranges[[1]]$x.range) +
- scale_y_continuous(position = "right") +
- coord_cartesian(ylim = c(-35, 5)) +
- theme_bw(base_family = font_family) +
- theme(panel.grid.major.x = element_blank(),
- panel.grid.minor.x = element_blank(),
- panel.grid.minor.y = element_blank(),
- axis.text.x = element_blank(), axis.ticks = element_blank(),
- panel.border = element_blank())
-
-
- both.1812.plot.simple <- rbind(ggplotGrob(march.1812.plot.simple),
- ggplotGrob(temps.1812.plot))
-
-
- panels <- both.1812.plot.simple$layout$t[grep("panel", both.1812.plot.simple$layout$name)]
-
-
- both.1812.plot.simple$heights[panels] <- unit(c(3, 1), "null")
-
- grid::grid.newpage()
- grid::grid.draw(both.1812.plot.simple)
- ```
-
- ```{r}
- march.1812.europe <- c(left = -13.10, bottom = 35.75, right = 41.04, top = 61.86)
-
- march.1812.europe.map.wc <- get_stamenmap(bbox = march.1812.europe, zoom = 5,
- maptype = "toner", where = "cache")
-
- ggmap(march.1812.europe.map.wc) +
- geom_path(data = troops, aes(x = long, y = lat, group = group,
- color = direction, size = survivors),
- lineend = "round") +
- scale_size(range = c(0.5, 5)) +
- scale_colour_manual(values = c("#DFC17E", "#252523")) +
- guides(color = FALSE, size = FALSE) +
- theme_nothing()
- ```
-
|