0

I calculated the niche width (from min to max extend) of a species related to 3 different variables. I now want to draw them in r as a single box showing var1 on the x-axis, var2 on the y-axis and var3 on the z-axis. This should result in a single box that is placed along the 3 axes.

I tried the rgl package in r.

# this is the extent of my scale
x <- c(31.94, 9460.00)
y <- c(28, 14375)
z <- c(0.02, 95.11)

# these are the coordinates of my box
x1<- 42.69
y1<- 4
z1<- 0.03
x2<- 3686.996
y2<- 1997.317
z2<- 5.156709

# my code is: 
library(rgl) # load package
open3d() #open plot 
plot3d(x, y, z, xlab="EC 1:5 [mS/cm]", ylab = "Na {mg/kg]", zlab="SAR") # plot axes
printBox(x1,y1,z1,x2,y2,z2) #add box

Unfortunately, this code adds the box (x1,y1,z1) at the lower-left corner of the set axes and extents the box to both, the neg. and pos. direction (x2,y2,z2).

Instead, I would like this code to add the box into the existing coordinates (plot3d()) with the lower-left corner at x1,y1,z1 and the upper left corner at x2,y2,z2.

I would be grateful for any help.

Ricarda
  • 1
  • 1
  • 3
    It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Just asking for package recommendations is considered off-topic for Stack Overflow. – MrFlick Jun 17 '22 at 14:16
  • The plot3d function https://www.rdocumentation.org/packages/rgl/versions/0.108.3.2/topics/plot3d is very basic. – John Garland Jun 17 '22 at 14:42
  • Thanks @MrFlick. I edited my question accordingly. Also thanks to John Garland. – Ricarda Jun 18 '22 at 11:14

0 Answers0