Python Forum
matplotlib pyplot ginput issue
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
matplotlib pyplot ginput issue
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  matplotlib.pyplot issue lonaveia 2 2,338 Jul-28-2020, 02:40 PM
Last Post: hussainmujtaba
  matplotlib.pyplot functions create new figures instead of applying to the current one karkas 2 2,091 Jul-09-2020, 08:32 AM
Last Post: karkas
  Plotting issue Matplotlib garam0 0 1,525 May-23-2020, 12:11 AM
Last Post: garam0
  How does pyplot know what was plotted by the output of pandas.DataFrame(...).cumprod( codeowl 2 2,193 Mar-28-2020, 08:27 AM
Last Post: j.crater
  zooming in pyplot window SchroedingersLion 0 2,193 Aug-02-2019, 02:59 PM
Last Post: SchroedingersLion
  How to draw rectangles in pyplot? SuchtyTV 4 6,434 Jul-14-2019, 02:41 PM
Last Post: SuchtyTV
  How to arrange the four pictures of a matplotlib.pyplot? vokoyo 0 2,770 Apr-04-2019, 10:58 PM
Last Post: vokoyo
  Problem with Matplotlib.pyplot LTMP 1 2,840 Aug-21-2018, 04:50 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020