# Visualization with ListContourPlot

**URL:** <https://community.wolfram.com/t/visualization-with-listcontourplot/5505>\
**Category:** Questions\
**Tags:** mathematica, graphics-and-visualization\
**Created:** [April 22, 2015, 3:48pm UTC](https://community.wolfram.com/t/visualization-with-listcontourplot/5505 "2015-04-22T15:48:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![getalex](https://avatars.discourse-cdn.com/v4/letter/g/aeb1de/32.png) [@getalex](https://community.wolfram.com/u/getalex)\
**Post date:** [April 22, 2015, 3:48pm UTC](https://community.wolfram.com/t/visualization-with-listcontourplot/5505/1 "2015-04-22T15:48:01Z")

</div>

Hi everybody,

I’m having some trouble visualizing a function with the ListContourPlot function. I’ve already done the calcuations and visualization in MATLAB, but need to reproduce the results in Mathematica as well. I’ve provided a screenshot from MATLAB to show you what I’m aiming for and another screenshot to show you what I’m currently getting in Mathematica.

Calculations are as follows:

```
linspace[x0_, x1_, n_] := Range[x0, x1, (x1 - x0)/(n - 1)];
Yrange = linspace[-10, 20, 500];
Xrange = linspace[-10, 30, 500];
RErange = 10^(Yrange);
PPLUSrange = 10^(Xrange);
constL = 0.0000346737;
constR = 100000;

z = (1 - (1/RErange)*(PPLUSrange)^0.7*constL)/(1 + (2*pi*RErange/PPLUSrange*constR));

data = Transpose[{Xrange, Yrange, z}];

ListContourPlot[data, Mesh -> None, PlotRange -> {{-10, 30}, {-10, 20}, {0, 1}}, ContourLabels -> All, 
ContourShading -> None, DataRange -> {{-10, 30}, {-10, 20}}]

```

I’m thinking this is some kind of perspective issue, but I’m not sure.

Any help is greatly appreciated!

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [April 22, 2015, 5:09pm UTC](https://community.wolfram.com/t/visualization-with-listcontourplot/5505/2 "2015-04-22T17:09:33Z")

</div>

Use “Pi” instead of “pi”.

Henrik

---

<div class="post-metadata">

**Author:** ![getalex](https://avatars.discourse-cdn.com/v4/letter/g/aeb1de/32.png) [@getalex](https://community.wolfram.com/u/getalex)\
**Post date:** [April 22, 2015, 6:39pm UTC](https://community.wolfram.com/t/visualization-with-listcontourplot/5505/3 "2015-04-22T18:39:16Z")

</div>

Thank you Henrik! That definitely helped! I’m still not used to Mathematica’s case sensitivity.

I got a new plot, much closer to that what I need and the values in the “data” array look correct. However, Mathematica still isn’t plotting correctly. I’ve attached a new screenshot of the plot.

Interestingly, as I mentioned, the z-values in the array are correct, all being between 0 and 1:

```
data
{{-10, -10, 1.53636*10^-6}, {-(4950/499), -(4960/499), 
  1.60945*10^-6}, {-(4910/499), -(4930/499), 1.68601*10^-6},...,{14890/499, 9920/499, 0.999578}, {14930/499, 9950/499, 0.999584}, \
  {30, 20, 0.99959}}

```

However, Mathematica is showing contour values from -5 to 25. I’m not sure if there is something incorrect with the “data” array? Maybe Mathematica is plotting the wrong entries? Z values should be the third entry within each set of {x,y,z} coordinates?

Thanks again for the help!

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [April 22, 2015, 10:27pm UTC](https://community.wolfram.com/t/visualization-with-listcontourplot/5505/4 "2015-04-22T22:27:38Z")

</div>

Hello A.N.,

it took me a while to find out what is going wrong here: Your data points do not really fill a plane, but rather lie on a straight line. You can see this with:

```
Graphics[Point[data[[;; , {1, 2}]]], Frame -> True]

```

`ListContourPlot` cannot work that way.

Instead of working with data you can define a analytical function:

```
constL = 0.0000346737;
constR = 100000;

f[x_, y_] := (1 - (1/(10^y))*(10^x)^0.7*constL)/(1 + (2.*Pi*(10^y)/10^x*constR))

```

which can be plotted like:

```
ContourPlot[f[x, y], {x, -10, 30}, {y, -10, 20}, Mesh -> None, 
 ContourLabels -> All, ContourShading -> None, 
 Contours -> Range[.2, 1, .2]]

```

This gives the result you are expecting!

Henrik

**Addendum:** I do not want to change your concept. Of course you can work with data values as well:

```
constL = 0.0000346737;
constR = 100000;
data = Flatten[Table[{x, y, (1 - (1/10^y)*(10^x)^0.7*constL)/(1 + (2*Pi*10^y/10^x*constR))}, {x, -10, 30, .1}, {y, -10, 20, .1}], 1];

ListContourPlot[data, Contours -> Range[.2, 1, .2], ContourLabels -> All, ContourShading -> None]

```

This also gives the expected result.

---

<div class="post-metadata">

**Author:** ![getalex](https://avatars.discourse-cdn.com/v4/letter/g/aeb1de/32.png) [@getalex](https://community.wolfram.com/u/getalex)\
**Post date:** [April 23, 2015, 7:56am UTC](https://community.wolfram.com/t/visualization-with-listcontourplot/5505/5 "2015-04-23T07:56:45Z")

</div>

Hi Henrik,

Thank you so much! It works both ways!

With my method I was trying to somehow emulate MATLAB’s meshgrid by giving a set of values and getting Mathematica to interpolate the function - I guess I wasn’t quite on the right track.

Thanks again! I learned a lot from this!
