-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
w10_NmiA.qmd
105 lines (84 loc) · 2.41 KB
/
w10_NmiA.qmd
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
title: "TidyTuesday 2023 w10 Numbats in Australia"
author: "Federica Gazzelloni"
execute:
comments: ""
eval: true
echo: true
warning: false
message: false
---
```{r}
library(tidyverse)
tuesdata <- tidytuesdayR::tt_load(2023, week = 10)
```
```{r}
numbats <- tuesdata$numbats
```
```{r}
numbats%>%count(scientificName)
```
```{r}
# devtools::install_github('bbc/bbplot')
library(bbplot)
# bbplot::bbc_style()
```
```{r}
library(ozmaps)
library(sf)
oz_states <- ozmaps::ozmap_states
centroids <- oz_states%>%
sf::st_centroid()%>%
as_tibble()%>%
filter(!NAME=="Other Territories")
mapdata <- oz_states%>%as_tibble()
# mapdata%>%count(NAME)
# nine colors
colors <- c("#1380A1","#cbcbcb",
"#FAAB18","#990000",
"#588300","#d4a09f",
"#d999fc","#83b3d2","#cc161d")
p <- ggplot() +
geom_sf_text(data = centroids,
mapping = aes(geometry=geometry,
label=NAME),size=3) +
geom_sf(data = mapdata,
mapping = aes(geometry=geometry,
fill=NAME),
alpha=0.4,color="black",linewidth=0.1) +
scale_fill_manual(values = colors)+
guides(fill="none")+
ggnewscale::new_scale_fill()+
geom_point(data= numbats,
mapping=aes(x=decimalLongitude,y=decimalLatitude,
fill=scientificName),
shape=21,stroke=0.3,size=3,
color="grey",alpha=0.7) +
ggthemes::scale_fill_fivethirtyeight()+
coord_sf(clip = "off")+
labs(title="Mapping the Habitat of the Endangered Numbat",
subtitle="A Geographic Analysis of the Species' Distribution in Australia",
caption = "DataViz: Federica Gazzelloni #30DayChartChallenge 2023 Day12 - Theme Day: BBC News")+
bbplot::bbc_style()+
ggthemes::scale_color_fivethirtyeight()+
theme(text=element_text(size=12),
plot.title = element_text(size=22),
plot.subtitle = element_text(size=14),
plot.caption = element_text(size=12),
axis.text.x = element_blank(),
axis.text.y = element_blank())
bbplot::finalise_plot(plot_name = p,
source_name = "Source: #TidyTuesday 2023 week10 Numbats in Australia",
save_filepath = "images/basemap.png")
```
```{r}
library(cowplot)
ggdraw()+
draw_image("images/basemap.png")+
draw_image("images/numbat.png",
scale=0.25,
x=0.35)
```
```{r}
ggsave("w10_NmiA.png")
```