4

when I use the script the window flashes and then disappears, so I just want to know how to make it stay for a long time? Thanks very much! you can get this python package form

from spectral import *
img = open_image('92AV3C.lan')
view = imshow(img, (29, 19, 9))


def imshow(data=None, bands=None, classes=None, source=None, colors=None,
       figsize=None, fignum=None, title=None, **kwargs):
    import matplotlib.pyplot as plt
    from spectral import settings
    from .graphics import get_rgb

    set_mpl_interactive()

    view = ImageView()
    if data is not None:
        view.set_data(data, bands, **kwargs)
    if classes is not None:
        view.set_classes(classes, colors, **kwargs)
    if source is not None:
        view.set_source(source)
    elif data is not None and len(data.shape) == 3 and data.shape[2] > 3:
        view.set_source(data)
    if fignum is not None or figsize is not None:
        fig = plt.figure(num=fignum, figsize=figsize)
        view.show(fignum=fig.number)
    else:
        view.show()

    if title is not None:
        view.set_title(title)
    return view
bogatron
  • 18,639
  • 6
  • 53
  • 47
Semie J
  • 41
  • 2

2 Answers2

1

I use PyCharm2019 and python3.8. After add two lines, it works. import matplotlib.pyplot as plt plt.pause(10)

Scentea
  • 11
  • 2
1

It flashes because the program execution finishes, which closes the GUI.

The common approach is to call plt.pause(<expected pause in seconds>) after calling view.show.

kist
  • 590
  • 2
  • 8