4

Anyone knows how to alter width-length aspect ratio of xy plane with plot3D package? For example, how to make x axis appear twice the length of y axis (without changing data values):

plot3D::persp3D(z = volcano)

image

Karolis Koncevičius
  • 9,417
  • 9
  • 56
  • 89
Oleg Melnikov
  • 3,080
  • 3
  • 34
  • 65

1 Answers1

3

This worked for me:

persp3D(x=1:nrow(volcano)*2, y=1:ncol(volcano), z=volcano, scale=FALSE)

image

Karolis Koncevičius
  • 9,417
  • 9
  • 56
  • 89
  • Thanks for the reply. I do not want to change data values, including those of x-axis. Is there another way? For example, something like `rgl::persp3d(...aspect=c(2,2,1)...)` – Oleg Melnikov Mar 16 '16 at 01:57
  • No problem. Regarding x-axis - please note that there is no x values to change in the data. What `x=1:nrow(volcano)*2` does is tells the plot what values of x to put the points on. And this line says: take the row numbers of volcano matrix `(1:81)` and multiply them by two thus expanding them. This will change nothing in volcano data. – Karolis Koncevičius Mar 16 '16 at 09:42
  • The thing is that my `x` and `y` values are more complex (dates, times) and I'd rather keep them as they are. – Oleg Melnikov Mar 16 '16 at 18:11
  • Maybe consider using a different library then? Have you tried `rgl` for 3d plots? Also I am not sure where this aversion from expanding x values just for plotting comes from. If some function had `x-scale` variable that can be set to 2, but inside the function did the same thing like we are doing here (multiplying x values by 2) would that be OK to you? – Karolis Koncevičius Mar 16 '16 at 20:17
  • Each library has its disadvantages :) Yes, I tried rgl (see my comment above), but it's troubling in other aspects... – Oleg Melnikov Mar 18 '16 at 21:28