
ModifyImage should not use local wave names. It must be a global name

It is assumed to be used in a function, and
Which of the following is correct?
Wave M_image=$"wavename"
and then
1.ModifyImage /W=$S_WinName M_image cindex=CM_ColorScale
2.ModifyImage /W=$S_WinName $nameofwave(M_image) cindex=CM_ColorScale
1.ModifyImage /W=$S_WinName M_image cindex=CM_ColorScale 2.ModifyImage /W=$S_WinName $nameofwave(M_image) cindex=CM_ColorScale
The answer is 2.
Image data is passed as a string with the global wave name. Otherwise, the following error occurs...
While executing ModifyImage, the following error occurred: Expected the name of an image in the top graph.
I got stuck on this and lost a whole day of New Year's. Why is this? It's a reasonable specification considering that it is used as a command, but wouldn't it be better to accept 'M_image'? I don't remember if there is a description of this in the manual or some other document. Or has someone already pointed this out somewhere?
I guess I still have a lot to learn.
The name expected by ModifyImage is an "image name", not a wave name.
To understand this, consider these commands which display the same matrix twice in a single graph:
Now execute this to create a graph recreation macro:
This creates the following recreation macro in the procedure window:
Note the first ModifyImage command uses the image name "mat" while the second uses "mat1". ModifyImage could not use the wave name because it is the same wave and there would be no way to target the two image plots.
This is analogous to trace names. While it would be rare to use the same matrix twice in an image plot, it is less rare to use the same wave twice in a graph. Consequently Igor distinguishes between wave names and trace names, and the ModifyGraph command expects trace names. This is explained under the following help topic:
DisplayHelpTopic "Programming With Trace Names"
With traces, you can explicitly use a trace name that is different from the wave name:
I don't think there is a way to specify an explicit image name analogous to specifying an explicit trace name.
January 3, 2024 at 06:02 am - Permalink
THX~
January 3, 2024 at 07:16 pm - Permalink