ContourPlot giving all (most) contours the same shading

I am using a ContourPlot command to plot a function and unless I explicitly define the ContourShading I get the same colour used for most intervals. Is there any way to fix this?

Here's the function that's not doing what I want

ContourPlot[1/x 1.303 E^(1/2 (-0.48 (-5.3+x)^2-(137 y^2)/x^2)),
{x,0,15},{y,-2,2},PlotRange->Full,PlotPoints->10,
AspectRatio->1/3,PlotLegends->Automatic]


which gives

whereas if I explicitly state the colour shading I get what I expected

ContourPlot[1/x 1.303 E^(1/2 (-0.48 (-5.3 + x)^2 - (137 y^2)/x^2)),
{x, 0, 15}, {y, -2, 2},
PlotRange -> Full, PlotPoints -> 10,
AspectRatio -> 1/3, PlotLegends -> Automatic,
ContourShading -> {White, Red, Green, Blue, Yellow, Purple}]


If I play around with PlotRange (All, Full, Automatic) then it changes whether I get the contours different colours, but the ranges also change. Playing around with the number of PlotPoints also changes whether I get contours as expected.

Is this a glitch or expected behaviour? Is there a way to explicitly tell it to use the default theme? This is what I was expecting (and have for different parameter values), so I'd like everything to match the same theme.

• You have a singularity at {0,0} which is effecting the range used by the color function. If you change the x-range to {x, 0.1, 15} you get something that looks reasonable. Jan 12, 2016 at 3:37
• It turns out that all of the colors are actually slightly different, as can be seen if you do Cases[Normal@plot, RGBColor[a__], Infinity]. Jan 12, 2016 at 3:43
• Thanks - that has fixed things. Still seems strange thought that it's not using the same variety in colours that it is later - the largest interval is still kicking in quite early. Jan 12, 2016 at 5:35

I think the problem is in the option PlotRange->Full. By removing this option

    ContourPlot[
1/x*1.303 E^(1/2 (-0.48 (-5.3 + x)^2 - (137 y^2)/x^2)), {x, 0,
15}, {y, -2, 2}, PlotPoints -> 10, AspectRatio -> 1/3,
PlotLegends -> Automatic]


one immediately gets the different shading:

Alternatively one may specify the color function:

    ContourPlot[
1/x*1.303 E^(1/2 (-0.48 (-5.3 + x)^2 - (137 y^2)/x^2)), {x, 0,
15}, {y, -2, 2}, PlotPoints -> 10, AspectRatio -> 1/3,
ColorFunction -> "Rainbow", PlotLegends -> Automatic]


giving the following:

The white area in the center is related to the default PlotRangevalue, by its fixing we get rid of it:

    ContourPlot[
1/x*1.303 E^(1/2 (-0.48 (-5.3 + x)^2 - (137 y^2)/x^2)), {x, 0,
15}, {y, -2, 2}, PlotPoints -> 10, AspectRatio -> 1/3,
PlotRange -> {0, 0.3}, PlotLegends -> Automatic,
ColorFunction -> "Rainbow"]


but here the heights are resolved in a more rough way.

Hope it helps. Have fun!

As rcollyer states, you can get the plot you need by leaving the origin out of the plotted range.

ContourPlot[
1/x 1.303 E^(1/2 (-0.48 (-5.3 + x)^2 - (137 y^2)/x^2)), {x, 0.001,
15}, {y, -2, 2}, PlotRange -> Full, PlotPoints -> 10,
AspectRatio -> 1/3, PlotLegends -> Automatic]


I feel like you should be able to do it using Exclusions but I can't quite figure it out.