6
$\begingroup$

I'm trying to fill a parametric plot, but I get this ugly seam for some values of $a$. Observe the following code:

f[t_, r_, a_] := {r*Cos[2 Pi*t]*Sin[Pi*t + 2*Pi*a], 
   r*Sin[4 Pi*t - 2*Pi*a]*Cos[2*Pi*t + 2*Pi*a]};
ff[a_] := 
  ParametricPlot[f[t, r, a], {t, -1, 1}, {r, 0.5, 1}, 
   PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}, Axes -> False, 
   Frame -> False, PlotPoints -> 60];
ff[0.1]

enter image description here

As you can see, there's this ugly seam that appears, and it only appears for certain values of $a$ (not all)! I don't know what's causing it, but given that I'm trying to export it as an animation, this seam is not acceptable. The problem is that I don't know how to get rid of it.

How can I change my code to prevent the seam from appearing?

$\endgroup$
  • 2
    $\begingroup$ add the option BoundaryStyle -> None? $\endgroup$ – kglr Dec 24 '19 at 22:27
  • $\begingroup$ Crossposted here. $\endgroup$ – Rohit Namjoshi Dec 25 '19 at 4:06
6
$\begingroup$

As kglr comments you can use BoundaryStyle -> None to avoid drawing the boundary line entirely. Then if desired you can draw lines with more control using Mesh and MeshStyle:

f[t_, r_, a_] := {r*Cos[2 Pi*t]*Sin[Pi*t + 2*Pi*a], 
   r*Sin[4 Pi*t - 2*Pi*a]*Cos[2*Pi*t + 2*Pi*a]};

ff[a_] := ParametricPlot[f[t, r, a], {t, -1, 1}, {r, 0.5, 1}, 
   PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}, Axes -> False, Frame -> False, 
   PlotPoints -> 60,
   BoundaryStyle -> None, 
   MeshStyle -> Directive[Opacity[1], AbsoluteThickness[3], Red],
   Mesh -> {0, {0.5, 1}}];

ff[0.1]

enter image description here

| improve this answer | |
$\endgroup$
4
$\begingroup$

Mr.Wizard's provides a good solution. but I strongly reccomend replacing

MeshStyle -> Directive[Opacity[1], AbsoluteThickness[3], Red]

with

MeshStyle -> Directive[Thin, rColor, Opacity[1]]

where

rColor = RGBColor[0.775, 0.820, 0.900];

which closely matches the bluish color Mathematica uses fill regions.

However, you might also consider an alternative solution which is somewhat simpler. It doesn't suppress the boundaries lines, it just colors them to blend-in with the region fill color. To my eyes this solves your problem as well as Mr.Wizard's solution does. But my eyes aren't so good, so I leave for you to decide.

rColor = RGBColor[0.775, 0.820, 0.900];
ff[a_] :=
  ParametricPlot[f[t, r, a], {t, -1, 1}, {r, 0.5, 1},
    PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}},
    Axes -> False,
    Frame -> False,
    PlotPoints -> 50,
    BoundaryStyle -> Directive[Thin, rColor, Opacity[1]]]

I evaluated

manip = Manipulate[ff[a], {a, 0, 1, .1, Appearance -> "Labeled"}];
Export[FileNameJoin[{$HomeDirectory, "Desktop", "ff.gif"}], manip]

to make the following animated GIF which looks OK to me.

animation

| improve this answer | |
$\endgroup$
  • $\begingroup$ I don't think I understand this answer; isn't the fill color just ColorData[97, 1] with reduced opacity? And if one doesn't want to see the boundary at all isn't BoundaryStyle -> None sufficient? $\endgroup$ – Mr.Wizard Dec 25 '19 at 2:47
  • $\begingroup$ p.s. Merry Christmas! $\endgroup$ – Mr.Wizard Dec 25 '19 at 2:47
  • $\begingroup$ @Mr.Wizard. 1) You are likely right about the color, but comes as news to me. The RGB color I give doesn't set alpha channel to a lower value, so it can't be quite the same. 2) No, that won't work. Try it. The very thinest sections of region disappear if neither boundary lines nor mesh lines are plotted. 3) A merry xmas and happy and prosperous new year to you. $\endgroup$ – m_goldberg Dec 25 '19 at 4:56

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.