# ContourPlot - unequal contour spacing

how can i specify the contour spacing or how the color range is distributed amongst the function values?

Let's say i plot some function depending on x and y. Function values differ between [0, 1]. I want that mathematica makes ...let's say 10 contours for the function value range [0,0.9] and another 10 contours for the rest of the range [0.9,1]. Further more the last Contour of the [0,0.9] range is supposed to be thicker, in order to show that from here on the contour spacing is finer.

thx for your help

thats alot so far for your help, my actual question has been answered already. but a follow-up question has arisen for me since the implementation of your codes does not work with my actual function and i don't know why. I have purged that function and the functions it calls from most variables and replaced them by constants for simplicity reasons. I hope it's ok so.

eislexpl[epsilon_, n2_, x_] :=  28 (epsilon)^2 - 1 +
((-2 Log[E^(1/2) x])/x^2 + (2.7(0.3 - epsilon))/x +
(10 epsilon^2 n2^(3/2))/x^(3/2));

eislminx2[epsilon_?NumericQ, n2_?NumericQ] :=
(minx = FindArgMin[{eislexpl[epsilon, n2, x], 0 < x}, x];
eislexpl[epsilon, n2, minx]);

ueislexpl[epsilon_, h_, n1_, n2_] :=
n1 (40  epsilon^2 - 1) + (1 -1.27 ) (1 + (n1 - 1) HeavisideTheta[1 - n1] -
(-1 + Exp[-(n1 - 1)]) HeavisideTheta[n1 - 1]) + n2  eislminx2[epsilon, n2] +
(h - n1 - n2) (28  epsilon^2 - 1);


ueislexpl[epsilon_, h_, n1_, n2_] is the function i want to plot with ContourPlot. If i use :

ContourPlot[
ueislexpl[0.1, 5, n1, n2], {n1, 0, 5}, {n2, 0, 5 - n1},
Contours -> (Function[{min, max},
Module[{r1, r2},
Join[r1 = Range[min, .1 max, (.1 max - min)/10],
r2 = Range[.1 max + .01, max, (max - .1 max - .01)/10]]]]),
ContourStyle -> (Join @@ {Table[Thick, {Length@r1}],
Table[Thin, {Length@r2}]})]


It should plot a contourplot with 10 divisions for the value range [min,0.1 max] and 10 more divisions for [0.1 max, max]. But my result is 3 divisions.

What do i have to change?

-
In the future, try to include examples of your specific data and a minimum working instance of the code you have been working on. A questions that shows effort will give you reputation and its more likely to be answered soon and thoroughly. –  rhermans Aug 8 '14 at 13:22
Thanks for the reminder. –  11drsnuggles11 Aug 8 '14 at 13:45
Notice that max->-3.4 and therefore 0.1 max > max, you are placing the Contours out of the range, at this positions: {-4.39953,-3.99363,-3.58774,-3.18184,-2.77595,-2.37005,-1.96416,-1.55826,-1.1523‌​7,-0.746472,-0.340577,-0.330577,-0.638096,-0.945615,-1.25313,-1.56065,-1.86817,-2‌​.17569,-2.48321,-2.79073,-3.09825,-3.40577} –  rhermans Aug 9 '14 at 12:12
ahhhh, you are right :) thanks –  11drsnuggles11 Aug 9 '14 at 12:45

Something like this?

ContourPlot[
1 - Exp[-x - y]
, {x, 0, 2}
, {y, 0, 2}
, PlotRange -> {0, 1}
, Contours -> Join[Range[0, 0.9, 0.1], Range[0.9, 1, 1/100]]
, ContourStyle -> Join[Table[Thick, {10}], Table[Thin, {9}]]
]


EDIT:

About the follow-up question, the function should look like this:

ContourPlot[
ueislexpl[0.1, 5, n1, n2]
, {n1, 0, 5}
, {n2, 0, 5 - n1}
, PlotPoints -> 100
, Contours -> (
Function[{min, max},
Module[{r1, r2, ret},
ret = Join[
r1 = Range[min, min + ( max - min)/10, (max - min)/100],
r2 = Range[1/100 (19 max + 81 min), max, (9 (max - min))/100]
];
Print[{min, max, r1, r2}];
ret
]])
, ContourStyle -> (
Join @@ {Table[Thick, {Length@r1}], Table[Thin, {Length@r2}]}
)
]


