How to add legend to scatterplot3d in R

I would like to add a legend to my scatterplot3d. I created 3 separate plots and put them on 1 plot, so I don’t know where the syntax for the legend ("topleft", inset = 0.5) should go

Plot <-scatterplot3d(data$Size,data$Pct,data$bias1, type='h', zlim=c(-20,100), xlab="size", ylab= "Percent", zlab="Bias") Plot$points3d (data$Size,data$Pct,data$Bias2, col="blue", type="h", pch=15, cex=.6) Plot$points3d(data$Size,data$Pct,data$Bias3, col="red", type="h", pch=4, cex=.6) 
+4
source share
1 answer

This is an old question. But I had the same problem and it was solved with the following code. I have four times a year in 3D.

As usual, I created the graphics as follows:

 s3d <- scatterplot3d(...) 

And then they just added the legend:

 legend(s3d$xyz.convert(18, 0, 12), col= c("green","blue", "red", "black"), bg="white", lty=c(1,1), lwd=2, yjust=0, legend = c("2010", "2011", "2012", "Prognose fΓΌr 2013"), cex = 1.1) 
+4
source

Source: https://habr.com/ru/post/1398758/


All Articles