ModifyImage error

hi all,

When plotting a new image from a user defined function, I get a ModifyImage error, saying "expected the name of an image in the top graph".
here is the function:

Function RectangularPlot(MxToPlot,PlotName)
    wave MxToPlot
    string PlotName
    SetDataFolder root:NWR:graph_variables:rectangle
    wave angle_ticklocator,angle_ticklabel
    NVar Radial_res=root:NWR:variables:Radial_res
    Display/N=NWRgraph as PlotName;AppendImage MxToPlot
    ModifyGraph/W=NWRgraph userticks(bottom)={angle_ticklocator,angle_ticklabel}
    ModifyImage/W=NWRgraph MxToPlot ctab= {*,*,Rainbow,1}
    ModifyGraph/W=NWRgraph axisEnab(bottom)={0,0.9}
    ModifyGraph/W=NWRgraph fStyle(bottom)=1,fSize(bottom)=14,fStyle(left)=1,fSize(left)=14
    //ColorScale/W=NWR_graph/C/N=cb_NWR/F=0/A=RC/X=-9.61/Y=0.51 heightPct=110,image=MxToPlot
    //ColorScale/W=NWR_graph/C/N=cb_NWR "concentration"
    SetScale/P y 0,Radial_res,"Wind speed (km/h)", MxToPlot
End Function


I don't get any errors if I do it all manually, so I'm probably missing something....
thanks for your help!
J-E Petit wrote:

    ModifyImage/W=NWRgraph MxToPlot ctab= {*,*,Rainbow,1}




I think it's because ModifyImage expects a name of a wave but you are providing a wave reference. I know two ways around it, maybe there are others:


function test(w)
    wave w  // image w
   
    display/K=1
    AppendImage w
   
        // (1) provide a name using $string
    ModifyImage $NameOfWave(w), ctab= {*,*,Rainbow,1}
       
       // (2) use of two single quotes for the displayed matrix
    ModifyImage ''#0,  ctab= {*,*,Rainbow,1}
end
Quote:
I think it's because ModifyImage expects a name of a wave but you are providing a wave reference.


That's not quite right.

You can use a wave reference wherever Igor expects a wave name. However ModifyImage does not expect a wave name - it expects an image name. To understand the difference, execute this:
Display
AppendImage/L=left/B=bottom0 mat
ModifyGraph axisEnab(bottom0)={0,0.45}
AppendImage/L=left/B=bottom1 mat
ModifyGraph axisEnab(bottom1)={0.55,1.00}
ModifyImage mat#1 ctab= {*,*,Rainbow,0}


This creates a graph with two images, mat and mat#1. mat is equivalent to mat#0.

This is analogous to the difference between wave names and trace names, which is explained here:
DisplayHelpTopic "Trace Names"