How to handle output window minimize/movement in interactive mode of matplotlib

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sharath067
    New Member
    • Dec 2009
    • 2

    How to handle output window minimize/movement in interactive mode of matplotlib

    I want to dynamically update the scatter plot based on the y-axis data received from a socket connection. I used python matplot lib in interactive mode to do this, but during dynamic updation if i move the window to a different location or minimize the window then the plot updation stops abruptly. Please let me know how to do this?

    I have attached a sample dynamic updation code used here and the same problem appears here also, please help.
    Code:
    import matplotlib.pyplot as plt
    import random
    import time
    items = [25.5,26.7,23.4,22.5,20,13.4,15.6,-12,-16,20]
    x = [1,2,3,4,5,6,7,8,9,10]
    
    plt.ion() #  Interactive on
    
    for i in range(1,100):
        plt.title('graph plotting')
        plt.ylabel('temperature')
        plt.xlabel('time')
        random.shuffle(items)
        plt.plot(x,items,'ob-')
        plt.axis([0, 10, -40, 40])
        plt.draw()
        #time.sleep(2)
        plt.clf()
    plt.close()
    Last edited by bvdet; Dec 22 '09, 04:02 PM. Reason: Add code tags
  • Glenton
    Recognized Expert Contributor
    • Nov 2008
    • 391

    #2
    Hi

    If you manage to do this, I'd be very interested! I use matplotlib to make my plots for papers, presentations etc, but also use python to control experiments, and couldn't figure out how to do this exact thing with matplotlib, although I didn't try as hard as I could yet! Still somewhere down there on my to do list!

    Anyway, the way I solved it was with gnuplot, and the corresponding gnuplot module for python. I don't really know how to use gnuplot, but you don't really have to, as it's a similar kind of interface to matplotlib.

    However, I have a feeling there's a python mega widget (PMW) or something similar that might be better still for this purpose. I vaguely remember seeing something about this in Langtangen's excellent Python Scripting for Computational Scientists. I'll try to remember to look it up when I get back to the office.

    Comment

    • sharath067
      New Member
      • Dec 2009
      • 2

      #3
      Ya I figured out how to do this...You need to use wxPython with matplotlib for this purpose...refer this link for more

      Comment

      Working...