Python Forum

Full Version: matplotlib pyplot ginput issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi. I am running PyCharm and I have an issue which I don't understand.

import numpy as np
import matplotlib.pyplot as plt

def ROIselection(mat):
    plt.imshow(mat,cmap='gray')
    plt.title("Click 4 times, vertices of a rectangle")
    plt.show()
    pts = plt.ginput(4)
    pts=np.array(pts)

    mask=np.zeros(mat.shape)
    xvals=pts[:,0]

    yvals=pts[:,1]

    mask[int(np.min(yvals)):int(np.max(yvals)),int(np.min(xvals)):int(np.max(xvals))]=1

    return mask

mat=np.random.rand(10,10)
ROIselection(mat)
If I copy and run this in an ipython terminal, there are no issues, works a charm. If I run this as a script in pycharm, the markers do not appear in the figure, and nothing gets saved. This is probably something silly, but I don't get it so would appreciate the help

thanks,

M