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 7902401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:29:07+00:00 2026-06-03T09:29:07+00:00

My problem is: I have Matplotlib figure in PyGTK application, that is constatly updated

  • 0

My problem is:
I have Matplotlib figure in PyGTK application, that is constatly updated each few seconds. I’ve added abbility to save figure to disk as PNG file. After calling figure.savefig(filename, other parameters) my figure in application stops being updated.

Figure initialization phase:

# setup matplotlib stuff on empty space in vbox4
    figure = Figure()
    canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
    canvas.show()
    self.win.get_widget('vbox4').pack_start(canvas, True, True) # this will be aded to last place
    self.win.get_widget('vbox4').reorder_child(canvas, 1) #place plot to space where it should be

Figure is being updated this way (this called each few seconds in separate thread):

def _updateGraph(self, fig, x, x1, y):
    #Various calculations done here

    fig.clf()#repaint plot: delete current and formate a new one
    axis = fig.add_subplot(111)
    #axis.set_axis_off()
    axis.grid(True)
#remove ticks and labels
    axis.get_xaxis().set_ticks_position("none")
    for i in range(len(axis.get_xticklabels())): axis.get_xticklabels()[i].set_visible(False)
    axis.get_yaxis().set_ticks_position("none")
    axis.plot(numpy.array(x),numpy.array(y)/(1.0**1), "k-" ,alpha=.2)
    axis.set_title('myTitle')
    fig.autofmt_xdate()
    fig.canvas.draw()

everything works as expected. But after calling:

figure.savefig(fileName, bbox_inches='tight', pad_inches=0.05)

File have been saved, BUT my figure on screen stops being updated.

Any ideas how do I save figure to disk and still be able to update my fig on screen ?

  • 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-06-03T09:29:08+00:00Added an answer on June 3, 2026 at 9:29 am

    I have found a work-a-round to this. As my figure refuses to be updated after calling figure.savefig() so i found a way how to work a round it. My figure is within HBox2 container (GUI is created with Glade 3.6.7) as first element

    #   some stuff going
        figure.saveFig(fileName)
    #   WORK-A-ROUND: delete figure after calling savefig()
        box = self.win.get_widget('hbox2')
        box.remove(box.get_children()[0])
        self._figPrepare()
    
    def _figPrepare(self):  #initialize graph
        figure = Figure()
        canvas = FigureCanvasGTK(figure) # a gtk.DrawingArea
        canvas.show()       
        figure.clf()
        gui.w().set("figure", figure)
        self.win.get_widget('hbox2').pack_start(canvas, True, True) # this will be aded to last place
        self.win.get_widget('hbox2').reorder_child(canvas, 0) #place plot to space where it should be
    

    I know this is not best practice, and probably is slow, but it work OK for me. Hope someone else will find this useful

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

Sidebar

Related Questions

I've seen that a few instances of this problem have been raised already. However,
I have a matplotlib figure that I want to be able to switch between
I have a problem with Matplotlib 1.0.1 I create a figure, and the I
I have a Python program that generates a histogram using matplotlib. The problem is
I have built PyGTK application with matplotlib graph in it. I also would like
Problem : I have a hand held device that scans those graphic color barcodes
Problem I have a custom tab control using Chrome-shaped tabs that binds to a
I have a problem getting matplotlib 1.0.0 to work in Python 2.5.2 ( Ubuntu
I have a matplotlib figure inside of a wxmpl panel, and am trying to
I have a wxPython application which contains a matplotlib panel (courtesy of wxmpl, though

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.