2
$\begingroup$

I'm trying to plot a graph using contour plot as below, but the lines are not smooth as they should be, how can I fix that?

r5 = ImplicitRegion[-Pi <= y + x <= Pi && -Pi <= y - x <= Pi && 
   y <= Pi && y >= -Pi, {x, y}]

    p3 = Show @@ 
  Table[ContourPlot[
    a == (Tan[(y - x)/2] + Tan[(y + x)/2])/2, {x, y} \[Element] r5, 
    ContourStyle -> Black], {a, -4, 4, 0.3}]

enter image description here

$\endgroup$
3
  • $\begingroup$ I get smooth contours (V13.1): i.sstatic.net/Lmbdu.png $\endgroup$
    – Michael E2
    Commented Nov 23, 2022 at 14:32
  • $\begingroup$ You could use, for instance, ContourPlot[..., Contours -> Range[-8, 8, 1/2]] to speed up the valuation as an additional suggestion. $\endgroup$ Commented Nov 23, 2022 at 14:32
  • $\begingroup$ In any case, smoothness may be controlled with the options PlotPoints (default 15) and MaxRecursion (default 2). $\endgroup$
    – Michael E2
    Commented Nov 23, 2022 at 14:38

1 Answer 1

6
$\begingroup$

We can also use Contours and RegionFunction instead.

ContourPlot[(Tan[(y - x)/2] + Tan[(y + x)/2])/2, {x, -3, 3}, {y, -3, 
  3}, Contours -> Range[-4, 4, .3], ContourShading -> None, 
 RegionFunction -> 
  Function[{x, y}, -Pi <= y + x <= Pi && -Pi <= y - x <= Pi && 
    y <= Pi && y >= -Pi]]

enter image description here

$\endgroup$
0

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.