-
Notifications
You must be signed in to change notification settings - Fork 4
/
11-sauvegarder-un-graphique.Rmd
29 lines (27 loc) · 1.1 KB
/
11-sauvegarder-un-graphique.Rmd
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
28
29
# Exporter un graphique
La fonction `ggsave()` de ggplot2 permet d'exporter des graphiques au format image.
Les formats suivants sont supportés : eps, ps, tex (pictex), pdf, jpeg, tiff, png, bmp, svg et wmf.
```{r exp_1, echo=TRUE, eval=FALSE, fig.height=5, fig.width=12}
p <- ODD_indicateur311 %>%
filter(Type_Zone != "Pays",
Age_group == "All age ranges or no breakdown by age",
Sex == "Both sexes or no breakdown by sex",
Location == "Total (national level)",
is.na(Value_type)
) %>%
filter(Year %in% c(2000, 2005, 2010, 2015)) %>%
ggplot() +
geom_col(aes(x = Country_or_Area_Name, y = Value, fill = Country_or_Area_Name)) +
theme_minimal() +
scale_fill_ipsum() +
coord_flip() +
labs(title = "Mortalité maternelle sur quelques zones du globe",
subtitle = "En 2015",
y = "Taux de mortalité de la mère \n(pour 100 000 naissances)",
x = "Zone",
fill = "Zone"
) +
theme(legend.position = "none") +
facet_wrap("Year", ncol = 4)
ggsave("figures/Mortalité maternelle sur quelques zones du globe.svg", p, width = 12, height = 5)
```