6
$\begingroup$

I have:

Graphics[{ LightBlue, Polygon[{{2/3, 0}, {2, 0}, {2, 1}, {3, 1}, {3, 3}, {2/3, 0}}], EdgeForm[Black], White, Opacity[0], Rectangle[{0, 0}, {1, 1}], Rectangle[{1, 0}, {2, 1}], Rectangle[{1, 1}, {2, 2}], Rectangle[{2, 1}, {3, 2}], Rectangle[{2, 2}, {3, 3}], Red, Thick, Line[{{2/3, 0}, {3, 3}}] }, Axes -> True] 

But my red line does not show up. Could it have something to do with the way I constructed my rectangles. It is last, so I expected it to be on the top layer.

Maybe I should ask is there a way to use the Rectangle and Polygon command with no filling?

Update (Thanks to Rahul): Excellent advice. This worked.

Graphics[{ LightBlue, Polygon[{{2/3, 0}, {2, 0}, {2, 1}, {3, 1}, {3, 3}, {2/3, 0}}], {FaceForm[None], EdgeForm[Black], Rectangle[{0, 0}, {1, 1}], Rectangle[{1, 0}, {2, 1}], Rectangle[{1, 1}, {2, 2}], Rectangle[{2, 1}, {3, 2}], Rectangle[{2, 2}, {3, 3}]}, Red, Thick, Line[{{2/3, 0}, {3, 3}}] }, Axes -> True] 

enter image description here

$\endgroup$
2
  • 5
    $\begingroup$ It's because you set Opacity[0], so the line is completely invisible. To disable filling, use FaceForm[None] instead. $\endgroup$ Commented Dec 5, 2015 at 20:42
  • $\begingroup$ @Rahul Thanks for the help. I learned a lot with the new FaceForm[None] command. $\endgroup$ Commented Dec 5, 2015 at 21:35

1 Answer 1

5
$\begingroup$
Graphics[ { LightBlue, (* valid until the next color spec *) Polygon[{{2/3, 0}, {2, 0}, {2, 1}, {3, 1}, {3, 3}, {2/3, 0}}], EdgeForm[Black], White, Opacity[0], (* valid until the next opacity spec *) Rectangle[{0, 0}, {1, 1}], Rectangle[{1, 0}, {2, 1}], Rectangle[{1, 1}, {2, 2}], Rectangle[{2, 1}, {3, 2}], Rectangle[{2, 2}, {3, 3}], Red, Thick, (* restore normal opacity *) Opacity[1], Line[{{2/3, 0}, {3, 3}}], }, Axes -> True] 

enter image description here

$\endgroup$
0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.