I have some codes that want to show a map with unequal color breaks and assign each category with a specific color. I used the scale_fill_stepsn function.
Here are my codes:
ggplot(data = rate) + 
    geom_sf(aes(fill = rate))+theme_bw()+
      scale_fill_stepsn(name = "Test Rate \n (n/1000)", 
                    colors =c("#999999","#6666FF", "#FFFF66","#FF6633"),
                    breaks = c(0,1, 10, 100),
                    labels=scales::label_number(accuracy=1),
                    show.limits = TRUE) +
    annotation_north_arrow(location = "tl", which_north = "true", 
        pad_x = unit(0.1, "in"), pad_y = unit(0.05, "in"),
        height = unit(1, "cm"),
        width = unit(1, "cm"),
        style = north_arrow_fancy_orienteering)+
    annotation_scale(location = "bl", width_hint = 0.2)
The exact colours I put in the function shows below, which do not match the colour in the result figure.
scales::show_col(c("#999999","#6666FF", "#FFFF66","#FF6633"))


 
    

