geom_tile不再理解美学之外的宽度和高度

时间:2016-01-25 07:03:50

标签: r ggplot2

自切换为ggplot2 2.0.0以来,在定义width之外的图块的heightaesthetics时出现问题。 我使用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)

1 个答案:

答案 0 :(得分:5)

您无需为数据框添加宽度和高度值。您可以将这两个参数移到aes()

ggplot(df, aes(x, y, fill=value)) + geom_tile(aes(width=0.9, height=0.9))