I am trying to add a fixed title to an interactive 3d plot using the rgl package from R, but so far I haven\'t been able to do it. I also would like to have one main title a
This cannot be done in rgl at present.
Similar to the suggestion about test, you can add a legend that stays stationary and use it as your title. See example below from Adding a legend to an rgl 3d plot
legend3d("topright", legend = paste('Type', c('A', 'B', 'C')), pch = 16, col = rainbow(3), cex=1, inset=c(0.02))
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 example
library(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 case Did 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).