{-4.39976,-3.40577,{-4.39976,-4.38982,-4.37988,-4.36994,-4.36,-4.35006,-4.34012,-4.33018,-4.32024,-4.3103,-4.30036},{-4.2109,-4.12144,-4.03198,-3.94252,-3.85306,-3.7636,-3.67415,-3.58469,-3.49523,-3.40577}}

I included a Print statements to get feedback on where the Contours are been placed. No idea why the plot is missing a half.

-
Yes, exactly like this, thank you rhermans :) –  11drsnuggles11 Aug 8 '14 at 13:44
@11drsnuggles11, Good! If this answers your question and closes the topic you can mark the answer as "accepted". –  rhermans Aug 8 '14 at 13:48
@rhermans I would recommend to wait a couple of hours before accepting any answer –  eldo Aug 8 '14 at 13:51
Is there a way so that i don' have to give the specific values of the range of the function values like [0,1] but rather say: make 10 contours for [min, 0.9 max] and 10 contours for [0.9 max, max]? –  11drsnuggles11 Aug 8 '14 at 14:17
thanks again for your help, rhermans. the plot is "missing" a half because of "{n2, 0, 5 - n1}" . the plot gives the energy of a specific system depending on deposited amount of material. n1 is the material in a so called wetting layer and n2 is the amount of material deposited in 3d-structures, the total amount h=n1+n2, thus i cut half of the plot, because in the missing half of the plot there is the unrealistic case: n1+n2> h. –  11drsnuggles11 Aug 9 '14 at 12:49

An alternative syntax for Contours that combine contours and styles:

cntrplt[expr_, arg1_, arg2_, contours : {{_, _} ..}, opts : OptionsPattern[]] :=
ContourPlot[expr, arg1, arg2, Contours -> Join @@ Thread /@ contours, opts];


Using @rhermans' example:

cntrplt[1 - Exp[-x - y], {x, 0, 2}, {y, 0, 2},
{{Range[0, .9, 1/10], Thick}, {Range[.91, 1, 1/100], Thin}},
PlotRange -> {0, 1}]


Update:

a way so that i don' have to give the specific values of the range of the function values like [0,1] but rather say: make 10 contours for [min, 0.9 max] and 10 contours for [0.9 max, max]

ContourPlot[1 - Exp[-x - y], {x, 0, 2}, {y, 0, 2},
Contours -> (Function[{min, max},
Module[{r1, r2},
Join[r1 = Range[min, .9 max, (.9 max - min)/10],
r2 = Range[.9 max + .01, max, (max - .9 max - .01)/10]]]]),
ContourStyle -> (Join @@ {Table[Thick, {Length@r1}], Table[Thin, {Length@r2}]})]


-
Thank you, kguler. Since i am a beginner with mathematica, i have to look into some things to fully understand what you presented me here ;) –  11drsnuggles11 Aug 8 '14 at 15:02
kgular, where in your code do you retrieve the min and max value of the range of function values and store it in "min" and "max"? –  11drsnuggles11 Aug 8 '14 at 17:53
@11drsnuggles11, when you use a pure function to generate the contours the two arguments of the function (min and max) are calculated automatically. The only information about this usage are the examples 6 and 7 in ContourPlot>>Options>>Contours, and a short blob in Contours>>Details –  kguler Aug 8 '14 at 18:09
... (BTW, you could also use the simpler form Contours -> (Join[Range[#1, .9 #2, (.9 #2 - #1)/10], Range[.9 #2 + .01, #2, (#2 - .9 #2 - .01)/10]] &) to specify the set of contours using a pure function.) –  kguler Aug 8 '14 at 18:10
I tried to apply that piece of code to my actual function, unfortunately it doesn' work and i don't know why. I have edited my question and posted a simplified version of my function. –  11drsnuggles11 Aug 8 '14 at 19:05

Borrowing from @rhermans:

Framed[ContourPlot[Sin[x y], {x, 0, 2}, {y, 0, 2},
Contours -> Join[Range[0, 0.9, 0.1], Range[0.91, 1, 0.01]],
Frame -> {{True, False}, {True, False}},
ColorFunction -> "Pastel",
ContourStyle ->
Join[Table[Directive[Brown, Thick], {10}], Table[Directive[Dashed, Thin], {9}]],
ContourLabels -> Function[{x, y, z}, Text[Framed[z], {x, y}, Background -> White]],
ImageSize -> 600],
FrameMargins -> 20]


-
Thank you, eldo. Do you know the answere to my comment to rhermans answere? –  11drsnuggles11 Aug 8 '14 at 15:00