1
$\begingroup$

I want to create a contour plot of a function that goes to infinity at x=1 and z=0 as can be seen by plotting it for x=1:

zmax = 4;
fun[x_, y_, z_, xp_, yp_] := -(3*z^3)/(2*Pi*(z^2 + (x - xp)^2 + (y - yp)^2)^(5/2));
Plot[fun[1, 1, z, 1, 1], {z, 0, zmax}]

enter image description here

The following code

ContourPlot[fun[x, 1, z, 1, 1], {x, -2, 3}, {z, 0, zmax}, 
    AspectRatio -> 1/2, PlotPoints -> 50, Frame -> True, ColorFunction -> GrayLevel, 
    PlotLegends -> Placed[BarLegend[Automatic, 10, LegendMarkerSize -> 350], Below], 
    PlotRange -> {Automatic, Automatic, {-0.5, 0}}]

produces a contour plot with a white area around the singularity:

enter image description here

The question is: how to get rid of the white area. I would like to exclude the region around point {1,0} from the calculations and set its colour to black (or any other). I tried adding something like

Exclusions -> {{x < 1.5, x > 0.5, z < 0.5}}, ExclusionsStyle -> Black

but it didn't change anything.

$\endgroup$
2
$\begingroup$

When I see this right, then you don't need this. The inner white "circle" is already clipped. Therefore, the only thing you have to add is ClippingStyle -> LightGreen and you get

Mathematica graphics

$\endgroup$
  • $\begingroup$ So simple! Thank you :-) $\endgroup$ – K.J. Dec 8 '17 at 18:28

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.