Introduction

These are all the graphics used on the home (https://fergustaylor.github.io/Arran/) page.

N.B. The previews shown underneath their code often look cramped here. This is because the image elements shuffle themselves around depending on the available dimensions, rather than scaling at a set ratio. As such you can create much nicer images by running the same code through the console and exporting the image at custom (larger) dimensions.

Dependencies

N.B. There are codeblocks here which have been hidden by default as they are just repeats of the start of ‘code’. This just the point where in a new environment you would need to load up the same packages as before, and import/create the data in ‘code’, to make the below graphics produceable in R. Anything new starts after ///.

If you’d like to see this code, it’s visible in the .rmd at ‘front_page_graphics.Rmd’.. Or directly from github https://github.com/fergustaylor/Arran (in /docs).

///

Front-Page Graphics

First - create a small function to make the plots work.

function0.5 <- function(argument) 
{
  filter(arransimd, DataZone==argument)
}

r function0.5 <- function(argument) { filter(arransimd, DataZone==argument) }

The code for each plot is hidden by default, select ‘code’/‘hide’ on the right to individually show/hide the code used for each plot.

plot1 <- ggplot() +
  theme_grey() +
  geom_point(data = arrancoordinates, 
             mapping = aes(x = longitude, y = latitude), size=1) +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
  coord_sf(crs= 4326, datum = sf::st_crs(4326))

plot2 <- ggplot() +
  geom_sf(data = arransubsect) +
  theme_grey() +
  geom_point(data = arrancoordinates, 
             mapping = aes(x = longitude, y = latitude), size=1) +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
  coord_sf(crs= 4326, datum = sf::st_crs(4326))

plot3 <- ggplot() +
  geom_sf(data = arran2016) +
  theme_grey() +
  geom_point(data = arrancoordinates, 
             mapping = aes(x = longitude, y = latitude), size=1) +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
  coord_sf(crs= 4326, datum = sf::st_crs(4326))

plot4 <- ggplot() +
  geom_sf(data = arransubsect) +
  geom_sf(data= function0.5("S01004372")) +
  geom_point(data = arrancoordinates[namingdzpostcode[[2]],], 
             mapping = aes(x = longitude, y = latitude), size=1) +
  theme_grey() +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
  coord_sf(crs= 4326, datum = sf::st_crs(4326))

plot5 <- function0.5("S01004372") %>%
  ggplot() +
  geom_sf() +
  theme_grey() +
  geom_point(data = arrancoordinates[namingdzpostcode[[2]],], 
             mapping = aes(x = longitude, y = latitude), size=1) +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        axis.text.x = element_blank(),
        axis.ticks.x = element_blank()) +
  coord_sf(crs= 4326, datum = sf::st_crs(4326))

grid.arrange(plot1, plot2, plot3, plot4, plot5, nrow = 1)

plot6 <- arran2016 %>%
  ggplot() +
  geom_sf() +
  theme_grey() +
  theme(legend.position="none") +
  theme(axis.text.x=element_blank(),
        axis.ticks.x=element_blank())

plot7 <- arran2016 %>%
  ggplot() +
  geom_sf(aes(fill = DataZone)) +
  theme_grey() +
  theme(axis.text.x=element_blank(),
        axis.ticks.x=element_blank())

plot8 <- arran2016 %>%
mutate(
    lon = map_dbl(geometry, ~st_centroid(.x)[[1]]),
    lat = map_dbl(geometry, ~st_centroid(.x)[[2]])
    ) %>%
  ggplot() +
  geom_sf(aes(fill = Percentile)) +
  theme_grey() +
  geom_text(aes(label = Percentile, x = lon, y = lat), size = 2, colour = "white") +
  theme(axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.x = element_blank(),
        axis.title.y = element_blank())

grid.arrange(plot6, plot7, plot8, nrow = 1)

arransimd %>%
ggplot() +
  geom_sf(aes(fill = Percentile)) +
  facet_wrap('year', nrow = 1) +
  theme_grey() +
  geom_text(aes(label = Percentile, x = lon, y = lat), size = 2, colour = "white") +
  theme(axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.x = element_blank(),
        axis.title.y = element_blank(),
        axis.text.y=element_blank(),
        axis.ticks.y=element_blank()) +
  theme(legend.position="right")  

function1.5.5 <- function(argument) 
{
  argument %>%
mutate(
    lon = map_dbl(geometry, ~st_centroid(.x)[[1]]),
    lat = map_dbl(geometry, ~st_centroid(.x)[[2]])
    ) %>%
  ggplot() +
  geom_sf(aes(fill = Percentile)) +
  facet_wrap('year') +
  theme_grey() +
  geom_text(aes(label = Percentile, x = lon, y = lat), size = 2, colour = "white") +
  theme(axis.text.x=element_blank(),
        axis.ticks.x=element_blank(),
        axis.title.x = element_blank(),
        axis.title.y = element_blank()) +
  theme(legend.position="bottom")  
}

function2.5.1 <- function(argument) 
{
  arransubsect %>%
  ggplot() +
  geom_sf() +
  theme_grey() +
  theme(axis.text.x=element_text(angle=45, hjust = 1)) +
  theme(legend.position="bottom") +
  geom_sf(data= argument, aes(fill = DataZone))
}

function5 <- function(argument, argument2) 
{
  argument %>%
  ggplot() +
  geom_sf() +
  theme_grey() +
  geom_point(data=function6(argument2), mapping = aes(x = longitude, y = latitude), size=1) +
  theme(axis.title.x = element_blank(),
        axis.title.y = element_blank()) +
  coord_sf(crs= 4326, datum = sf::st_crs(4326))
}

function6 <- function(argument) 
{
  arrancoordinates[namingdzpostcode[[argument]],]
}

function7.5.1 <- function(argument, argument2) 
{
  a <- function1.5.5(argument)
  b <- function2.5.1(argument) 
  c <- function5(argument, argument2)
  grid.arrange(a, b, c, nrow = 1)
}

function7.5.1(function0.5("S01004372"),2)

See the rest of these plots.