[R] how to plot three dimension data to filled contour plot or surface plot in R Ask Question
dncdd
dncdd at aliyun.com
Tue Apr 11 08:16:54 CEST 2017
ENV
R 3.3.2
When I have data like:
rdn<-c(0.8,1.8,2.8)
tdn<-c(1,2,3,4,5,6,7,8,9)
idn<-matrix(c(0.3, 0.3, 0.3, 0.2, 0.2, 0.4, 0.1, 0.1, 0.5, 0, 0.2, 0.5, 0, 0.3, 0.6, 0, 0.4, 0.6, 0, 0.4, 0.6, 0, 0.5, 0.7, 0, 0.5, 0.7), nrow=9, ncol=3, byrow=T)
And the matrix looks like(3*9 = 27 data elements):
0.3, 0.3, 0.3,
0.2, 0.2, 0.4,
0.1, 0.1, 0.5,
0, 0.2, 0.5,
0, 0.3, 0.6,
0, 0.4, 0.6,
0, 0.4, 0.6,
0, 0.5, 0.7,
0, 0.5, 0.7
Then I can get a filled.contour with parameters x,y,z. x is tdn, y is rdn, z is the matrix. I already get this.
**My current problem** is:
What If I have three dimension data
r1dn<-c(0.8,1.8,2.8)
r2dn<-c(0.8,1.8,2.8)
tdn<-c(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9)
And (3*3*9 = 81 data elements):
0.8 1.8 2.8
0.8 1.8 2.8 0.8 1.8 2.8 0.8 1.8 2.8
--------------- 81 ---- elements ----------------------
0.3, 0.3, 0.3, 0.3, 0.3, 0.5, 0.3, 0.3, 0.3,
0.2, 0.2, 0.4, 0.2, 0.4, 0.4, 0.4, 0.2, 0.5,
0.1, 0.1, 0.5, 0.2, 0.3, 0.5, 0.4, 0.4, 0.5,
0, 0.2, 0.5, 0.2, 0.2, 0.6, 0.4, 0.5, 0.6,
0, 0.3, 0.6, 0.3, 0.3, 0.6, 0.5, 0.5, 0.7,
0, 0.4, 0.6, 0.2, 0.5, 0.7, 0.5, 0.6, 0.7,
0, 0.4, 0.6, 0, 0.5, 0.6, 0.5, 0.6, 0.9,
0, 0.5, 0.7, 0, 0.6, 0.8, 0.5, 0.7, 0.8,
0, 0.5, 0.7 0, 0.6, 0.8 0.5, 0.8, 0.9
I googled many surface and contour codes but I still not find some code for three dimension data yet. How to do that in R? Say, x is r1dn, y is r2dn, z is tdn, what about the three dimension data? Does ggplot can plot three dimension filled contour or surface plot? Or another alternative solutions?
All I expected is a 3d plot with color changes smoothly and no grid on it.
Looks like:
no grid for next three figures
Those should be 3d filled contour or 3d surface plot.
Thanks for your time.
[1]: https://i.stack.imgur.com/z6u3p.png
[2]: https://i.stack.imgur.com/MEnFn.png
[3]: https://i.stack.imgur.com/Ri29w.png
[4]: https://i.stack.imgur.com/CdCqL.jpg
[5]: https://i.stack.imgur.com/Pt1Nw.jpg
[[alternative HTML version deleted]]
More information about the R-help
mailing list