I am using the persp() function to make a 3d plot.
I just want to add a greek letter or math expression to the axes labels, but that has proven to be difficult. I have tried the following, but it didn't work:
rm()
library(graphics)#for 3d plot
beta_grid=c(1,2,3,4)
alpha_grid=c(1,2,3,4)
z=matrix(c(1,2,3,4,5,6,7,8,1,1,1,1,1,1,1,1),4)
labNames <- c('xLab','yLab')
xlab <- bquote(.(labNames[1]) ~ x^2)
ylab <- bquote(.(labNames[2]) ~ y^2)
persp(alpha_grid, beta_grid, z,theta=45, phi=45,xlab = xlab, ylab=ylab)
I have also tried this more obvious solution:
persp(alpha_grid, beta_grid, z,theta=45, phi=45,main=expression(x^2+gamma),xlab=expression(x^2),ylab=expression(gamma))
but as you can see, this only works for the tile of the graph, not for the axes (see figure below).
Any help on how to fix this issue?


