3
$\begingroup$

I have a list of x-, and y-coordinates $(\{\{x_1,y_1\},\{x_2,y_2\},...\})$:

xy:={{0., 0.}, {0., 0.25}, {0., 0.5}, {0., 0.75}, {0., 1.0}}

corresponding to a list of densities $(\{f_1,f_2,...\})$:

f:={0.25, 0.5, 0.75, 0.5, 0.25}

How do I combine them in the correct format for ListDensityPlot $(\{\{x_1,y_1,f_1\},\{x_2,y_2,f_2\},...\})$?

xyf:={{0., 0., 0.25}, {0., 0.25, 0.5}, {0., 0.5, 0.75}, {0., 0.75, 0.5}, {0., 1.0, 0.25}}
$\endgroup$
3
$\begingroup$

For example

MapThread[Append, {xy, f}]

or

Append @@@ Transpose[{xy, f}]

or

Flatten /@ Transpose[{xy, f}]
$\endgroup$
  • 1
    $\begingroup$ Transpose[xy]~Join~{f} // Transpose, because why not. $\endgroup$ – corey979 Jan 9 '18 at 11:01

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.