Message Boards Message Boards

1
|
6993 Views
|
5 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Avoid streamlines to smear in ContourPlot[]?

Posted 6 years ago

The image illustrates the problem I am having with ContourPlot[]: lines smear and blot when they get too close together. I tried to reduce the number of streamlines, but the Contours option has no effect, whether I specify a number or real values in curly brackets. (MMA 10.0.0.0 on OS 10.9.5)

k = Pi/16;

streamline[psi_] := 
  ContourPlot[( -(Exp[x] Sin[y ])/(Exp[2 x] - 2 Exp[x] Cos[y ] + 
        1)) == psi , {x, -Pi, Pi}, {y, -Pi, Pi}, PlotRange -> All, 
   Background -> White];

psiCurves = Table[streamline[psi], {psi, -Pi, Pi, k}];

Show[psiCurves]
Attachment

Attachments:
POSTED BY: Gary Palmer
5 Replies
Posted 6 years ago

With a slight modifications of Henrik's plot, I was able to obtain the desired effects. I sampled the contours list, inceased the thickness, and increased MaxRecursion. Thanks to all for the almost instantaneous help.

k = Pi/21; contours = Table[psi, {psi, -Pi, Pi, 2 k}]; contours = Take[contours, {2, -1, 2}]; sl[x, y] := -(Exp[x] Sin[y])/(Exp[2 x] - 2 Exp[x] Cos[y] + 1);

ContourPlot[sl[x, y], {x, -Pi, Pi}, {y, -Pi, Pi}, ContourShading -> None, Contours -> contours, PlotRange -> All, ContourStyle -> Thickness[.004], PerformanceGoal -> "Quality", PlotPoints -> 25, MaxRecursion -> 4, ImageSize -> Large]

Attachment

Attachments:
POSTED BY: Gary Palmer

These lines come infinitely close each other, so at some level you will always have that effect as they have finite thickness. Maybe this helps a bit:

k = Pi/16;
contours = Table[psi, {psi, -Pi, Pi, k}];
sl[x_, y_] := -(Exp[x] Sin[y])/(Exp[2 x] - 2 Exp[x] Cos[y] + 1);

ContourPlot[sl[x, y], {x, -Pi, Pi}, {y, -Pi, Pi}, 
 ContourShading -> None, Contours -> contours, PlotRange -> All, 
 ContourStyle -> Thickness[.001], PerformanceGoal -> "Quality", 
 PlotPoints -> 25, MaxRecursion -> 2, ImageSize -> Large]
POSTED BY: Henrik Schachner
Posted 6 years ago

The thin style reduces the extent of smearing, but the plot still shows an irregular clumping at the pole (origin), and the thin lines are not the effect I was looking for. I wanted something more like the following:

Attachment

Attachments:
POSTED BY: Gary Palmer
Posted 6 years ago

What if you specify ContourStyle -> Thin, so that the lines take up less space next to one another? Increasing the size of the output also can help, naturally.

k = Pi/16;

streamline[psi_] := 
  ContourPlot[(-(Exp[x] Sin[y])/(Exp[2 x] - 2 Exp[x] Cos[y] + 1)) == 
    psi, {x, -Pi, Pi}, {y, -Pi, Pi}, PlotRange -> All, 
   Background -> White, ContourStyle -> Thin];

psiCurves = Table[streamline[psi], {psi, -Pi, Pi, k}];

Show[psiCurves, ImageSize -> Large]

enter image description here

POSTED BY: Kyle Martin
Posted 6 years ago

Try the following option in ContourPlot:

ContourStyle -> Thin
POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract