Моя легенда показывает только 5 предметов, а не 9, которые у меня есть, с цветом эстетики c, и я не могу понять, почему. Я также не уверен, как установить цвет заливки элементов легенды. Я, вероятно, неправильно понимаю документацию, поэтому заранее извиняюсь за возможный глупый вопрос. Любые идеи с благодарностью.
substrate_types <- c("Medium sands",
"Tidal flat mixed sediments",
"Muddy sand",
"Mud",
"*.Are (fine and very fine sands/sparse infauna)",
"Fine and very fine sands; Arenicola beds/sparse infauna",
"Gravelly sands",
"Rock",
"Scoured cobbles w. diverse encrusting & low faunal turf fauna")
sub_type_rectx <- c(-4.15, -3.95)
sub_type_recty <- c(57.81, 57.88)
sub_type_colours <- c("blue",
"blue",
"red",
"purple",
"orange",
"black",
"red",
"darkred",
"darkblue")
plt_sub_type <- ggplot(data = uk, colour = colours) +
geom_sf(fill = fill_colour, colour = line_colour) +
geom_sf(data = intertidal, colour = "black", fill = "wheat3")+
#geom_sf(data = scot, colour = line_colour, fill = fill_colour) +
geom_sf(data = biotope_list_sf[["Medium sands"]], aes(colour = "blue"), fill = "lightblue", alpha = 0.5) +
geom_sf(data = biotope_list_sf[["Tidal flat mixed sediments"]], aes(colour = "blue"), fill = "lightblue", alpha = 0.5) +
geom_sf(data = biotope_list_sf[["Muddy sand"]], aes(colour = "red"), fill = "pink", alpha = 0.5) +
geom_sf(data = biotope_list_sf[["Mud"]], aes(colour = "purple1"), fill = "purple", alpha = 0.5) + # hard substrate, Possibly contains mussels
geom_sf(data = biotope_list_sf[["*.Are (fine and very fine sands/sparse infauna)"]], aes(colour = "orange"), fill = "orange", alpha = 0.5) +
geom_sf(data = biotope_list_sf[["Fine and very fine sands; Arenicola beds/sparse infauna"]], aes(colour = "green"), fill = "black", alpha = 0.5) +
geom_sf(data = biotope_list_sf[["Gravelly sands"]], aes(colour = "purple1"), fill = "purple", alpha = 0.5) + # hard substrate, Possibly contains mussels
geom_sf(data = biotope_list_sf[["Rock"]], aes(colour = "orange"), fill = "orange", alpha = 0.5) +
geom_sf(data = biotope_list_sf[["Scoured cobbles w. diverse encrusting & low faunal turf fauna"]], aes(colour = "green"), fill = "black", alpha = 0.5) +
geom_sf(data = A9, colour = road_colour) +
geom_sf(data = bridge, colour = "black", fill = "black", alpha = 0.8) +
# Crop and scales
coord_sf(xlim = sub_type_rectx, ylim = sub_type_recty, expand = FALSE) +
scale_x_continuous(breaks = seq(sub_type_rectx[1], sub_type_rectx[2], by = 0.1), labels = label_function_x) +
scale_y_continuous(breaks = seq(sub_type_recty[1], sub_type_recty[2], by = 0.03), labels = label_function_y) +
#scale_colour_identity(name = 'Legend', guide = 'legend',labels = mytilus) +
scale_colour_manual(values = sub_type_colours, labels = substrate_types, drop = FALSE) +
# Annotations
annotation_scale(location = "tr",
width_hint = 0.3) +
annotation_north_arrow(location = "tr",
which_north = "true",
pad_x = unit(0.1, "in"),
pad_y = unit(0.2, "in"),
style = north_arrow_fancy_orienteering) +
# Styling
theme(panel.background = element_rect("white", "black", 1)) +
theme(axis.title = element_blank()) +
geom_rect(xmin = sub_type_rectx[1],
xmax = sub_type_rectx[2],
ymin = sub_type_recty[1],
ymax = sub_type_recty[2], fill = NA, colour = "black", size = 1)
plt_sub_type #Show plot