I have a table (N x M).
I would like to plot some random points {i,j}with PlotMarkers being represented by the corresponding values in the table (row i, column j).
Can anyone help me with this?
I have a table (N x M).
I would like to plot some random points {i,j}with PlotMarkers being represented by the corresponding values in the table (row i, column j).
Can anyone help me with this?
This plots the value in the nxm matrix in locations corresponding to the indices. Is that what you meant?
data = Table[RandomReal[{-10, 10}], {3}, {5}];
{n, m} = Dimensions[data];
locations = Flatten[Table[{{i, j}}, {i, n}, {j, m}], 1];
markers = Flatten[data];
ListPlot[locations, Frame -> True, Axes -> False,
PlotMarkers -> markers, PlotRangePadding -> Scaled[.2]]
As an inlustration for what I want:
For a small table, I can do it in the following manner:
Suppose I want 30 points, {i,j}
i = RandomInteger[{1, N}, 30];
j = RandomInteger[{1, M}, 30];
points = Transpose[{i, j}];
Let M be my table, I can plot what I want brutally:
Show[ListPlot[{#}, PlotMarkers -> M[[#[[1]], #[[2]]]], PlotRange -> All] & /@ points]
But, if the required sample size increases (the limit being, say, the bare readablity of the plotted numbers), I am affraid that this isn’t the most rational way.
Hi Sandu,
This is pretty confusing. Do I understand that:
If that is the case, you could also read the same value off the plot axes, of course not exactly.
Regards,
David
No, no.. you got it right, and your code is very useful.
I was required to plot 441 points. So I tried to see how it would work with a matrix 22 x 20. This takes some time even with your solution and it gives “A very large output…”
So I was a bit concerned with this and was looking for other ways.
But then, surprisingly for me at least, I did it with 441 points and it went almost instantly. I went back and ListPlotted again (with locations= Output from locations and markers= Output from markers) and it worked very fast. I cannot explain this phenomenon..
but, in the end it worked perfectly.
Thanks a lot!