I have this map with a shapefile I built, intersected with species occurrence data. It’s mapping correctly except the coloring is wrong. There should only be 1 point of purple, because that would match the data table (I’ll attach a snippet of it below with the way the maps looks).
This is my current code. At first, I had a scale color gradient with low = green and high = red, but with the colors mapping incorrectly, I thought it was maybe the scale gradient and switched to viridis.
library(viridis)
# Plot with labels
oslo_map <- ggplot() +
geom_sf(data = shp2_oslo, color = "gray30", size = 0.2, fill = "lightblue1") +
geom_sf(data = intersect3_oslo, aes(color = occurrences), size = 1.5, fill = NA) +
scale_color_viridis(option = "plasma", begin = 0, end = 1, direction = -1) + # Adding color scale for points
ggtitle("Oslo") +
theme_bw() +
theme(axis.title.x = element_blank(), # Remove x-axis title
axis.title.y = element_blank(), # Remove y-axis title
plot.title.position = "panel", # Position the title centered above the plot
plot.title = element_text(hjust = 0.5) # Center the title text
)
print(oslo_map)
It’s still not mapping correctly, even though the table looks fine and I feel like the code makes sense. Any suggestions?