Procedure Display matrix columns on graph
n.black
I think this should be pretty straight forward. I'm making a procedure such that I can plot all the columns of a matrix as traces on a graph. Essentially treating the columns as 1D waves.
This is what I've got so far.
Function PlotMatrixColumn(matrix, 1Dxwave)
wave matrix
wave 1Dxwave
Variable nCols = DimSize(matrix, 1)
Variable i
for (i = 0; i < nCols; i += 1)
Display /W=(454.5,315.5,849,524) matrix[*][i] vs wnum
endfor
// Graph formatting
ModifyGraph mirror=2
ModifyGraph fStyle=1
ModifyGraph axThick=1.5
Label left "\\Y label"
Label bottom "\\xlabel (cm\\S-1\\M)"
End
wave matrix
wave 1Dxwave
Variable nCols = DimSize(matrix, 1)
Variable i
for (i = 0; i < nCols; i += 1)
Display /W=(454.5,315.5,849,524) matrix[*][i] vs wnum
endfor
// Graph formatting
ModifyGraph mirror=2
ModifyGraph fStyle=1
ModifyGraph axThick=1.5
Label left "\\Y label"
Label bottom "\\xlabel (cm\\S-1\\M)"
End
I was hoping I could loop and call each wave as matrix[*][1] but when i tested the procedure it only plotted the 0th column.
Hopefully what i'm trying to do is clear.
As you guys on IGOR are generally fantastic at solving my problems while teaching me new things I thought I'd save time and ask you guys! =)
Thanks,
N
and to clarify I would like all the traces displayed on one graph
August 25, 2015 at 07:11 am - Permalink
Display matrix[][i] vs wnum
Since you need everything on one graph. You need to do it a bit differently.
wave matrix
wave 1Dxwave
Variable nCols = DimSize(matrix, 1)
Variable i
//set up graph window
DoWindow /K allPlot //kill it if it exists
Display /N=allPlot
for (i = 0; i < nCols; i += 1)
AppendToGraph /W=allPlot matrix[][i] vs wnum
endfor
// Graph formatting
ModifyGraph mirror=2
ModifyGraph fStyle=1
ModifyGraph axThick=1.5
Label left "\\Y label"
Label bottom "\\xlabel (cm\\S-1\\M)"
End
That should work. To resize your window to 454.5,315.5. etc. do that after the loop with your other stuff.
August 25, 2015 at 07:26 am - Permalink
wave matrix
wave xWave
Variable nCols = DimSize(matrix, 1)
Variable i
for (i = 0; i < nCols; i += 1)
DoWindow MatrixGraph
if (!V_flag)
Display/K=1 /W=(454.5,315.5,849,524)/N=MatrixGraph matrix[][i] vs xWave
else
AppendToGraph /W= MatrixGraph matrix[][i] vs xWave
endif
endfor
// Graph formatting
ModifyGraph mirror=2
ModifyGraph fStyle=1
ModifyGraph axThick=1.5
Label left "\\Y label"
Label bottom "\\xlabel (cm\\S-1\\M)"
End
August 25, 2015 at 07:27 am - Permalink
That did the trick! And it the code was more simpler/efficient that I thought it would be. =)
Hopefully others will find it helpful also.
Best wishes,
N
August 25, 2015 at 07:51 am - Permalink
I quote from the NewWaterfall command help:
using each column in the 2D matrix wave, mwave, as a waterfall trace.
You can manually set x and z scaling by specifying wavex and wavez to override
the default scalings. Either wavex or wavez may be omitted by using a *.
August 25, 2015 at 08:21 am - Permalink
I was using waterfall plots to illustrate my data, but unfortunately it made reading the Y axis quite unclear so I wanted to mass make the 90deg view that had a convenient legend next to it.
Impressed you could read through what I was trying to achieve!!!
Thanks,
N
August 25, 2015 at 09:28 am - Permalink