7
$\begingroup$

This is related to the issue brought up here, if you want to mark it as duplicate feel free to do so, but it is slightly separate.

Take two sets of data, identical except for the form,

dta1 = Table[Exp[-x^2] Sin[y], {y, -π, π, π/3}, {x, -8, 8, 1}];
dta2 = Table[{x, y, Exp[-x^2] Sin[y]}, {x, -8, 8, 1}, {y, -π, π, π/3}]~Flatten~1;

The first is a two-dimensional array and the second is a list of tuples. Now note the different effects of InterpolationOrder on these data,

ListContourPlot[dta1, InterpolationOrder -> #, ImageSize -> 200, 
   DataRange -> {{-8, 8}, {-π, π}},PlotRange-> All] & /@ {0, 1, 2, 3}

enter image description here

ListContourPlot[dta2, InterpolationOrder -> #, 
   ImageSize -> 200,PlotRange -> All] & /@ {0, 1, 2, 3}

enter image description here

Going past an order of 1 has no effect. At order zero they are identical, at order 1 the 2D array is already better.

Notice that this is not a problem for ListLinePlot with one-dimensional data

func = Exp[-#^2] Cos[4 #] &;
list1 = Table[func[x], {x, -5, 5, .5}];
list2 = Table[{x, func[x]}, {x, -5, 5, .5}];
ListLinePlot[list1, DataRange -> {-5, 5}, InterpolationOrder -> #, 
   PlotRange -> {-1, 1}, ImageSize -> 200] & /@ {0, 1, 2, 3}
ListLinePlot[list2, InterpolationOrder -> #, PlotRange -> {-1, 1}, 
   ImageSize -> 200] & /@ {0, 1, 2, 3}

enter image description here

$\endgroup$
  • $\begingroup$ You forgot to hyperlink "here" in the first sentence. $\endgroup$ – march Dec 2 '15 at 16:49
  • $\begingroup$ D'oh!! I'm at home now so I'll have to do it in a bit. It was a post about interpolation in listcontouplot that I made recently $\endgroup$ – Jason B. Dec 2 '15 at 17:24
  • $\begingroup$ With Version 10.3, I was unable to reproduce these figures without PlotRange -> All. Also, with ListContourPlot replaced by ListPlot3D, the addition of Mesh -> All produces what to me are surprising results. $\endgroup$ – bbgodfrey Dec 3 '15 at 5:02
  • $\begingroup$ I can't prove this, but I suspect that this is because in the first case you have an array of values that Mathematica can smoothly interpolate, but in the second case you are specifying a discrete domain at which the data are sampled, so interpolation order will never have an effect. The option will not force the plot to try to upsample your data in this case. The DataRange option in the first use of ListContourPlot is only telling Mathematica how you want the axes scaled. $\endgroup$ – djphd Dec 3 '15 at 5:08
  • $\begingroup$ @bbgodfrey - sorry about that, forgot that I have PlotRange->All set in my init.m file. In my opinion that should be the default, since the contour plots look atrocious without it. That is also interesting how Mesh->All interacts with the InterpolationOrder option. $\endgroup$ – Jason B. Dec 3 '15 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.