Put a fixed title in an interactive 3D plot using rgl package, R
Putting a title in a RGL plot is now possible, thanks to an update dating from last year.
The idea is to use the new function bgplot3d
which outputs to the background of the RGL window, as if it was a normal plot.
For example:
# A minimal plot3d examplelibrary(rgl)a = matrix(runif(3000), ncol=3)plot3d(a, col = rainbow(100)[cut(a[,1], breaks = seq(0,1,le=101), include.lowest = T)])bgplot3d({ plot.new() title(main = 'This is the main title', line = 3) mtext(side = 1, 'This is a subtitle', line = 4) # use here any other way you fancy to write your title})
Which gives:
There is one pretty important caveat though, stated as a note in the help page for bgplot3d
:
Because the background plots are drawn as bitmaps, they do not resize very gracefully. It's best to size your window first, then draw the background at that size.
To reproduce your script kde is missing (a library not included) ... in any caseDid you consider using:adding after the movie:
text3d(x=0.08, y=0.97, z=0.03, title.main ,col="Blue")
where: x,y,z are locations in your graphic. I have use this together with scatter3d (using also using rgl).