在ggplot2中使用函数geom_tile和facet_wrap一起使用时,如何设置不同的审美限制fill,作为scales可以设置free/free_y/free_x在的选项facet_wrap?
以下是显示问题的示例。对于不同type的 data.frame df,范围z可能会如此不同。如果我们用同样的审美界限fill,一些z价值很小的面板,将很难看到细节。
pp <- function (n,r=4) {
x <- seq(-r*pi, r*pi, len=n)
df <- expand.grid(x=x, y=x)
df$r <- sqrt(df$x^2 + df$y^2)
df$z <- cos(df$r^2)*exp(-df$r/6)
df
}
tmp <- pp(20)
tmp$type <- rep(1:4,each=nrow(tmp)/4)
tmp$z <- tmp$z*(10^(tmp$type))
ggplot(tmp,aes(x,y))+geom_tile(aes(fill=z))+facet_wrap(~type,scales="free")
