I have a 2d histogram created with stat_bin2d
in the ggplot2
package. I'd like to control both the number of breaks in the color gradient, as well as where those breaks are located. I'm sure I'm just overlooking something small, but I can't figure out how to control the breaks in the binning.
Example:
x <- rnorm(100)^2
y <- rnorm(100)^2
df <- data.frame(x,y)
require(ggplot2)
p <- ggplot(df, aes(x, y))
p <- p + stat_bin2d(bins = 20)
p + scale_colour_gradient2(breaks=c(1,2,3,4,5,6))
This produces:
This plot only has 3 breaks at c(5,10,15)
despite my futile attempt to put breaks at c(1,2,3,4,5,6))
Any hints?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…