levelplot不显示内容

时间:2013-04-02 12:23:55

标签: r levelplot

我是功能级别情节的新手。 Ich有x,y,z,我想通过以下方式可视化水平图:

> require(lattice)



> head(z)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,]  4.5  4.7  4.6  4.6  4.6  4.6  4.6  4.6  4.7
[2,]  4.5  4.6  4.6  4.6  4.6  4.6  4.6  4.6  4.7
[3,]  4.5  4.7  4.6  4.6  4.6  4.6  4.7  4.6  4.7
[4,]  4.5  4.6  4.6  4.6  4.6  4.6  4.6  4.6  4.7
[5,]  4.6  4.6  4.6  4.6  4.6  4.6  4.6  4.6  4.7
[6,]  4.5  4.7  4.6  4.6  4.6  4.6  4.6  4.6  4.7

> head(y)
     [,1]
[1,]    1
[2,]    2
[3,]    3
[4,]    5
[5,]    7
[6,]   10

> head(x)
[1] "2013-01-03 04:30:00 GMT" "2013-01-03 04:45:00 GMT" "2013-01-03 05:00:00 GMT"
[4] "2013-01-03 05:15:00 GMT" "2013-01-03 05:30:00 GMT" "2013-01-03 05:45:00 GMT"

z代表水温和y水深

我想以下列方式绘制数据:

> levelplot(z~x*y)

正确绘制了轴和图例,但根本没有绘制内容。任何人都可以帮助我吗?

祝你好运, 菲利普

1 个答案:

答案 0 :(得分:3)

虽然我不知道您为什么尝试不起作用,但似乎使用levelplot.array代替levelplot.formula正常工作(指定了aspect="fill"):

x <- as.POSIXct(x) #make sure x are POSIXct and not just characters
levelplot(z, row.values=x, column.values=y, aspect="fill")

enter image description here