[R] 3D scatterplot, using size of symbols for the fourth variable

Jim Lemon jim at bitwrit.com.au
Mon Jul 23 12:03:55 CEST 2012


On 07/23/2012 06:20 PM, elpape wrote:
> Dear R fans,
>
> I would like to create a scatterplot showing the relationship between 4
> continuous variables. I thought of using the package "scatterplot 3d" to
> have a 3-dimensional plot and then using the size of the symbols to
> represent the 4th variable.
>
> Does anybody know how to do this?
>
Hi Ellen,
The plot is pretty crowded, but you could try this (newdata is your data 
frame):

library(plotrix)
size_n_color(newdata$MI,newdata$TD,size=(newdata$EG_18-10.5)/1000,
  col=color.scale(newdata$Dstar,1,c(0,1,0),c(0,0,1),xrange=c(60,80)),
  yat=c(2.8,3.2,3.6),ylim=c(2.75,3.8),xlab="MI",ylab="TD",
  main="Four dimensional plot")
color.legend(2.3,2.52,2.5,2.57,seq(60,80,by=4),
  color.scale(seq(60,80,by=4),1,c(0,1,0),c(0,0,1)))
mtext("Size = EG_18",side=1,at=2.83,line=3)

Jim



More information about the R-help mailing list