3
$\begingroup$

The user of Mathematica version 9 is trying to plot the following experimental data:

data[1]={{{-1., -1., 0.0384625}, {-0.5, -1., 0.068232}, {0., -1., 
15915.5}, {0.5, -1., 0.068232}, {1., -1., 0.0384625}}, {{-1., -0.5,
 0.0477074}, {-0.5, -0.5, 0.0758774}, {0., -0.5, 
15915.5}, {0.5, -0.5, 0.0758774}, {1., -0.5, 0.0477074}}, {{-1., 
0., 0.0123607}, {-0.5, 0., 0.0787931}, {0., 0., 15915.5}, {0.5, 0.,
0.0787931}, {1., 0., 0.0123607}}, {{-1., 0.5, 0.0477074}, {-0.5, 
0.5, 0.0758774}, {0., 0.5, 15915.5}, {0.5, 0.5, 0.0758774}, {1., 
0.5, 0.0477074}}, {{-1., 1., 0.0384625}, {-0.5, 1., 0.068232}, {0.,
1., 15915.5}, {0.5, 1., 0.068232}, {1., 1., 0.0384625}}}

data[2]={{{-1., -1., 0.0384625}, {-0.5, -1., 0.068232}, {0., -1., 
15915.5}, {0.5, -1., 0.068232}, {1., -1., 0.0384625}}, {{-1., -0.5,
0.0477074}, {-0.5, -0.5, 0.0758774}, {0., -0.5, 
15915.5}, {0.5, -0.5, 0.0758774}, {1., -0.5, 0.0477074}}, {{-1., 
0., 0.0123607}, {-0.5, 0., 0.0787931}, {0., 0., 15915.5}, {0.5, 0.,
0.0787931}, {1., 0., 0.0123607}}, {{-1., 0.5, 0.0477074}, {-0.5, 
0.5, 0.0758774}, {0., 0.5, 15915.5}, {0.5, 0.5, 0.0758774}, {1., 
0.5, 0.0477074}}, {{-1., 1., 0.0384625}, {-0.5, 1., 0.068232}, {0.,
1., 15915.5}, {0.5, 1., 0.068232}, {1., 1., 0.0384625}}}

mylist = data[1] + data[2];

list = Flatten[mylist, 1];

ListPlot3D[list]

It gives the following plot result, enter image description here

However, the x and y axis needs to be scaled because data values for x and y were from 0 to 1. But when adding two data to get the sum of z values, x and y were added as well. Therefore attempt was made to use DataRange to scale x y back to original value or from 0 to 1 for both x and y axis. However, when typing the correct last line of code which is,

ListPlot3D[list, DataRange -> {{0, 1}, {0, 1}}]

the output is

enter image description here

Cannot figure out what is wrong with the code. It is giving me the burnout. Any comments?

$\endgroup$
  • $\begingroup$ You can add PlotRange->All to get rid of the flat chopped off area, but it is still strange. I get something different that what you get, but it is still strange. $\endgroup$ – Bill Watts Sep 15 '18 at 23:09
1
$\begingroup$

DataRange typically is used with arrays of height values, not with arrays of position and height values. Look at the last examples under "Examples>Options>DataRange" in the documentation of ListPlot3D to see how it interprets DataRange with arrays of position and height values. This is not what you want here. Instead, use Map to discard the position values and plot just the height values.

 ListPlot3D[Map[Last, mylist, {2}], DataRange -> {{0, 1}, {0, 1}}]

enter image description here

as desired. Incidentally, from the original position data, I would expect that you would wish to use DataRange -> {{-1, 1}, {-1, 1}}.

Addendum

Relabeling tick marks also works.

ticks[min_, max_] := {Range[min, max, (max - min)/2], Range[0, 1, .5]} // Transpose
ListPlot3D[list, Ticks -> {ticks, ticks, Automatic}]

enter image description here

$\endgroup$

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.