2
There is an example in ?plot3d if you are talking about plotting points in a 3d space and colouring them:
有一个例子在?plot3d,如果你说的是在三维空间中绘制点并着色它们:
x
y
z
plot3d(x, y, z, col=rainbow(1000))
But if you mean to colour the points by a 4th variable, say a grouping variable, then we can modify the example above to do this by creating a grouping variable
但是如果你想用第4个变量来着色点,比如说一个分组变量,那么我们可以通过创建一个分组变量来修改上面的例子。
grp
## now select the colours we want
cols
## Now plot
plot3d(x, y, z, col=cols[grp])
OK, is this more what you want?
好的,这是你想要的吗?
X
Y
## Z is now a 100 row object of X,Y combinations
Z
## Add in Z1, which is the 3rd variable
## X,Y,Z1 define the surface, which we colour according to
## 4th variable Z2
Z