Message Boards Message Boards

PlotMarkers as values

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?
POSTED BY: Sandu Ursu
3 years ago
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]]
POSTED BY: David Keith
3 years ago
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.
POSTED BY: Sandu Ursu
3 years ago
Hi Sandu,
This is pretty confusing. Do I understand that:
  1. You have a large matrix nxm in size.
  2. Each element of the matrix is itself a point {x,y}. So the dimensions are {n,m,2}
  3. You want to select a randomsu bset of these points from the matrix,
  4. You then want to plot the subset of points as with ListPlot.
  5. For each point you want its PlotMarker to be its {x,y} value, which is in fact its{x,y} location on the plot.
If that is the case, you could also read the same value off the plot axes, of course not exactly.
POSTED BY: David Keith
3 years ago
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.. emoticon  but, in the end it worked perfectly.

Thanks a lot!
POSTED BY: Sandu Ursu
3 years ago

Group Abstract Group Abstract