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

  • Home
  • SEARCH
  • 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 8255723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:37:25+00:00 2026-06-08T01:37:25+00:00

Background: I am working an a data processing application and am trying to visualize

  • 0

Background: I am working an a data processing application and am trying to visualize 2D arrays with matplotlib embedded into a tkinter gui. I am trying to update the matplotlib figure by collecting user input (i.e. what frame they want displayed, various other options) so I do not want to generate the animation in advance.

System: Windows xp, Python 2.7, matplotlib 1.1.1rc

Question: How do I update only the image produced by imshow and not the colorbar?

GUI
gui snapshot
Notice how color bars write over themselves.

Code: note: the code below is untested, however it is the basic idea of how my current code is setup

import matplotlib
import matplotlib.pyplot as plt
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
import Tkinter as tk
import numpy as np


class MainWindow:
    def __init__(self,application):
        self.mainframe=tk.Frame(application)

        #update button
        ttk.Button(application,text='Update',command=self.update).pack()

        #matplotlib setup
        self.ren2DFig=plt.figure(figsize=(4,4),dpi=100)
        self.renCanvas=FigureCanvasTkAgg(self.ren2DFig,master=self.renWin2D)
        self.renCanvas.show()
        self.renCanvas.get_tk_widget().pack()

        self.subPlot=self.ren2DFig.add_subplot(111)
        self.subPlot.get_yaxis().set_visible(False)
        self.subPlot.get_xaxis().set_visible(False)
        self.subPlot.get_axes().set_frame_on(False)
        frame=np.zeros((20,40),)
        frame[9:11 ,9:11]=1
        frame[5 ,5]=.5
        self.im=self.subPlot.imshow(self.rotate(frame), origin = 'lower')
        self.cbar=self.ren2DFig.colorbar(self.im)
        self.cbar.set_label('Solid Fraction')
        self.renCanvas.draw()
        self.ren2DFig.canvas

    def update(self):
        self.im.set_array(np.zeros((20,40),))
        self.renCanvas.draw() # I think this is the problem?

application=tk.Tk()
application.focus_force()
window=MainWindow(application)
application.protocol("WM_DELETE_WINDOW",window.close)
application.mainloop()

Any help would be much appreciated! Thanks!

Update[July 13, 2012]:

If I try clearing the subplot, then adding the image and color bar back, finally re-drawing the canvas I get this:

matplotlib

What the heck am I doing wrong?????? This is really starting to irritate me.

  • 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-08T01:37:26+00:00Added an answer on June 8, 2026 at 1:37 am

    I figure it out. The problem is with

    self.subPlot.get_axes().set_frame_on(False)
    

    I guess it is a bug or something but if I change it to True, i.e.

    self.subPlot.get_axes().set_frame_on(True)
    

    It works just fine, everything updates like normal.

    This little thing stumped me for two days!!! Go figure. lol.

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

Sidebar

Related Questions

First some background: I'm working on an application and I'm trying to follow MVVM
Background: working a user q&a site where users logged,etc. What user/visitor data should be
Background: Trevor was working on a test project solely for the purpose of trying
I'm working on a Qt GUI for visualizing 'live' data which is received via
Background: I am working on an Android Honeycomb (v3.0) application that has a requirement
Background I'm working with byte arrays in JNI . And I can't get length
Background I'm working on building an ASP.Net MVC 3 application that utilizes: JQueryUI for
A little background I'm working on an .net application that's uses plugins heavily, the
I have seen progress bar in mobile which are working continuously while processing data
I'm a person with a non-programming background working on a web application that must

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.