简体   繁体   中英

Scale bar using RGL

is there a way I could get scale when I run a plot in RGL in R Studio for a point cloud?

I currently have a point cloud from a las file and when I plot the data it process with a different color corresponding to changing height in the point cloud. Is there a way to get a sale bar that shows the corresponding color in RGL?

Here's one way: divide the plot region into two parts, one for the plot, one for the scale. Plot your points in one region, then use bgplot3d() in the other region to plot a scale.

For example:

library(rgl)     # for the plot
library(plotrix) # for the scale

x <- rnorm(1000); y <- rnorm(1000); z <- seq(-3, 3, len=1000)
open3d(windowRect = c(10, 10, 500, 500))
layout3d(matrix(1:2, 1,2), c(0.8, 0.2), 1)
plot3d(x, y, z, col=rainbow(1000)[rank(z)])
next3d()
bgplot3d({
  plot.new()
  color.legend(0.1, 0.1, 0.9, 0.9, 
               rect.col=rainbow(1000), 
               legend=(-3):3, gradient="y", cex = 1.5)
  })

This produces

截图

One problem with this method of drawing a scale is that it is a bitmap drawing, so if you resize the plot, it will tend to look bad. If you want one that will scale itself, you might want to investigate the plot3Drgl package.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM