Similar to the recent post (see: How to remove boxes around ggplot2 legend labels), I am not able to get rid of the boxes around the symbols of in the legend. Here the code and below some of the data and the plot:
theme_opts_V5 <- list(theme(
panel.grid.minor.x = element_line(color = "transparent"),
panel.grid.major.x = element_line(color = "transparent"),
panel.grid.minor = element_line(color = "grey"),
panel.grid.major = element_line(color = "grey"),
panel.background = element_blank(),
plot.background = element_rect(),
panel.border = element_blank(),
axis.line = element_line(colour = "black")
))
ggplot(data, aes(x = value, y = old_value, fill = category, color = category)) +
geom_hline(
yintercept = 0, linetype = "solid",
color = "#898800", size = 1
) +
geom_vline(
xintercept = 57, linetype = "solid",
color = "#898800", size = 1
) +
geom_text(aes(x = 61, label = "Mean", y = 15), colour = "#898800", angle = 0, size = 3.4) +
geom_point(size = 3, shape = 23) +
labs(
title = "Title",
subtitle = "Subtitle",
caption = "Source"
) +
xlab("new, in %") +
ylab("change to old") +
scale_color_manual(values = c("#440154", "#3b528b")) +
scale_fill_manual(values = c("#440154", "#3b528b")) +
theme(
legend.title = element_blank(),
legend.position = "bottom",
legend.key = element_rect(fill = NA)
) +
theme(legend.background = element_blank()) +
theme_opts_V5 +
scale_x_continuous(limits = c(30, 80), breaks = seq(30, 80, by = 10), expand = c(0, 0)) +
scale_y_continuous(limits = c(-30, 20), breaks = seq(-30, 20, by = 10), expand = c(0, 0))
Here you find a snippet of my data:
structure(list(city = c("Aadorf", "Affeltrangen", "Altnau", "Amlikon-Bissegg",
"Amriswil", "Arbon", "Basadingen-Schlattingen", "Berg", "Berlingen",
"Bettwiesen", "Bichelsee-Balterswil", "Birwinken", "Bischofszell",
"Bottighofen", "Braunau", "Bürglen", "Bussnang", "Diessenhofen",
"Dozwil", "Egnach"), value = c(55L, 48L, 60L, 70L, 63L, 76L,
52L, 42L, 53L, 49L, 49L, 57L, 70L, 36L, 49L, 69L, 47L, 47L, 44L,
57L), old_value = c(4L, 2L, -1L, 0L, 0L, 0L, 3L, -3L, -2L, 6L,
5L, -11L, -2L, -3L, -3L, 6L, -3L, 0L, -8L, -3L), category = c("low",
"low", "low", "low", "high", "high", "low", "low", "low", "low",
"low", "low", "low", "low", "low", "low", "low", "low", "low",
"low")), row.names = c(NA, 20L), class = "data.frame")
And the plot:
Thanks for any help!
Sorry for the incompleteness of the post. Here is the code for theme_opts_V5 that only defines background and grid lines of the plot: `
theme_opts_V5 <- list(theme(panel.grid.minor.x = element_line(color = "transparent"),
panel.grid.major.x = element_line(color = "transparent"),
panel.grid.minor = element_line(color = "grey"),
panel.grid.major = element_line(color = "grey"),
panel.background = element_blank(),
plot.background = element_rect(),
panel.border = element_blank(),
axis.line = element_line(colour = "black")))
```
Thank you in advance!