Next: , Previous: , Up: Tutorial   [Contents][Index]


3.4 Labels

Adding labels is easy in Asymptote; one specifies the label as a double-quoted LaTeX string, a coordinate, and an optional alignment direction:

size(3cm);
draw(unitsquare);
label("$A$",(0,0),SW);
label("$B$",(1,0),SE);
label("$C$",(1,1),NE);
label("$D$",(0,1),NW);

labelsquare

Asymptote uses the standard compass directions E=(1,0), N=(0,1), NE=unit(N+E), and ENE=unit(E+NE), etc., which along with the directions up, down, right, and left are defined as pairs in the Asymptote base module plain (a user who has a local variable named E may access the compass direction E by prefixing it with the name of the module where it is defined: plain.E).