自切换为ggplot2 2.0.0
以来,在定义width
之外的图块的height
和aesthetics
时出现问题。
我使用geom_tile
创建了某种热图,我希望在图块之间留出一点空间,因此我在ggplot2
width=.9
和{{1}的旧版本中使用了参数,但在新版本中失败。
height=.9
实现这一目标的唯一方法是在数据框中添加宽度和高度的列并使用美学。这应该是这样的吗?或者我在这里想念什么?
df <- data.frame(x=letters[1:10], y=rep(LETTERS[1:10], each=10), value=runif(100))
ggplot(df, aes(x, y, fill=value)) + geom_tile()
ggplot(df, aes(x, y, fill=value)) + geom_tile(width=.9, height=.9)
答案 0 :(得分:5)
您无需为数据框添加宽度和高度值。您可以将这两个参数移到aes()
。
ggplot(df, aes(x, y, fill=value)) + geom_tile(aes(width=0.9, height=0.9))