0

I have a piece of code in python that creates an animation, and generates a plot. The code relevant to the animation is as below:

class Node:
    def __init__(self):
        self.fig, self.ax = plt.subplots()
        self.ln_agents, = plt.plot([],[], 'bs')

        ani = animation.FuncAnimation(self.fig, self.draw_agents, self.new_data, init_func=self.init_2DSpace, interval=200)#interval=2000
        plt.show()

    def draw_agents(self, points):
        if condition met:
            plt.close()
        self.ln_agents.set_xdata(np.array(points[0]))
        self.ln_agents.set_ydata(np.array(points[1]))

The animation should stop when some condition is met. I need to run this code on a remote server, such that it continues running even when the ssh connection is dropped. I know I can achieve this with the screen command on the ubuntu terminal. I don't need to see the output on my local machine. When I ssh to the server without the -X flag I get the following error

Unexpected error: (, TclError('no display name and no $DISPLAY environment variable',), )

Any suggestions? Thanks!!

  • What exactly do you want to `show` without x server? – ImportanceOfBeingErnest Mar 23 '18 at 13:14
  • I want everything to be running on remote, without needing to see it on my local machine. – highWaters Mar 23 '18 at 15:48
  • maybe asked differently: What is the purpose of an animation which noone can see, because it's played on a server without display? – ImportanceOfBeingErnest Mar 23 '18 at 15:51
  • I see your point. Let me explain. The animation per se is not the goal of my code. I am running some simulations, and I added the animation such that it can help me visualize what is going on. What I did was to remove that part and send the code to the remote server. However, I'd like to understand how it can be done. It might be that it is indeed a stupid question :). – highWaters Mar 24 '18 at 15:01
  • I guess the problem is rather the `plt.show()`. But to be on the safe side, you should probably just choose a [non-interactive backend](https://stackoverflow.com/questions/4931376/generating-matplotlib-graphs-without-a-running-x-server) for the server side code. – ImportanceOfBeingErnest Mar 24 '18 at 15:10

0 Answers0