5
$\begingroup$

In 10.3.1 there was a Graphics option -- it might be a sub-option of Method -- which erases the thin line visible at the join between these two Polygons:

Graphics[{Polygon[{{0, 0}, {1, 0}, {0, 1}}], Polygon[{{1, 0}, {0, 1}, {1, 1}}]}]

polygons showing line at join

I presume it is still present in 10.4. Can someone remind me what it is?

$\endgroup$
  • 2
    $\begingroup$ In this case, adding EdgeForm[Black] at the beginning fixes it. Not very general, though. EdgeForm[Opacity[1]] might be more general. $\endgroup$ – march Mar 14 '16 at 5:23
  • $\begingroup$ Converting to GraphicsComplex may also be an option. $\endgroup$ – Yves Klett Mar 14 '16 at 6:13
  • $\begingroup$ Related, perhaps a duplicate: (381), (2629) $\endgroup$ – Mr.Wizard Mar 14 '16 at 8:11
  • $\begingroup$ @march Nice solution. However that's still not really general; consider Graphics[{Red, EdgeForm[Opacity[1]], Polygon[{{0, 0}, {1, 0}, {0, 1}}], Polygon[{{1, 0}, {0, 1}, {1, 1}}]}] $\endgroup$ – Mr.Wizard Mar 14 '16 at 8:19
  • $\begingroup$ Related: 80824 $\endgroup$ – Edmund Mar 14 '16 at 11:03
8
$\begingroup$

Antialiasing -> False will do it, which surprisingly can be used in-line as a directive:

Graphics[{Antialiasing -> False, Polygon[{{0, 0}, {1, 0}, {0, 1}}], 
  Polygon[{{1, 0}, {0, 1}, {1, 1}}]}]

Because the multiple-polygon form of Polygon (presently?) renders without antialiasing by default this also works:

Graphics[{Polygon[{{{0, 0}, {1, 0}, {0, 1}}, {{1, 0}, {0, 1}, {1, 1}}}]}]

Reference:

$\endgroup$
  • $\begingroup$ never ceases to amaze me...thank you for link also :) $\endgroup$ – ubpdqn Mar 14 '16 at 8:52
  • $\begingroup$ @ubpdqn Thanks for the kind words. I do wonder if RegionUnion is not a better solution in many cases however. I hesitate to vote only because it doesn't answer the direct question that was asked. Then again sometimes indirect answers are the best answers. $\endgroup$ – Mr.Wizard Mar 14 '16 at 8:56
  • $\begingroup$ I assumed this MWE was for more complex purposes, else you could just use rectangle. It is one of the joys of MMA and this site that there is more than one way to do things and wisdom is in choice including caveat emptor...:) $\endgroup$ – ubpdqn Mar 14 '16 at 9:01
2
$\begingroup$

I have found the option I'm looking for: Method->"TransparentPolygonMesh"->True. The documentation for Graphics says it should erase the adjoining lines between Polygons. However:

For Graphics, Antialiasing->False (as a directive) erases the line, as Mr.Wizard says; Method->"TransparentPolygonMesh" apparently does nothing.

For GeoGraphics (with GeoBackground->None), both Antialiasing->True and Method->"TransparentPolygonMesh"->True erase the line, regardless of the setting of the other.

Since the defaults are Antialiasing->True and Method->"TransparentPolygonMesh"->False, Graphics by default show the lines, but GeoGraphics do not.

$\endgroup$
1
$\begingroup$

Perhaps:

pg = {Polygon[{{0, 0}, {1, 0}, {0, 1}}], 
   Polygon[{{1, 0}, {0, 1}, {1, 1}}]};
ru = RegionUnion @@ pg;
RegionPlot[ru, PlotStyle -> Yellow, Frame -> False

enter image description here

or

BoundaryMesh[DiscretizeRegion@ru, MeshCellStyle -> {1 -> {Black, Thick}, 2 ->Yellow}]
$\endgroup$

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.