omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. scoodood

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    scoodood

    @scoodood

    0
    Reputation
    262
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    scoodood Unfollow Follow

    Latest posts made by scoodood

    • fig.canvas.flush_events() -> NotImplementedError

      The following code works fine on my OSX. But it doesn't work on Pythonista. Why?
      Anyone know how to do dynamic update on Matplotlib? Thanks

      # import matplotlib
      # matplotlib.use('TkAgg')          # OSX need this
      
      import time
      import numpy as np
      import matplotlib.pyplot as plt
      
      plt.ion()
      
      class Plot:
          def __init__(self):
              self.deg = np.arange(0, 360, .1)
              self.rad = np.deg2rad(self.deg)
              self.cos = np.cos(self.rad)
              self.fig = plt.figure()
              self.ax = self.fig.add_subplot(111)
              self.ax.plot(self.deg, self.cos)
              self.ax.grid()
      
          def run(self, counter=100):
              for i in range(counter):
                  self.cos = np.roll(self.cos, -30)
                  self.ax.lines[0].set_xdata(self.deg)
                  self.ax.lines[0].set_ydata(self.cos)
                  self.fig.canvas.draw()
                  self.fig.canvas.flush_events()
                  time.sleep(.01)
      
      pp = Plot()
      pp.run()
      
      posted in Pythonista
      scoodood
      scoodood