0

I am trying to convert my figure from Asymptote to PDF. In Asymptote it looks fine. However, in PDF the axis appears behind the drawing.

I use the following command to produce PDF:

asy.exe -f pdf -render 0 fig.asy

MWE:

import graph3;
import three;
import contour3;
size3(250);
currentprojection=orthographic(-5,-9,3);
currentlight = light(-9, -9, 9);
triple v1 = (1, 0, 1);
triple v2 = (0, 1, 1);
triple v3 = (2, 2, 2);
draw(surface(v1--v2--v3--cycle),gray(0.9));
draw(v1--v2--v3--cycle,currentpen+1);
dot(v1);
dot(v2);
dot(v3);
xaxis3("$x$", 0, 2.7, OutTicks(), arrow=Arrow3);
yaxis3("$y$", 0, 2.7, OutTicks(NoZero), arrow=Arrow3);
zaxis3("$z$", 0, 2.7, OutTicks(NoZero), arrow=Arrow3);

How it looks in Asymptote (version 2.38): How it appears in PDF (Adobe Reader):

Any idea or advice is really appreciated!

  • 2
    I do not know if that helps but something seemingly related is mentioned on p. 55 of this great tutorial. One reason why I cannot say more is that I cannot even reproduce the upper screen shot with your code. Nevertheless it may help if you add settings.render=0; settings.outformat="pdf";. – Schrödinger's cat Sep 5 at 17:36
  • Thank you for your suggestion. I have looked at p.55 and I see that certain problems exist. Unfortunately, I cannot understand how to apply that approach to my problem. Adding settings.outformat="pdf"; settings.render=0; take no effect, i.e. PDF with the same issue is produced. But if I click on PDF (enable PRC content), I see the correct image like in the upper figure. – Andrey L. Sep 6 at 10:29
  • Note: If desired you can get rid of the PRC content using settings.prc = false;. I don't think that's your primary goal, but it can make the output easier to debug. – Charles Staats Sep 6 at 17:11
1

With -render=0 it is not possible to have automatic visible/hidden faces managment. It is a 2D projection of the 3D scene. The only advantage is the vectorized output. When you click on your pdf (with adobe) a 3D rendering engine is launched, the PRC engine of Adobe. If you print it or export the output it is a bitmap image and not vectorized. The main advantage is the 3D rendering with visible/hidden faces support. (in fact I do not understand why -render=0 -f pdf gives the superposition of the pdf figure and prc). It is the same with -render=n with n>0, the OpenGL engine and the output is a bitmap image. (see Errors with Asymptote)

With some efforts and for simple 3D pictures it is possible to manage by yourself the visible/hidden faces/lines. But you have to do by yourself (the painting algorithm, depending of the eye...).

In the very specific case it is possible to draw zaxis after by putting the option above=true. Try with

zaxis3("$z$", 0, 2.7, OutTicks(NoZero), arrow=Arrow3,above=true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.