3
默認情況下,geom_raster
創建一個漸變圖例,該圖例略微超出數據限制。防止擴展guide_colourbar
例如:
library(ggplot2)
p1 <- ggplot(data=cbind(expand.grid(x=1:10, y=1:10), z=seq(0, 100, length=100)),
aes(x=x, y=y, fill=z)) +
geom_raster() +
coord_equal() +
scale_x_continuous(expand=c(0, 0)) +
scale_y_continuous(expand=c(0, 0))
p1
我可以防止顏色條從延伸超出這些限制(即,在上面的例子中0和100)?設置limits=c(0, 100)
沒有幫助,並設置draw.ulim
和draw.llim
到FALSE
只是隱藏了極致蜱,但仍繪製相同的斜坡,如:
p1 + scale_fill_continuous(
limits=c(0, 100), guide=guide_colorbar(draw.ulim=FALSE, draw.llim=FALSE))