1
$\begingroup$

Is there any function to plot vectors in form $(x,y,z)$ where first coordinate is X value, second- Y value and color of square represents third coordinate? It should look like ArrayPlot.

Here is a sample of my data (http://pastebin.com/nHprReDu) and the results I obtain using ListDensityPlot:

enter image description here

$\endgroup$
3
$\begingroup$

ListDensityPlot will deal with data in that format. An interpolation order of zero will reproduce the "blocky" ArrayPlot output as well.

data = Flatten[Table[{x, y, Sin[x] + Sin[y]}, {x, -3 Pi, 3 Pi}, {y, -3 Pi, 3 Pi}], 1];
ListDensityPlot[data, InterpolationOrder -> 0]

Mathematica graphics


Thank you for posting your data. Unfortunately, the data you have is not regularly sampled, hence the irregular shapes in the ListDensityPlot. However, you can interpolate and resample if you want "square" blocks. Below, data is your data from pastebin.

if = Interpolation[data];
ListDensityPlot[
 Flatten[Table[{x, y, if[x, y]}, {x, 1, 23, 2}, {y, 1, 14}], 1],
 InterpolationOrder -> 0
]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thank you for idea, but in my case it returns not only squares, what's weird because values are different $\endgroup$ – pupilx Jan 26 '17 at 22:16
  • $\begingroup$ @pupilx You should add your data and the results in the question, so we can compare results. $\endgroup$ – MarcoB Jan 26 '17 at 22:18
  • $\begingroup$ Please see my edit $\endgroup$ – pupilx Jan 26 '17 at 22:31
  • $\begingroup$ @pupilx Thank you for the data. I have amended my answer. Take a look at the new version. $\endgroup$ – MarcoB Jan 26 '17 at 22:41
  • $\begingroup$ Thank you, it helps me a lot. The most important for me is not to lose information if value < 1, because then I need to construct true/false matrix , will it be ok? $\endgroup$ – pupilx Jan 26 '17 at 22:47

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.