5

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?

CarbonFlambe
  • 1,234
  • 8
  • 13

3 Answers3

8

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:

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • never ceases to amaze me...thank you for link also :) – ubpdqn Mar 14 '16 at 08:52
  • @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. – Mr.Wizard Mar 14 '16 at 08:56
  • 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...:) – ubpdqn Mar 14 '16 at 09:01
2

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.

CarbonFlambe
  • 1,234
  • 8
  • 13
1

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}]
ubpdqn
  • 60,617
  • 3
  • 59
  • 148