5
$\begingroup$

Why do I get gaps in my plots below? Looking at this post suggests that using Exclusions-> None should fix the problem if there is a discontinuity. However there is no discontinuity in my case. So why do I get the gaps? Using Exclusions-> None does fix the problem so it must be a similar but different problem.

Module[{H, Ha, A = 0.015, α = 4, β, γ = 0.001},
 H[β_] := (
  E^(-2 π α (I β + γ)) (-I E^(
      2 π α (I β + γ)) (β - 
        I γ) + (I β + γ) Cos[2 π α] - 
     Sin[2 π α]))/(-1 + β^2 - 
   2 I β γ - γ^2);
 Ha[β_] := 
  A (I β + γ)/(1 - (β - I γ)^2);

 pp = ParametricPlot[{ReIm@Ha[β], ReIm@H[β]}, {β, 0,
     2},
   ImageSize -> 11 72, PlotRange -> All
   ]

 ]

Mathematica graphics Note that there is a gap in the yellow curve near the horizontal axis as well as the obvious one in the blue curve.

To look more closely I did

Length@Cases[pp, _Line, ∞]
(* 4 *)

This shows that the blue and yellow curves have been each been split up into two sections. I thought it might be due to the course sampling but increasing the PlotPoints to 200 still leaves a gap in the blue curve.

Now with Exclusions-> None added I get a good result and there are now just two lines as expected.

Module[{H, Ha, A = 0.015, α = 4, β, γ = 0.001},
 H[β_] := (
  E^(-2 π α (I β + γ)) (-I E^(
      2 π α (I β + γ)) (β - 
        I γ) + (I β + γ) Cos[2 π α] - 
     Sin[2 π α]))/(-1 + β^2 - 
   2 I β γ - γ^2);
 Ha[β_] := 
  A (I β + γ)/(1 - (β - I γ)^2);

 pp = ParametricPlot[{ReIm@Ha[β], ReIm@H[β]}, {β, 0,
     2},
   ImageSize -> 11 72, PlotRange -> All, Exclusions -> None
   ]

 ]

Mathematica graphics

So why do I get the gaps?

$\endgroup$
5
  • $\begingroup$ Side note: adding PlotPoints -> 500 makes the plot much smoother. $\endgroup$
    – anderstood
    Commented Nov 7, 2016 at 19:27
  • 2
    $\begingroup$ Try MaxRecursion -> 10, PlotPoints -> 60, along Exclusions -> None. The function has some strange behaviour at that point which happens not to show up in this particular plot. Mathematica detects and excludes it anyway. Your first function has very rapid change there, thus with uniform sampling in $\beta$ it look ugly and it needs an unusually high number of recursive refinements to smooth it out. $\endgroup$
    – Szabolcs
    Commented Nov 7, 2016 at 19:31
  • $\begingroup$ @Szabolcs You values are not quite enough in Version 11.0.0.PlotPoints -> 200, MaxRecursion -> 10 does not do it but then increasing the MaxRecursion to 15 does. What is odd is that in the original plot the yellow curve has a gap despite it being smooth. Is there also an issue with plotting vertically? Thanks for your input. $\endgroup$
    – Hugh
    Commented Nov 7, 2016 at 21:21
  • $\begingroup$ It looks completely smooth with 11.0.1. Perhaps you should upgrade, point releases bring many bugfixes ... $\endgroup$
    – Szabolcs
    Commented Nov 7, 2016 at 21:38
  • $\begingroup$ you may want to separately plot the two functions as Show[{ParametricPlot[H],ParametricPlot[Ha]}] so that you can independently set the parameters, $\endgroup$
    – george2079
    Commented Nov 8, 2016 at 0:43

1 Answer 1

3
$\begingroup$

You need to increase the number of PlotPoints to get a smooth curve and use the option Exclusions to force evaluations close to the exclusion points (i.e., close the gaps).

Module[
 {H, Ha, A = 0.015, α = 4, β, γ = 0.001},
 H[β_] :=
  (E^(-2 π α (I β + γ)) (-I E^(2 π α (I β + γ)) (β - I γ) +
       (I β + γ) Cos[2 π α] - Sin[2 π α]))/
   (-1 + β^2 - 2 I β γ - γ^2);
 Ha[β_] := A (I β + γ)/(1 - (β - I γ)^2);
 pp = ParametricPlot[
   {ReIm@Ha[β], ReIm@H[β]}, {β, 0, 2},
   Exclusions -> {β == 2},
   ImageSize -> Medium,
   PlotRange -> All,
   PlotPoints -> 300]]

enter image description here

EDIT: The gaps are closed when the Exclusion is at the max value of β

Manipulate[
 Module[
  {H, Ha, A = 0.015, α = 4, β, γ = 0.001},
  H[β_] :=
   (E^(-2 π α (I β + γ)) (-I E^(2 π α (I β + γ)) (β - I γ) +
        (I β + γ) Cos[2 π α] - Sin[2 π α]))/
    (-1 + β^2 - 2 I β γ - γ^2);
  Ha[β_] := A (I β + γ)/(1 - (β - I γ)^2);
  pp = ParametricPlot[
    {ReIm@Ha[β], ReIm@H[β]}, {β, 0, βmax},
    ImageSize -> Medium,
    PlotRange -> All,
    PlotPoints -> 300,
    Exclusions -> {β == βmax}]],
 {{βmax, 2}, 1, 2, .1, Appearance -> "Labeled"}]
$\endgroup$
4
  • $\begingroup$ This is very odd. The problem is close to [Beta]==1 but adding an exclusion at [Beta]==2 does help. It does not help to add the exclusion at [Beta]==1. What is going on? Thanks for investigating. $\endgroup$
    – Hugh
    Commented Nov 7, 2016 at 21:31
  • $\begingroup$ @Hugh - see edit. $\endgroup$
    – Bob Hanlon
    Commented Nov 7, 2016 at 22:05
  • $\begingroup$ Experimenting it appears that any value of Exclusion works. It even works to put Exclusions -> {} Not a clear behaviour. Very difficult to understand what is happening. $\endgroup$
    – Hugh
    Commented Nov 7, 2016 at 22:47
  • $\begingroup$ the functions (both H and Ha are actually smooth and continuous. (both real and imaginary parts). they just vary very rapidly near beta=1, so that it appears to jump if the sampling is too coarse. Setting a large PlotPoints (1000 works) is all you need here. $\endgroup$
    – george2079
    Commented Nov 8, 2016 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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