Writing:

Normal@ParametricPlot[{x, x^2 t}, {x, 0, 2}, {t, 0, 1}] /. 
p : {__Polygon} :> Graphics`PolygonUtils`PolygonCombine[p]

I get:

enter image description here

but if I write:

Normal@ParametricPlot[{x, x^2 t}, {x, 0, 2}, {t, 0, .1}] /. 
p : {__Polygon} :> Graphics`PolygonUtils`PolygonCombine[p]

I get:

enter image description here

How can I avoid this problem by having to use this function?

up vote 6 down vote accepted

A small modification of the original code solves the problem:

Normal@ParametricPlot[{x, x^2 t}, {x, 0, 2}, {t, 0, .1}] /. 
 p : {{__Polygon} ..} :> Graphics`PolygonUtils`PolygonCombine[p]

output

The new code also works for the initial problem.

  • Thanks, it works perfectly! – TeM Aug 14 at 8:44

You can use Graphics`PolygonUtils`PolygonCombine on all polygons rather than on groups of polygons separately:

pp = ParametricPlot[{x, x^2 t}, {x, 0, 2}, {t, 0, .1}] ;
allpolygons = Join @@ Cases[Normal@pp, {__Polygon}, Infinity];
Graphics[{ EdgeForm[Darker@LightBlue], Opacity[.5, LightBlue],  
  Graphics`PolygonUtils`PolygonCombine[allpolygons]}, Options[pp]]

enter image description here

  • 1
    (+1) Or simpler: Normal@ParametricPlot[{x, x^2 t}, {x, 0, 2}, {t, 0, .1}] /. p : {{__Polygon} ..} :> Graphics`PolygonUtils`PolygonCombine[p]. – Alexey Popkov Aug 14 at 8:36
  • @AlexeyPopkov, i could have sworn that I tried that first; somehow it didn't work then:) You might want to post that as an answer. – kglr Aug 14 at 8:38
  • Simply brilliant, thanks to both! P.S .: is it possible to find a list of the unofficial features of Wolfram Mathematica? – TeM Aug 14 at 8:43
  • 1
    @TeM, some are collected in What are some useful, undocumented Mathematica functions? – kglr Aug 14 at 8:57

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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