1

I have a continous variable that I would like to map to the color of my points. However the distribution of the variable is shifted tot the right.

So I thought I could use the quantiles to set the breaks but this doesn't seem to be working.

I think I don't understand the subtleties between all of the different variants of scale_colour_gradient.

ggplot(df, aes(x = LibPl, y = IntStd, color = totSmpInt)) +
  geom_point(position = "jitter", alpha = 0.5) +
  scale_colour_gradientn(colours = brewer.pal(n = 4, "RdYlBu"),
                         breaks = c(qn[1], qn[2], qn[3], qn[4], qn[5]))

enter image description here

As you can see from the color legend in the plot it doesn't really seem like the quantiles were used as break points.

I have read a few other similar posts, and tried variants, but none are working Any help is appreciated.

Thanks,

Henrik
  • 65,555
  • 14
  • 143
  • 159
user2814482
  • 631
  • 1
  • 10
  • 28
  • Why don't you color using log scale ?? – Koundy May 06 '15 at 09:17
  • the numbers are allready logged – user2814482 May 06 '15 at 09:21
  • 3
    [Consider providing a reproducible example to recreate your problem or intended task.](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – shekeine May 06 '15 at 11:35
  • It's a normal behavior : the scale is extended from minimum to maximum value. One solution would be to reassign all values below the first quintile to that value : `df$totSmpInt[df$totSmpInt < qn[1]] <- qn[1]` (or to a slightly lower value `df$totSmpInt[df$totSmpInt < qn[1]] <- qn[1] * 0.95` so they don't distort the scale so much – scoa May 06 '15 at 20:47

0 Answers0