8

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

Jason B.
  • 68,381
  • 3
  • 139
  • 286
  • You forgot to hyperlink "here" in the first sentence. – march Dec 02 '15 at 16:49
  • 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 – Jason B. Dec 02 '15 at 17:24
  • 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. – bbgodfrey Dec 03 '15 at 05:02
  • 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. – djphd Dec 03 '15 at 05:08
  • @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. – Jason B. Dec 03 '15 at 07:45
  • @djphd, it really ought to be able to upsample the data using the exact same interpolation routines that Interpolation uses. Especially since the data provided by dta2 is on a rectangular grid. – Jason B. Dec 03 '15 at 07:50

0 Answers0