Creating an Image Plot from XYZ (sparse matrix) data
| patricochet | March 4, 2010 - 14:09 | ||
|---|---|---|---|
|
Disclaimer: I've got version 5.05 of Igor Pro, but I'd be willing to upgrade if this solves my problem easily. 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, |
|||

Joined: 2007-06-29
Location: United States
Hello 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.
Joined: 2007-07-19
Location: United States
It's *not* elegant, but you can use the ContourZ function to create an matrix from XYZ points.
Also ImageInterpolate, I think. 5.05 is a *long* time ago.
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Joined: 2011-08-04
Location: France
Say your X, Y, Z data is in waves
xw, yw, zwThen do the following to display it as an image:
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.