I have a long list, where the elements are of this kind {x,y,g,a1,a2,a3}
and I want to extract some sublists with which I can make plots or manipulate the elements.
For instance, if I want to make a ContourPlot
that has x
and y
as the cartesian axes and g
as the "third" axis that creates the contour, I would really love to have my entries rearranged in a nested way as {{x,y},g}
, from which I could easily create an InterpolatingFunction
like:
newlistTEMP = Interpolation[nestedlist, InterpolationOrder->2];
gfunc[x_,y_] := newlistTEMP[x,y];
However, I am failing at finding a clever way to rearrange the elements of my list into the desired nested list form. The best I can do is to extract a sublist like:
sublist = Cases[list, {x_, y_, g_, _, _, _} :> {x, y, g}];
but after this I am stuck.
Thank you for your help!
{{x, y}, g}
on the right hand-side inCases
? $\endgroup$data2 = {#[[1 ;; 2]], #[[3]]} & /@ data
$\endgroup$