[R] scatterplot3d + density() + polygon(color)

klebyn klebyn at yahoo.com.br
Wed Sep 28 04:14:29 CEST 2005


Hi R Users,

How to use the function polygon()
together with the package scatterplot3d?

I am trying to color below of the curves
defined for the function density().

I tried to use the site: R GRAPH GALLERY
as tutorial.

I tried to adapt the example of this page:
[figure]:
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=30

[code]:
http://addictedtor.free.fr/graphiques/sources/source_30.R

to my case but I do not obtain success.

Somebody could give a tip to me, please?

I am thankful anticipatedly.

Cleber Borges



#My code test
##############
library(scatterplot3d)
x=c(0.4, -1.2, .8, -.7, 0)

d1 = density(x[1],bw=1.2, from=-3.0,  to=3.0  )
d2 = density(x[2],bw=0.8, from=-3.0,  to=3.0  )
d3 = density(x[3],bw=0.6, from=-2.5,  to=2.5  )
d4 = density(x[4],bw=0.5, from=-2.0,  to=2.0  )
d5 = density(x[5],bw=0.3, from=-1.5,  to=1.5  )

sx = c(d1$x,d2$x,d3$x,d4$x,d5$x)
sy = c(d1$y,d2$y,d3$y,d4$y,d5$y)
sz = c(rep(0.1,512),rep(0.2,512),rep(0.3,512),rep(0.4,512),rep(0.5,512))

scatterplot3d(x=sx,y=sz,z=sy,type='l')
##############




More information about the R-help mailing list