Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6998141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:22:24+00:00 2026-05-27T20:22:24+00:00

I am trying to get user selected points (to get a polygon) from an

  • 0

I am trying to get user selected points (to get a polygon) from an image. I have already embedded a matplotlib.figure in a lot of my code, so I would MUCH prefer to use this style over pylab’s figure. I am trying to do the follow:

import pylab
from matplotlib.figure import Figure

x1 = pylab.rand(103, 53) 
figure = Figure(figsize=(4, 4), dpi=100)
axes = figure.add_subplot(111)
axes.imshow(x1) 
x = figure.ginput(2) 

print(x)

But I get the following error:

Traceback (most recent call last):
  File "ginput_demo.py", line 17, in <module>
    x = figure.ginput(2)
  File "C:\Python27\lib\site-packages\matplotlib\figure.py", line 1177, in ginpu
t
    show_clicks=show_clicks)
  File "C:\Python27\lib\site-packages\matplotlib\blocking_input.py", line 282, i
n __call__
    BlockingInput.__call__(self,n=n,timeout=timeout)
  File "C:\Python27\lib\site-packages\matplotlib\blocking_input.py", line 94, in
 __call__
    self.fig.show()
AttributeError: 'Figure' object has no attribute 'show'

The original pylab code that works that I am trying to more or less reproduce is from here:

import pylab 

x1 = pylab.rand(103, 53) 
fig1 = pylab.figure(1) 
ax1 = fig1.add_subplot(111) 
ax1.imshow(x1) 
ax1.axis('image') 
ax1.axis('off') 
x = fig1.ginput(2) 

fig1.show() 

So basically, is there a way to get pylab.ginput to work with a matplotlib.figure or matplotlib.axes reference??

Thanks,

tylerthemiler

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:22:25+00:00Added an answer on May 27, 2026 at 8:22 pm

    You should use pylab.ginput instead of myfigure.ginput.
    After changing this, you will realize that axes.imshow is not plotting, you can fix it using pylab.imshow.
    And finally you will find that after clicking and getting the position numbers, the figure disappears, so you want to add a pylab.show at the end.

    This works, trying to follow as close as possible your prefered way of coding mpl:

    from pylab import show, ginput, rand, imshow
    from matplotlib.figure import Figure
    
    x1 = rand(103, 53) 
    figure = Figure(figsize=(4, 4), dpi=100)
    axes = figure.add_subplot(111)
    
    imshow(x1)
    x = ginput(2) 
    print(x)
    show()
    

    I think the problem here comes from mixing different modules (coding styles) from matplotlib.
    Your myfigure.ginput() complaints about its Figure class not having a show method. However it works with pylab.figure.ginput().
    In fact, pylab.figure, that is actually the one defined in the pyplot module:

    >>> import pylab
    >>> import matplotlib.pyplot as plt 
    >>> pylab.figure is plt.figure
    True
    

    although being of the class matplotlib.figure.Figure is not the same as the Figure instance

    myfigure = matplotlib.figure.Figure()
    

    pyplot.figure implements a couple of additional methods, one of them show():

    >>> from matplotlib import pyplot
    >>> from matplotlib.figure import Figure
    >>> pfig = set(dir(pyplot.figure()))
    >>> Ffig = set(dir(Figure()))
    >>> pfig.difference(Ffig)
    set(['number', 'show'])
    

    that’s why you got the AttributeError with the Figure instance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get user GUID from Active Directory. My code: DirectoryEntry entry =
I'm trying to get the following code working: string url = String.Format(@SOMEURL); string user
i'm trying to get an input box to get auto-selected when the user clicks
In the following code, I am trying to get a folder location from the
I am trying to get the anchorOffset of text selected by the user in
I'm trying to get a user control working asynchronously, yet no matter what I
I am trying to get the user defined global hot key for my application.
I'm trying to get a list of user's friends using fb connect for the
I'm trying to get all the direct reports of a User through Active Directory,
I am a noob Perl user trying to get my work done ASAP so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.