TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In Asymptote, I'd like to draw two intersecting planes, one with a solid color and another with some pattern (e.g. checkerboard), so that it would look okay if printed black and white. However, the pattern module doesn't appear to work.

The code below is what I'm trying to get to work, with the statement that I wished drew that plane commented out (I understand of course that function doesn't exist, I just don't know which one to use).

settings.prc = false;
import three;
import graph3;
import patterns;

real rot_param = 0.01;
currentlight = (4,-1,4);

render render = render(compression=Low, merge = true);

limits((0,0,0), (3,3,3));

real delta = 0.75;
real dterm = (1-delta)/delta;

draw(surface(O -- (dterm,0,0) -- (3,3-dterm,0) -- (3,3,0) -- cycle), orange+opacity(0.5), render);
draw(surface(O -- (3,3,0) -- (0,3,0) -- cycle), orange+opacity(0.5), render);
draw(surface(O -- (3,3,0) -- (3,3,3) -- (0,0,3) -- cycle), lightred+opacity(0.5), render);
draw(surface((dterm,0,0) -- (3,3-dterm,0) -- (3,3-dterm,3) -- (dterm,0,3) -- cycle), lightblue+opacity(0.5), render);

// Does not work!
//filldraw(surface((dterm,0,0) -- (3,3-dterm,0) -- (3,3-dterm,3) -- (dterm,0,3) -- cycle), pattern("checker"));

draw(O -- 3.5X,arrow=Arrow3);
draw(O -- 4Y,dashed, arrow=Arrow3);
draw(O -- 4Z,arrow=Arrow3);

draw(box((0,0,3),(3,3,3)), black+linewidth(0.6pt));
draw((0,3,0) -- (0,3,3), dashed);
draw((3,3,0) -- (3,3,3));
draw((3,0,0) -- (3,0,3));

This is how it looks (I'd like to make at least the blue plane checkerboard): Generated plot

I would be very grateful if anyone knows how to do this. In case you can't tell I have some other problems too, so I'll just throw these out there if anyone happens to know:

  • I'm using perspective but I'd like to use the "oblique" perspective except from "below", so that the axis pointing "out of the screen" ($\phi(C,\theta_0)$ ) is actually pointing up and to the left a bit. I've tried to approximate it as you can see. Is there a way to do this?
  • How do I get the last "3"s to show up as labels on the axis?
  • I don't want the vertical axis to scale (I want it bigger than it appears, so I'm just relabeling, e.g. the 1). Is there a way to do this automatically?
share|improve this question
The simplest solution to the checker problem is probably to use a nested for loop to draw each square as a separate surface. – Charles Staats May 21 '14 at 1:16
Ah, that's too bad there's not something more elegant.... And the cross-hatch I'm guessing is to draw lines using a loop too? – fltfan May 21 '14 at 1:27
You might check out the grid3 module. You might also check out Figure 70 on this page. Any method you use will require you to draw the surface using a different method than you are using, and the nested for loop is by far the simplest method to learn. – Charles Staats May 21 '14 at 2:49
For the oblique perspective from below, try currentprojection = oblique(angle=-45);. According to the documentation, "If an optional real argument is given, the negative z axis is drawn at this angle in degrees." – Charles Staats May 21 '14 at 2:53
Thanks for all the responses. Setting angle=-45 doesn't bend the arrow upward but apparently people have already tried and failed playing with the parameter (playing with it myself I can at most get it to be "horizontal" on the page: tex.stackexchange.com/questions/125027/… – fltfan May 21 '14 at 3:21
up vote 8 down vote accepted

Here's a minimal example showing an elegant(?) way to set up a checkerboard pattern on a surface. To use this you need control over how exactly the surface is built out of patches; this is easiest to accomplish by constructing the surface as a parametric graph and using the nu= and if necessary the nv= parameters.

\documentclass[margin=10pt, convert]{standalone}
import graph3;      //Need graph3, not just three, for parametric surfaces.

triple uaxis = X, vaxis = Y, c = O;
int n = 8;

triple plane(pair coords) {
    return c + coords.x*uaxis + coords.y*vaxis;

surface s = surface(plane, (0,0), (1,1), nu=n);

material[] surfacepen = new material[] {red, green};
surfacepen.cyclic = true;
if (n % 2 == 0) {
    surfacepen = sequence(new material(int i) {
            if (i >= n) ++i;
            return surfacepen[i];

draw(s, surfacepen=surfacepen);

The result:

enter image description here

share|improve this answer

Run with xelatex or latex->dvips->ps2pdf:


\multido{\iA=0+15}{18}{%  Only for the animation, can be deleted
\psset{lightsrc=viewpoint,viewpoint=30 \iA\space 20 rtp2xyz,Decran=25}
   fcol= /t 0 def 0 1 63 { dup dup 8 mod 0 eq { /t t 1 add def } if 
         t add 2 mod 0 eq { (Green) }{ (red) } ifelse } for, 
  base=-4 4 -4 4]
}% end of multido


enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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