How to find out if a wave is already displayed in a graph

veto
Posts: 3
Joined: 2018-06-04
Location: India

Hi
I am new to Igor programming and this is my first question here.
I have a generated a set of waves, using different equations that I am working with.
I have also created slider controls for the different parameters that are present in the equation. I am trying to make a macro that will enable the user to change the parameters with the slider and see the effects on the graph.

I have a choice of four waves to display. Displaying all of them clutters the graph. I would like to create a toggle button to choose if a given wave is displayed in my graph or not. I have created the button and the procedure. I used the commands appendtograph and Removefromgraph and was able to append a wave and remove a wave. I am not able to query if the wave is already displayed in the graph. Therefore I keep adding multiple copies of the wave or I reach an error where the I try to remove the wave when it is not present in the graph.

My question is : How can I find out if a given wave is displayed in the graph or not. Is there a command for this?
Thanks
veto


jtigor
Posts: 405
Joined: 2007-09-04
Location: United States

Not a direct answer to your question, but use RemoveFromGraph with the /Z flag to suppress an error message if the wave is not displayed in the graph.


aoa
Posts: 68
Joined: 2015-10-30
Location: United States

veto wrote:
My question is : How can I find out if a given wave is displayed in the graph or not. Is there a command for this?

One simple way is to use the built-in function WaveList(matchStr,";","WIN:winName") where winName is the name of the window you want to query. The matchStr could be the name of the wave of interest, and in that case the list returned by wavelist would have one item if the wave is displayed and zero items if it is not displayed. matchStr could also be "*" to get a list of all the waves in the graph. You could then use, for example, listmatch to find out if a wave of interest is plotted.


jtigor
Posts: 405
Joined: 2007-09-04
Location: United States

I think a limitation of WaveList is that it will only list waves in the graph that are in the current data folder. For a list of all waves displayed in the graph, regardless of data folder, use TraceNameList.


Posts: 1693
Joined: 2007-06-21
Location: United States

Use CheckDisplayed.


veto
Posts: 3
Joined: 2018-06-04
Location: India

hrodstein wrote:
Use CheckDisplayed.

Thank you
I used CheckDisplayed and this worked well.


ajleenheer
Posts: 73
Joined: 2013-04-26
Location: United States

A possibly alternate way to approach what you're doing is to simply hide the traces rather than remove & append them all the time. See this example panel:
http://www.igorexchange.com/node/4633

The upside is that the axes can keep the scaling range needed for all the waves.


Back to top