library(tidyverse)
<- tidytuesdayR::tt_load(2023, week = 13) tuesdata
<- tuesdata$transitions
transitions<- tuesdata$timezones
timezones<- tuesdata$timezone_countries
timezone_countries<- tuesdata$countries countries
%>%head transitions
%>%head timezones
<- map_data("world")
world
%>%
timezonesggplot(aes(longitude,latitude))+
geom_rect(xmin=0,xmax=Inf,ymin=-Inf,ymax=Inf,fill="#fff1e0")+
geom_rect(xmin=-Inf,xmax=0,ymin=-Inf,ymax=Inf,fill="#bfd0dd")+
geom_rect(xmin=0,xmax=Inf,ymin=-Inf,ymax=0,fill="#bfd0dd")+
geom_rect(xmin=-Inf,xmax=0,ymin=-Inf,ymax=0,fill="#fff1e0")+
geom_polygon(data=world,mapping=aes(long,lat,group=group),fill=NA,color="grey")+
geom_point(shape=21,stroke=0.3,fill="#7b9aca")+
geom_vline(xintercept = 0)+
geom_hline(yintercept = 0)+
coord_sf()+
labs(title="Positive & Negative Coordinates",
subtitle = "Time zone locations",
caption="DataSource: #TidyTuesday Week13: Time Zones - #30DayChartChallenge Day15: positive/negative\nDataViz: Federica Gazzelloni")+
::theme_map()+
ggthemestheme(plot.background = element_rect(color="#7b9aca",fill="#7b9aca"))
Bonne Projection
library(sf)
<- c("+proj=bonne +lat_1=10")
projection_bonne
<- sf::st_graticule(lon= seq(-180,180, 15),
world_graticule lat = seq(-90,90, 7.5),
ndiscr = 5000,
margin = 0.00000000001) %>%
::st_transform(projection_bonne)
sf
<- rnaturalearth::ne_countries(returnclass = "sf")
world_pol
= st_as_sf(timezones, coords = c("longitude", "latitude"),
DT_sf crs = 4326, agr = "constant")
ggplot()+
geom_sf(data = world_graticule)+
geom_sf(data = world_pol)+
geom_sf(data=DT_sf)+
coord_sf()
# input_coord <- st_point(c(<longitude>, <latitude>))
<- "+proj=moll"
proj_mollweide <- st_transform(DT_sf, crs = proj_mollweide) output_coord
Mollweide Projection
# set the fonts
library(showtext)
library(sysfonts)
library(extrafont)
::showtext_auto()
showtext::showtext_opts(dpi=320)
showtextfont_add_google(name="Patrick Hand",
family="Patrick Hand")
ggplot(output_coord)+
geom_rect(xmin=0,xmax=Inf,ymin=-Inf,ymax=Inf,fill="#fff1e0")+
geom_rect(xmin=-Inf,xmax=0,ymin=-Inf,ymax=Inf,fill="#bfd0dd")+
geom_rect(xmin=0,xmax=Inf,ymin=-Inf,ymax=0,fill="#bfd0dd")+
geom_rect(xmin=-Inf,xmax=0,ymin=-Inf,ymax=0,fill="#fff1e0")+
geom_sf(data = world_pol,fill=NA,color="grey40")+
geom_sf(shape=21,stroke=0.3,fill="#7b9aca")+
geom_vline(xintercept = 0)+
geom_hline(yintercept = 0)+
#coord_map(projection = "mollweide")+
labs(title="Positive & Negative Coordinates",
subtitle = "Time zone locations",
caption="DataSource: #TidyTuesday Week13: Time Zones - #30DayChartChallenge Day15: positive/negative\nDataViz: Federica Gazzelloni")+
::theme_map()+
ggthemestheme(text=element_text(family="Patrick Hand"),
plot.title = element_text(size=30),
plot.caption = element_text(size=10),
plot.background = element_rect(color="#7b9aca",fill="#7b9aca"))
ggsave("p.png",
width = 7,height = 5)