scale_fill_gradientn()-setting midpoint

Hi,

I wonder how to set manually the midpoint of scale_fill_gradientn(). If you could help me, I'd be grateful.

 scale_fill_gradientn(colours= c("black","grey","white"))

Thank you!

I dont understand because you set the midpoint to grey ... so what are you asking to do that you haven't succeeded ?

Hi,

let's say I have a scale 1 to 10 and I want 3 to be grey.

Thank you for taking your time.

what do you want the other 9 levels to be ?

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

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.