rand = RandomReal[1, {4, 3, 2}];

Graphics @ Polygon @ rand

Mathematica graphics

Graphics[Polygon /@ rand]

Mathematica graphics

I am losing anti-aliasing when I use the multiple-polygon syntax form of Polygon. Yet it is possible for Mathematica to apply AA as can be shown with:

 Graphics @ Polygon @ rand,
 Antialiasing -> True

(Incidentally this Style-applied AA does not copy with Szabolcs's Image Uploader but the in-Notebook appearance is identical to the second output above.)

  • Why am I losing anti-aliasing here?

  • Is there a system option to turn it on, and with what caveat?

  • 5
    $\begingroup$ It seems with antialiasing on, you get seams between adjacent polygons. It's in the end of possible issues in the Polygon docs. So probably it assumes that by default, with the multiple-polygon syntax form it's more important to avoid seams for adjacent polygons and with the several distinct polygons antialiasing is more important. Just an idea $\endgroup$ – Rojo Jun 24 '12 at 19:51
  • 2
    $\begingroup$ Also, setting the Antialiasing->True globally instead of Automatic, fixes this, but I have no idea what other sideeffects it has $\endgroup$ – Rojo Jun 24 '12 at 20:09
  • $\begingroup$ Maybe one could add the "undocumented" tag. $\endgroup$ – Jens Jun 24 '12 at 20:39
  • $\begingroup$ @Rojo Antialiased polygons don't join properly and will create artefacts in e.g. a ListDensityPlot, try ListDensityPlot[RandomReal[1, {20,3}]]. $\endgroup$ – Szabolcs Jun 24 '12 at 20:41

It seems with antialiasing on, you get seams between adjacent polygons. It's at the end of the possible issues section in the Polygon documentation page.

So probably it assumes that by default, with the all-in-one-polygon syntax form (one Polygon head for multiple polygon representations) it's more important to avoid seams for adjacent polygons, and with the multiple-Polygon-syntax, antialiasing is more important.

Functions such as ContourPlot or ListDensityPlot, that use Polygon to render it's results, use this all-in-one syntax to save space, and require the polygons to join well, so by default antialiasing is off. See Antialiasing option behaves weird (polygon edges visible in ContourPlot) for an example of what can happen with anti-aliasing. You could always set the option Antialiasing to True instead of Automatic, either at global or notebook or cell level, but you will suffer the consequences when using one of these functions.

| improve this answer | |

Antialiasing can be used as a directive inside Graphics:

Table[Graphics[{Antialiasing -> aa, Polygon[rand]}], {aa, {True, False}}]

enter image description here

| improve this answer | |
  • 7
    $\begingroup$ That's a very unusual syntax! $\endgroup$ – Szabolcs Jun 24 '12 at 20:26
  • $\begingroup$ I didn't know this (+1) but it still requires an additional step, and it still doesn't explain what I'm seeing. Any further comment? $\endgroup$ – Mr.Wizard Jun 24 '12 at 20:30
  • 1
    $\begingroup$ It's good to know (+1), but @Mr.Wizard's Style syntax allows the same thing and seems more consistent. $\endgroup$ – Jens Jun 24 '12 at 20:37
  • $\begingroup$ Only that globally forcing Antialiasing -> True would have negative consequences for some scenarios (possibly depending on platform.) $\endgroup$ – Brett Champion Jun 24 '12 at 20:37
  • 4
    $\begingroup$ The difference is due to the behavior of Antialiasing->Automatic (see the documentation for Antialiasing). The behavior of Automatic is not defined (and could change). The current behavior is effectively True for a single polygon and False for a multi-polygon (even it if only has one item). $\endgroup$ – ragfield Jun 24 '12 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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