From b8b367b75b902573188eca6340076e8380f823e8 Mon Sep 17 00:00:00 2001 From: Thibault Barnouin Date: Sat, 30 Oct 2021 18:44:31 +0200 Subject: [PATCH] modify display to 3d output --- lib/plots.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/plots.py b/lib/plots.py index dfcca90..42f8b41 100755 --- a/lib/plots.py +++ b/lib/plots.py @@ -16,30 +16,31 @@ class DynamicUpdate(): def on_launch(self): #Set up plot - self.figure, self.ax = plt.subplots() - self.lines, = self.ax.plot([],[],'o') + self.fig = plt.figure() + self.ax = self.fig.add_subplot(projection='3d') + self.lines, = self.ax.plot([],[],[],'o') #Autoscale on unknown axis and known lims on the other self.ax.set_autoscaley_on(True) self.ax.set_xlim(self.min_x, self.max_x) self.ax.set_ylim(self.min_x, self.max_x) + self.ax.set_zlim(self.min_x, self.max_x) #Other stuff self.ax.grid() - self.ax.set_aspect('equal') + #self.ax.set_aspect('equal') - def on_running(self, xdata, ydata, step=None, label=None): + def on_running(self, xdata, ydata, zdata, step=None, label=None): #Update data (with the new _and_ the old points) - self.lines.set_xdata(xdata) - self.lines.set_ydata(ydata) + self.lines.set_data_3d(xdata, ydata, zdata) if not label is None: self.ax.set_title(label) #Need both of these in order to rescale self.ax.relim() self.ax.autoscale_view() #We need to draw *and* flush - self.figure.canvas.draw() - self.figure.canvas.flush_events() - if not step is None and step%10==0: - self.figure.savefig("tmp/{0:05d}.png".format(step),bbox_inches="tight") + self.fig.canvas.draw() + self.fig.canvas.flush_events() + if not step is None and step%50==0: + self.fig.savefig("tmp/{0:05d}.png".format(step),bbox_inches="tight") #Example def __call__(self):