[R] how to plot three dimension data to filled contour plot or surface plot in R Ask Question

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Tue Apr 11 16:27:25 CEST 2017


Ggplot does not do xyz. Look at package lattice or package rgl instead.
-- 
Sent from my phone. Please excuse my brevity.

On April 10, 2017 11:16:54 PM PDT, dncdd via R-help <r-help at r-project.org> wrote:
>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]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list