Creating an Image Plot from XYZ (sparse matrix) data
patricochet
I have a set of X,Y,Z data, a "confusion matrix," that I'd like to present in an image plot. The data is essentially:
Correct Answer, Guessed Answer, Counts of Guessed Answer
Most of the data is along the X=Y axis, since most of the answers are right, but it's enlightening to see bright spots, either in greyscale or false color, to show obviously confused choices (people incorrectly guess #13 for #2 and #2 for #13, say.)
However, most of the 2D matrix this represents is zeros; there are few wrong Guesses for any given Answer.
Is there a way to make an Image Plot of XYZ data?
Or do I need to convert the sparse matrix into a full 2D matrix will all the zeros. If so, is there an elegant way to do this besides initializing a zero-filled 2D matrix of the appropriate size, and two nested FOR loops? It's one line of code in MATLAB, and I was hoping for a similar sparse->2D command, or better yet, something I'm missing in AppendImage that will let me use the XYZ data directly.
Thanks in Advance,
Patrick
IP5 is very old so it's time to consider an upgrade. In IP6 I'd use something like the code below and then display the wave "full".
HTH,
A.G.
WaveMetrics, Inc.
Wave inWave
MatrixOP/Free/O aa=col(inWave,0)
MatrixOP/Free/O bb=col(inWave,1)
MatrixOP/Free/O cc=col(inWave,2)
Variable rows=WaveMax(aa)
Variable cols=WaveMax(bb)
Make/O/n=(rows,cols) full=0
Variable i,num=DimSize(aa,0)
for(i=0;i<num;i+=1)
full[aa[i]][bb[i]]=cc[i]
endfor
End
March 4, 2010 at 04:30 pm - Permalink
Also ImageInterpolate, I think. 5.05 is a *long* time ago.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
March 9, 2010 at 11:46 pm - Permalink
xw, yw, zw
Then do the following to display it as an image:
ModifyGraph mode=2
ModifyGraph lsize=2
ModifyGraph zColor(yw)={zw,*,*,Rainbow,0}
Change lsize (dot size) and the color table (Rainbow) so that the plot looks nice. zColor can be accessed from the graph by double clicking on the trace, and then choosing "Set as f(z)..." for Color.
August 9, 2011 at 08:28 am - Permalink