Kill uppermost Image Plot?

How can I kill the uppermost Image Plot?

(Want to use this command to close an Image Plot before I display a new one)

Thanks!
Hi,

WinName(0,1) will return the the top graph.

Killwindow Windowname will kill it.
I tried this:

String win
    win = WinName (0,1)
    print win
    KillWindow win


It prints the name of the top graph correctly -
But it just won't kill the top graph...
try

killwindow $win

This passes the contents of the string win as opposed to literally "win"
Yes, that did the trick! :) Thanks a lot!

As a side-effect, this command now kills my panel as well :/

How can I tell IGOR to only delete graphs and leave my panel alone?

I tried to use an exception to spare my panel, but it gets killed anyway:

        win = WinName (0,1)
    Test = cmpstr(win,"PanelName")
    if(Test != 0)
        KillWindow $win
    endif  


Seems the problem is that a graph is embedded in my panel by means of a subwindow... Wenn I try to kill the topmost graph, it automatically closes the panel (since it hosts the topmost graph in this case - what can I do to circumvent that?)
This snippet solved the case:

       
win = WinName(0,1)
    print win
    Test = cmpstr(win,"")
    if(Test != 0)
        KillWindow $win
    endif


Seems that IGOR writes "" for any window it cannot figure out :)
PeterR wrote:
This snippet solved the case:

       
win = WinName(0,1)
    print win
    Test = cmpstr(win,"")
    if(Test != 0)
        KillWindow $win
    endif


Seems that IGOR writes "" for any window it cannot figure out :)


I think that your interpretation of why your code works isn't quite right.

WinName() returns the name of the top window of the specified type or an empty string (""). If your top window is a panel and you pass 1 (meaning graphs) as the 2nd parameter to WinName, it should return "", as it seems it is doing in your case, since your top window is a panel, not a graph. The fact that the panel contains a graph subwindow should not matter.

When you pass an empty name to KillWindow in a function, it apparently kills the top window. I wouldn't expect this behavior based on the KillWindow documentation, and I have asked the programmer who wrote KillWindow to verify if this intended.

Ultimately you figured out the correct solution to your problem but I wanted to make sure that you understand why it works so you won't be confused about this in the future.