omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    fig.canvas.flush_events() -> NotImplementedError

    Pythonista
    3
    2
    2211
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • scoodood
      scoodood last edited by

      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()
      
      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        Matplotlob on pythonista has some limitations, since it is not based on gtk, etc. So just the image back end.

        I have an experimental pythonista back end, which allows interactive plots.

        https://github.com/jsbain/backend_pythonista

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors