scale_fill_gradientn()-setting midpoint

hmmm. try this.

# scale_fill_gradientn(c)
library(tidyverse)
df <- data.frame(
  x = 1:100,
  y = sample.int(n=10,size=100,replace=TRUE)
) %>% mutate(z = y)

ggplot(df, aes(x, y)) +
  geom_point(aes(colour = z)) +
  scale_colour_gradient2(low = "black",
                       mid = "grey",
                       high="white",
                       midpoint = 3)

switch colour for fill depending on your chart I suppose

1 Like