'Change factor level in map in R
I know this question has been asked before and I have seen answers in literature too. Still, I cannot get the code to work for my specific purpose and I hope someone can help me. I am creating maps in R and it often happens that some points on the map are covered by bigger ones. I need to change the order of the factor levels with lower counts.
The code for the map looks like this:
rnaturalearth::ne_countries(scale = "medium", returnclass = "sf") %>%
ggplot() +
geom_sf() +
coord_sf(xlim = c(-10, 5), ylim = c(36, 44), expand = FALSE) +
geom_point(data = cm3,
aes(x = x, y = y, color = factor(motif), size = count),
na.rm = TRUE) +
theme_minimal() +
xlab(NULL) +
ylab(NULL)
The resulting map looks like this:

It happened now that the pelta motifs with a pink dot are covered by other ones. Is there a possibility to change the factor levels within the code for the map or do I have to change the dataframe prior to that?
I tried to change the order manually by modifying the code like this:
rnaturalearth::ne_countries(scale = "medium", returnclass = "sf") %>%
ggplot() +
geom_sf() +
coord_sf(xlim = c(-10, 5), ylim = c(36, 44), expand = FALSE) +
geom_point(data = cm3,
aes(x = x, y = y, color = factor(motif, levels = c("pelta", "floral", "other", "boat", "crescent moon")), size = count),
na.rm = TRUE) +
theme_minimal() +
xlab(NULL) +
ylab(NULL)
And I get the following result which I am not happy with:

The code didn't give me what I want because I know there are two or three points representing the pelta motif which should appear in the north of the peninsula. But they don't appear. I really just want the smaller points to be displayed over the bigger ones, so that they are visible. Can anyone help me? Thanks in advance!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
