shalabuda
shalabuda

Reputation: 320

Mathematica z-value mesh in plots

I have a list of {x,y,z} values and I am using a ListDensityPlot to visualize it. I want to draw contours with something like MeshFunctions->{#3&}. This is what I have now:

ListDensityPlot[data, PlotRange->{0, 350}, Mesh->{10}, MeshFunctions->{#3 &}]

But I want the values of contours to grow exponentially from the minimum value of z up to the maximum range (which is 350). How do I do that? Thanks!

Upvotes: 1

Views: 962

Answers (1)

Etaoin
Etaoin

Reputation: 8724

If you give a single number (like 10) to Mesh, you're asking for that many contours, evenly spaced. But if you give it a list of values, contours will be drawn at those points.

So all we need now is a list of ten numbers (let's say n numbers) increasing exponentially from the minimum value (call it min) to the maximum (call it max). We can generate it like this -- the proof is left as an exercise:

Table[
    min Exp[i Log[max / min] / (n - 1)],
    {i, 0, n - 1}
]

So the solution to your problem is:

min = Min[data[[All, 3]]];
ListDensityPlot[
    data,
    PlotRange->{0, 350},
    Mesh->{Table[
        min Exp[i Log[350 / min] / 9],
        {i, 0, 9}
    ]},
    MeshFunctions->{#3 &}
]

Note the extra braces around the Table call, which make that list of values the specification for a single mesh.

Upvotes: 1

Related Questions