fixed legends on choropleth and lines

This commit is contained in:
Jeremy Kidwell 2019-02-01 13:29:18 +00:00
parent ff4ab7a2ec
commit 945efe1dea
2 changed files with 13 additions and 14 deletions

View file

@ -341,7 +341,6 @@ ggplot() +
"Data: UK Data Service (OGL) & Jeremy H. Kidwell", "Data: UK Data Service (OGL) & Jeremy H. Kidwell",
"You may redistribute this graphic under the terms of the CC-by-SA 4.0 license.", "You may redistribute this graphic under the terms of the CC-by-SA 4.0 license.",
sep = "\n")) + sep = "\n")) +
guides(colour = guide_legend(reverse=T)) +
theme_void() + theme_void() +
theme(text = element_text(family = "Arial Narrow", size = 9), theme(text = element_text(family = "Arial Narrow", size = 9),
plot.title = element_text(size = 12, face = "bold"), plot.title = element_text(size = 12, face = "bold"),
@ -363,7 +362,7 @@ ggplot() +
data = admin_lev1_fortified, data = admin_lev1_fortified,
colour = 'black', colour = 'black',
alpha = .7, alpha = .7,
size = .1) + size = .005) +
viridis::scale_fill_viridis(discrete = TRUE) + viridis::scale_fill_viridis(discrete = TRUE) +
labs(x = NULL, y = NULL, fill = "Groups", labs(x = NULL, y = NULL, fill = "Groups",
title = "Figure 2", title = "Figure 2",
@ -378,7 +377,7 @@ ggplot() +
plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"), plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"),
panel.border = element_rect(fill = NA, colour = "#cccccc"), panel.border = element_rect(fill = NA, colour = "#cccccc"),
legend.text = element_text(size = 8), legend.text = element_text(size = 8),
legend.position = c(0.9, 0.25)) legend.position = c(0.25, 0.85))
# ggsave("figure2.pdf") # ggsave("figure2.pdf")
# TODO: Need to sort out why error: "Insufficient data values to produce 5 bins." # TODO: Need to sort out why error: "Insufficient data values to produce 5 bins."
@ -389,7 +388,7 @@ ggplot() +
data = admin_lev1_fortified, data = admin_lev1_fortified,
colour = 'black', colour = 'black',
alpha = .7, alpha = .7,
size = .3) + size = .005) +
viridis::scale_fill_viridis(discrete = TRUE) + viridis::scale_fill_viridis(discrete = TRUE) +
labs(x = NULL, y = NULL, fill = "Groups", labs(x = NULL, y = NULL, fill = "Groups",
title = "Figure 3", title = "Figure 3",
@ -404,7 +403,7 @@ ggplot() +
plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"), plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"),
panel.border = element_rect(fill = NA, colour = "#cccccc"), panel.border = element_rect(fill = NA, colour = "#cccccc"),
legend.text = element_text(size = 8), legend.text = element_text(size = 8),
legend.position = c(0.9, 0.25)) legend.position = c(0.25, 0.85))
# ggsave("figure3.pdf") # ggsave("figure3.pdf")
``` ```
@ -461,7 +460,7 @@ ggplot() +
data = admin_lev1_fortified, data = admin_lev1_fortified,
colour = 'black', colour = 'black',
alpha = .7, alpha = .7,
size = .3) + size = .005) +
viridis::scale_fill_viridis(discrete = TRUE) + viridis::scale_fill_viridis(discrete = TRUE) +
labs(x = NULL, y = NULL, fill = "Groups", labs(x = NULL, y = NULL, fill = "Groups",
title = "Figure 5", title = "Figure 5",
@ -476,7 +475,7 @@ ggplot() +
plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"), plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"),
panel.border = element_rect(fill = NA, colour = "#cccccc"), panel.border = element_rect(fill = NA, colour = "#cccccc"),
legend.text = element_text(size = 8), legend.text = element_text(size = 8),
legend.position = c(0.9, 0.25)) legend.position = c(0.25, 0.85))
ggplot() + ggplot() +
@ -485,7 +484,7 @@ ggplot() +
data = admin_lev1_fortified, data = admin_lev1_fortified,
colour = 'black', colour = 'black',
alpha = .7, alpha = .7,
size = .3) + size = .005) +
viridis::scale_fill_viridis(discrete = TRUE) + viridis::scale_fill_viridis(discrete = TRUE) +
labs(x = NULL, y = NULL, fill = "Groups", labs(x = NULL, y = NULL, fill = "Groups",
title = "Figure 6", title = "Figure 6",
@ -500,7 +499,7 @@ ggplot() +
plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"), plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"),
panel.border = element_rect(fill = NA, colour = "#cccccc"), panel.border = element_rect(fill = NA, colour = "#cccccc"),
legend.text = element_text(size = 8), legend.text = element_text(size = 8),
legend.position = c(0.9, 0.25)) legend.position = c(0.25, 0.85))
ggplot() + ggplot() +
geom_polygon(aes(x = long, y = lat, group = group, geom_polygon(aes(x = long, y = lat, group = group,
@ -508,7 +507,7 @@ ggplot() +
data = admin_lev1_fortified, data = admin_lev1_fortified,
colour = 'black', colour = 'black',
alpha = .7, alpha = .7,
size = .3) + size = .005) +
viridis::scale_fill_viridis(discrete = TRUE) + viridis::scale_fill_viridis(discrete = TRUE) +
labs(x = NULL, y = NULL, fill = "Groups", labs(x = NULL, y = NULL, fill = "Groups",
title = "Figure 7", title = "Figure 7",
@ -523,7 +522,7 @@ ggplot() +
plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"), plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"),
panel.border = element_rect(fill = NA, colour = "#cccccc"), panel.border = element_rect(fill = NA, colour = "#cccccc"),
legend.text = element_text(size = 8), legend.text = element_text(size = 8),
legend.position = c(0.9, 0.25)) legend.position = c(0.25, 0.85))
# todo: plot as animated chorogram: # todo: plot as animated chorogram:
# https://www.r-graph-gallery.com/331-basic-cartogram/ # https://www.r-graph-gallery.com/331-basic-cartogram/
@ -634,7 +633,7 @@ ggplot() +
data = urbanrural_fortified, data = urbanrural_fortified,
colour = 'black', colour = 'black',
alpha = .7, alpha = .7,
size = .3) + size = .005) +
geom_point(aes(X, Y, fill = NULL, group = NULL), size = 1, data=ecs_df, geom_point(aes(X, Y, fill = NULL, group = NULL), size = 1, data=ecs_df,
colour = 'white', colour = 'white',
size = .3, size = .3,
@ -653,7 +652,7 @@ ggplot() +
plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"), plot.margin = unit(c(0, 0.25, 0.0, 0.25), "in"),
panel.border = element_rect(fill = NA, colour = "#cccccc"), panel.border = element_rect(fill = NA, colour = "#cccccc"),
legend.text = element_text(size = 8), legend.text = element_text(size = 8),
legend.position = c(0.9, 0.25)) legend.position = c(0.25, 0.85))
``` ```

File diff suppressed because one or more lines are too long