2

Say I have 3 variables such that

x=1:9
y=c(1,1,1,2,2,2,3,3,3)
z=6:14

How can I rearrange the data so that I can make a contour plot of the data with r? I am getting the message

Error in contour.default(x, y, z) : 
  increasing 'x' and 'y' values expected

Thank you.

4

1 回答 1

1

zmatrix要绘制等高线的值。x并且y是它们各自的位置。r-help 邮件列表中的“Tyler”对此进行了解释,并举例说明了如何转换数据以使事情正常进行。另请参阅帮助中的示例?contour

x = seq(0, 10, by = 0.5)
y = seq(0, 10, by = 0.5)
z <- outer(x, y)

contour(x, y, z)
于 2011-05-01T08:00:34.433 回答