Home > Mobile >  R: Customizing Scatterplots
R: Customizing Scatterplots

Time:10-21

I am using the R programming language. I am trying to follow the answer posted in this previous stackoverflow post (enter image description here

Desired Result:

enter image description here

Can someone please show me what I am doing wrong?

Thanks

CodePudding user response:

The order of height and weight caused the problem.

s3d <- scatterplot3d(my_data$weight, my_data$height,my_data$age, pch = 19, type = c("p"), color = "darkgrey",
                     main = "Regression Plane", grid = TRUE, box = FALSE,  
                     mar = c(2.5, 2.5, 2, 1.5), angle = 55)



# regression plane
s3d$plane3d(model_1, draw_polygon = TRUE, draw_lines = TRUE, 
            polygon_args = list(col = rgb(.1, .2, .7, .5)))

# overlay positive residuals
wh <- resid(model_1) > 0
s3d$points3d(my_data$height, my_data$weight, my_data$age, pch = 19)

enter image description here

  • Related