# Aligned pictures in Asymptote depending on Label?

I have a confusing problem with Asymptote. I want to draw a contour plot and a surface plot side-by-side and try this code:

``````settings.outformat="pdf";
settings.render=8;
settings.prc=false;

import graph3;
import contour;

real f(pair z) {return (z.x^2+3*z.y^2)*exp(1-z.x^2-z.y^2);}

picture pic1;
size(pic1,175);
int n=10;
real[] c=new real[n];
for(int i=0; i < n; ++i) c[i]=3*i/n;
Label[] Labels=sequence(new Label(int i) {
return Label(c[i] != 0 ? (string) c[i] : "",Relative(unitrand()),    (0,0),UnFill(1bp));
},c.length);
draw(pic1,Labels,contour(f,(-2,-2),(2,2),c),black+1+fontsize(6pt));

picture pic2;
currentprojection=orthographic(0.8,1,1);
defaultrender.merge=true;
size(pic2,175,120,IgnoreAspect);
size3(pic2,175);
draw(pic2,surface(f,(-2,-2),(2,2),Spline),lightgreen);

shipout("test");
``````

I get only the left-hand contour plot! [The character "|" is added to show the right hand side of the image.]

BUT, if I remove the Labels argument from the contour plot, I get both pictures (with no labels, of course).

Why? And what do I do about it?

• It's odd, but both pictures appears OK when the order of the `add` commands is changed: first `add(pic2.fit(),(5mm,0),E);`, then `add(pic1.fit(),(0,0),W);`. Nice function, btw. – g.kov Jan 14 '16 at 15:49
• This is a very strange phenomenon. I have no idea why it's not working. – Charles Staats Jan 18 '16 at 5:27

First, if your primary goal is just to get this particular picture to work right, I suggest you follow the solution of `g.kov` and switch the two `add` statements.

As far as actually figuring out what's wrong, I still don't know the answer, but I have the following piece of data to add to the picture: if you allow the two images to overlap, the 3d image is only shown when it lies on top of the 2d image previously added. Furthermore, the labels that start to the left of the 3d image's left edge are allowed to go on top of the 3d image, but labels that start to the right (specifically the `0.3` label) are hidden underneath it.

``````add(pic1.fit(),(0,0)); Reversing the order of the `add` statements, the entire 3d image is shown and the `0.3` label is permitted on top of it:
``````add(pic2.fit(),(5mm,0),E); 