Waterfall Colour Procedure

Hi All,

I wrote this procedure which is really just copy and pasting bits from the manual but my final piece of code doesn't work.

I want to automate batch processing and colour the columns of the matrix by making a colour matrix of same size as data matirx.

Function WaterfallPlot(mat2D, xwave)
    wave mat2D, xwave  

    // Create waterfall plot
    NewWaterfall mat2D vs {xWave, *}        // You can manually set x and y scaling by specifying wavex  and wavey  to override the default scalings. Either wavex  or wavez  may be omitted by using a *
    ModifyWaterfall angle=50, axlen= 0.4, hidden= 0
   
    //  Colour bit that goes wrong
       
    Duplicate mat2D, mat1ColorIndex
    mat1ColorIndex=y
    ModifyGraph zColor(mat2D)={mat1ColorIndex,*,*,Rainbow}
End


When I use the procedure i get the error trace not in graph and it doesn't change the colours. BUT when I copy and paste the final line:
ModifyGraph zColor(mat2D)={mat1ColorIndex,*,*,Rainbow}
into the command line waterfall plot has has colour gradient.

Any idea what I'm doing wrong or how to get around this?

Thanks,

N
It's the use of "mat2D" as the trace name for zColor. Traces are not waves. The usual fix is like this:
ModifyGraph zColor($NameOfWave(mat2D))={mat1ColorIndex,*,*,Rainbow}
This works because by default trace names are the same as the displayed Y wave name. It breaks down if you plot two waves with the same name, either because it really is the same wave both times, or because you are using two waves from different data folders and those waves have the same name. In that case, you need to add the # syntax, and that can be tricky. You probably don't need to worry- it's rare to have two waterfall plots on one graph.

Of course, this isn't really a "trace", it's a waterfall plot. But the rules are the same.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com