【发布时间】:2018-01-19 11:15:57
【问题描述】:
我正在尝试使用 R 将矩阵数据绘制到 d*d 网格中。所以我使用了geom_raster 函数。
我的数据包含三个变量:row 和 col 指定每个数据点的位置,w 是我希望使用geom_raster 绘制的数据。
我模拟了下面的三个变量:
row <- rep(1:55, 55)
col <- rep(1:55, 55)
w <- runif(55*55)
为了使用ggplot,我将数据转换成dataframe形式:
df <- data.frame(
row = row, col = col, w = w
)
现在我使用 df 生成绘图
ggplot(data = df, aes(row, col)) + geom_raster(fill = aes(w))
但它返回一个错误提示
stats::complete.cases(df[, vars, drop = FALSE]) 中的错误: 参数的“类型”(列表)无效
我最终不知道如何修复此错误,有人可以帮助我吗?
【问题讨论】:
标签: r ggplot2 geom-raster