1
$\begingroup$

Hi I have a very simple question but I haven't been able to find a set answer. How would I draw a bunch of polygons on one graph. The following does not work:

Graphics[{Polygon[{{989, 1080}, {568, 1080}, {834, 711}}], 
  Polygon[{{1184, 1080}, {989, 1080}, {834, 711}, {958, 541}}], 
  Polygon[{{1379, 1080}, {1184, 1080}, {958, 541}, {1082, 370}}], 
  Polygon[{{1470, 1080}, {1379, 1080}, {1082, 370}, {1140, 291}}], 
  Polygon[{{1665, 1080}, {1470, 1080}, {1140, 291}, {1263, 120}}], 
  Polygon[{{1756, 1080}, {1665, 1080}, {1263, 120}, {1321, 41}}], 
  Polygon[{{1394, 0}, {1920, 0}, {1920, 1080}, {1846, 1080}}], 
  Polygon[{{1352, 0}, {1394, 0}, {1846, 1080}, {1756, 1080}, {1321, 
     41}}], Polygon[{{931, 0}, {1352, 0}, {1084, 367}}], 
  Polygon[{{736, 0}, {931, 0}, {1084, 367}, {961, 537}}], 
  Polygon[{{540, 0}, {736, 0}, {961, 537}, {836, 708}}], 
  Polygon[{{450, 0}, {540, 0}, {836, 708}, {779, 788}}], 
  Polygon[{{255, 0}, {450, 0}, {779, 788}, {654, 958}}], 
  Polygon[{{164, 0}, {255, 0}, {654, 958}, {597, 1038}}], 
  Polygon[{{73, 0}, {164, 0}, {597, 1038}, {568, 1080}, {524, 1080}}],
   Polygon[{{0, 0}, {73, 0}, {524, 1080}, {0, 1080}}]}]

I apologize for how basic this question is. If anyone could steer me in the right direction it would be greatly appreciated.

$\endgroup$
4
  • $\begingroup$ Have you seen this? Be sure to look under "Applications", "Options" and "Neat Examples". $\endgroup$
    – C. E.
    Commented Nov 18, 2014 at 18:36
  • $\begingroup$ Sorry. Edited question. For some reason I couldn't post the code (getting nondescript error) and had to post it as an image. $\endgroup$
    – Julian
    Commented Nov 18, 2014 at 18:38
  • 1
    $\begingroup$ @Julian We can't really reproduce your errors as nobody is going to sit down and re-write the code you posted. Try using other ways to share the code :) $\endgroup$
    – Sektor
    Commented Nov 18, 2014 at 18:41
  • $\begingroup$ Very sorry! :) here is the code. pastebin.com/wj0D6CGs $\endgroup$
    – Julian
    Commented Nov 18, 2014 at 18:49

2 Answers 2

3
$\begingroup$
polys = {Polygon[{{989, 1080}, {568, 1080}, {834, 711}}],
   Polygon[{{1184, 1080}, {989, 1080}, {834, 711}, {958, 541}}],
   Polygon[{{1379, 1080}, {1184, 1080}, {958, 541}, {1082, 370}}],
   Polygon[{{1470, 1080}, {1379, 1080}, {1082, 370}, {1140, 291}}],
   Polygon[{{1665, 1080}, {1470, 1080}, {1140, 291}, {1263, 120}}],
   Polygon[{{1756, 1080}, {1665, 1080}, {1263, 120}, {1321, 41}}],
   Polygon[{{1394, 0}, {1920, 0}, {1920, 1080}, {1846, 1080}}],
   Polygon[{{1352, 0}, {1394, 0}, {1846, 1080}, {1756, 1080}, {1321, 41}}],
   Polygon[{{931, 0}, {1352, 0}, {1084, 367}}],
   Polygon[{{736, 0}, {931, 0}, {1084, 367}, {961, 537}}],
   Polygon[{{540, 0}, {736, 0}, {961, 537}, {836, 708}}],
   Polygon[{{450, 0}, {540, 0}, {836, 708}, {779, 788}}],
   Polygon[{{255, 0}, {450, 0}, {779, 788}, {654, 958}}],
   Polygon[{{164, 0}, {255, 0}, {654, 958}, {597, 1038}}],
   Polygon[{{73, 0}, {164, 0}, {597, 1038}, {568, 1080}, {524, 1080}}],
   Polygon[{{0, 0}, {73, 0}, {524, 1080}, {0, 1080}}]};

The default fill for Polygon is Black so you end up with an almost completely black field. The edges are very faint.

Graphics[polys]

enter image description here

You can use EdgeForm to clearly see the edges of the polygons.

Graphics[{EdgeForm[Red], polys}]

enter image description here

Or you can color the polygons

Graphics[
 Thread[{
   Table[
    ColorData[RandomInteger[{1, 113}]][n],
    {n, Length[polys]}],
   polys}]]

enter image description here

$\endgroup$
3
$\begingroup$

your plot is ok. actually all polygons are plotted but because the EdgeForm & FaceForm, the plot is not clear. check this:

poly = {Polygon[{{989, 1080}, {568, 1080}, {834, 711}}], 
   Polygon[{{1184, 1080}, {989, 1080}, {834, 711}, {958, 541}}], 
   Polygon[{{1379, 1080}, {1184, 1080}, {958, 541}, {1082, 370}}], 
   Polygon[{{1470, 1080}, {1379, 1080}, {1082, 370}, {1140, 291}}], 
   Polygon[{{1665, 1080}, {1470, 1080}, {1140, 291}, {1263, 120}}], 
   Polygon[{{1756, 1080}, {1665, 1080}, {1263, 120}, {1321, 41}}], 
   Polygon[{{1394, 0}, {1920, 0}, {1920, 1080}, {1846, 1080}}], 
   Polygon[{{1352, 0}, {1394, 0}, {1846, 1080}, {1756, 1080}, {1321, 
      41}}], Polygon[{{931, 0}, {1352, 0}, {1084, 367}}], 
   Polygon[{{736, 0}, {931, 0}, {1084, 367}, {961, 537}}], 
   Polygon[{{540, 0}, {736, 0}, {961, 537}, {836, 708}}], 
   Polygon[{{450, 0}, {540, 0}, {836, 708}, {779, 788}}], 
   Polygon[{{255, 0}, {450, 0}, {779, 788}, {654, 958}}], 
   Polygon[{{164, 0}, {255, 0}, {654, 958}, {597, 1038}}], 
   Polygon[{{73, 0}, {164, 0}, {597, 1038}, {568, 1080}, {524, 
      1080}}], Polygon[{{0, 0}, {73, 0}, {524, 1080}, {0, 1080}}]};

Graphics[#] & /@ poly


Graphics[{FaceForm[], EdgeForm[Black], #}] & /@ poly

Show[%]
$\endgroup$
1
  • $\begingroup$ Thank you for your answer. I am not at my computer that has Mathematica installed on it, but I will check this later tonight when I am! $\endgroup$
    – Julian
    Commented Nov 18, 2014 at 19:05

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