0
$\begingroup$

I try to plot level curves of the real part of the complex function $f(z)=\frac{1}{z}$ with

ContourPlot[Re[1/(x + I y)], {x, -5, 5}, {y, -5, 5}, 
 PlotLegends -> Automatic, Exclusions -> {x^2 + y^2 == 0}]

But I get

enter image description here

It is acceptable though, there is a problem at the origin $(0,0)$. How can I improve the code?

$\endgroup$
  • 3
    $\begingroup$ Try increasing the MaxRecursion option in ContourPlot. MaxRecursion -> 4 gives a pretty good result $\endgroup$ – Marchi Feb 14 '17 at 20:41
  • $\begingroup$ You can try PlotPoints->100 option too $\endgroup$ – BlacKow Feb 14 '17 at 20:43
  • $\begingroup$ @Marchi: thanks for your comment. That solves the problem. Would you turn your comment into an answer so that I can accept it? $\endgroup$ – Jack Feb 14 '17 at 23:06
1
$\begingroup$

We can solve the rendering issue by increasing the MaxRecursion option in ContourPlot.

ContourPlot[Re[1/(x + I y)], {x, -5, 5}, {y, -5, 5}, 
 PlotLegends -> Automatic, Exclusions -> {x^2 + y^2 == 0}]

enter image description here

From @BlacKow's comment, the same result can be achieved by increasing the number of PlotPoints:

ContourPlot[Re[1/(x + I y)], {x, -5, 5}, {y, -5, 5}, 
 PlotLegends -> Automatic, Exclusions -> {x^2 + y^2 == 0}, 
 PlotPoints -> 100]

enter image description here

$\endgroup$
1
$\begingroup$
ContourPlot[Re[1/(x + I y)], {x, -5, 5}, {y, -5, 5}, 
PlotLegends -> Automatic, Exclusions -> {x^2 + y^2 == 0}, 
MaxRecursion -> 6, ColorFunction -> "Rainbow", 
ClippingStyle -> Automatic, Frame -> False, 
PerformanceGoal -> "Quality", WorkingPrecision -> 20, 
PlotPoints -> 150, ImageSize -> 600]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ This one is very nice! Thank you for your answer! $\endgroup$ – Jack Feb 15 '17 at 14:19

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