I'm trying to plot 3D graph with Asymptote. I used a previous post as guidance.
I have well structred X and Y and Z values in 2 files. One with x and y variables and the other file with z matrix. All computations are performed using R. I'm only using Asymptote for plotting.
- Here is xy file with x and y variable (100 rows) in csv format: https://www.dropbox.com/s/rotpeelk9530dsl/xy_new.csv?dl=0
- Here is the z matrix for each combination of x and y (100 x 100) in csv format: https://www.dropbox.com/s/bwefr4te1dew11c/z_new.csv?dl=0
Below is the Asymptote code that was tried so far:
import three;
import grid3;
import graph3;
import palette;
unitsize(5cm,5cm,5cm);
currentprojection=orthographic(18,17,3);
bool renderPRC = true;
if(renderPRC) { ...
// PRC TRUE
settings.prc=true;
settings.embed=true;
}
else {
// RASTERIZE
settings.outformat="png";
settings.prc=false;
settings.render=3;
}
file fic =input("xy_new.csv").line().csv();
file fic1 =input("z_new.csv").line().csv();
real[][] z=fic1.dimension(0,100);
real[][] a=fic.dimension(0,2);
real [][] b=transpose(a);
real [] xpt,ypt;
xpt = b[1];
ypt = b[0];
real[][] zpt=-z;
surface s=surface(zpt,xpt,ypt,Spline);
s.colors(palette(s.map(zpart),Rainbow()));
draw(s);
The output that I get is not a 3D file.
I'm expecting something like this:
The above plot was produced using the following R
function with same x,y and z values:
plot3D::persp3D(x = x, y = y, z = -1*z, col="grey87",cex.axis=1, cex.lab=1,
colkey=FALSE, theta=-30,alpha = 1,zlim=c(-500,-240),ylim=c(0.2,5),
border = "grey50", ticktype="detailed",scale=T,
contour=list(levels = -1*c(240,242.09,242.3,242.8,243,244,245,246,247,247.5,247.8),side ="z",col="grey39"),
xlab="$\\sigma$",ylab="$\\xi$", zlab="Log Likelihood",
lty=0,expand = 0.7)
I have 2 part question:
- Why is my Asymptote plot not in 3d?
- How can I draw contour on top of surface plot?