FIXING SCALE RANGE OF PLOT3D

Asked 2 years ago, Updated 2 years ago, 37 views

Currently, using R's lot3d library, we aim to create a graph with the scale bar fixed (color fixed as much as possible) when displaying 10x10 size matrix in three dimensions.

You can use the following code to display a graph for a single matrix (assuming D1).

library(plot3D)
matrix(rexp(100, rate=.3), ncol=10) ->D1
persp3D(z=D1,zlim=c(-50,50),phi=30,contour=list(nlevels=20,col="yellow"),image=list(col=grey(seq(0,1,length.out=100))))

What I'm having trouble with right now is that if I create another matrix (let's say D2) and display it again in persp3d, the scale displayed on the right side of each graph will be different.(D1 and D2 are deliberately created in a different range.)

 matrix (rexp(100, rate=.8), ncol=10) - > D2
persp3D(z=D2,zlim=c(-50,50),phi=30,contour=list(nlevels=20,col="yellow"),image=list(col=grey(seq(0,1,length.out=100))))

This is the result.matrix contains random numbers, so the results change slightly every time

Here, D1 (left side) scales from 2 to 6, while D2 (right side) scales from 0.5 to 2.5.I would like to fix this scale difference to any scale (for example, 1 to 5).I changed the attiribute of persp3D by referring to the web, but it didn't work, so I'm asking you a question here.

If anyone knows how to fix the scale, please let me know.
Also, I would appreciate it if you could let me know if it is possible other than lot3d.

Thank you for your cooperation.

r

2022-09-30 21:23

1 Answers

Try the code below.

library(plot3D)
matrix(rexp(100, rate=.3), ncol=10) ->D1
persp3D(
  z = D1,
  zlim = c (-50, 50),
  phi = 30,
  tour=list(nlevels=20, col="yellow"),
  image=list(col=grey(seq(0,1,length.out=100))),
  clim=c(1,5)#Add here
)

If you just want to fix it, you can specify it with clim=.However, if there is a value that exceeds the area specified in the claim, it will be treated as NA.
This is my first time using this package, so I tried it while reading the help document for this function.There are many other color bar settings, so please check ?plot3D::personp3D for more information.


2022-09-30 21:23

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.