Procedure Display matrix columns on graph

Hi All,

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


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
sorry wnum = 1Dxwave I was trying to make my original code a little more transparent!

and to clarify I would like all the traces displayed on one graph
You don't need the [*]. Go for Display matrix[][i] vs wnum
Since you need everything on one graph. You need to do it a bit differently.

Function PlotMatrixColumn(matrix, 1Dxwave)
    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.
something like this?

Function PlotMatrixColumn(matrix, xWave)
    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
Thanks sjr51 and ChrLie,

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
It seems to me that what you are describing might also be displayed in one graph as a Waterfall plot, a "sequence of traces in a perspective view".
DisplayHelpTopic "Waterfall Plots"

I quote from the NewWaterfall command help:
The NewWaterfall operation creates a new waterfall plot window or subwindow
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 *.

Thanks for the input s.r.chinn,

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