I'd like to use Asymptote to compose an existing EPS file and draw some stuff onto it. I'm doing this using the suggested method of using label() and graphic() to place the EPS file on the canvas. The problem is that the imported graphics, being treated as a label, stay on top of all drawing that is done afterwards.

Let's say I have an EPS file generated using the following Asymptote file foo.asy (in my case the EPS actually contains a raster image, so I can't just include the commands to create the EPS in my final Asymptote file):

fill(circle((0, 0), 10), blue + white);

And now I include the EPS file from the following Asymptote file bar.asy:

label(graphic("foo.eps"), (0, 0));
draw((-10, -10) -- (10, 10), black + 2);

This results in the blue circle being drawn on top of the black line.

Is there either a way to somehow draw ontop of a label or is there another way to include an EPS file without using label()?

  • 2
    Have you tried using the layer() command? Commented Oct 9, 2015 at 21:12
  • @CharlesStaats No. It seems I didn't thoroughly read the documentation I linked to. :( Commented Nov 12, 2015 at 14:34

1 Answer 1


An example of using Asymptote to draw on top of an image from a file may be found here:


The key step you are missing is to include the line


after you include the image, but before you draw anything that should go on top of it.

Explanation (for general readers—the OP seems to understand this): In Asymptote (excluding 3d stuff), by default, labels are always on top of "drawing" elements so that the labels won't be hidden. Since images are imported as a kind of label, only other labels will go on top of it; drawing elements will go beneath it, and themselves will be hidden.

However, the layer() command changes the default: anything after a layer() command goes on top of everything before it, allowing drawn elements to go on top of labels.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .