diff --git a/src/ansys/fluent/visualization/matplotlib/plotter_defns.py b/src/ansys/fluent/visualization/matplotlib/plotter_defns.py index 5ab05f6c..f5194a0f 100644 --- a/src/ansys/fluent/visualization/matplotlib/plotter_defns.py +++ b/src/ansys/fluent/visualization/matplotlib/plotter_defns.py @@ -52,9 +52,8 @@ def __init__( self._data = {} self._closed = False self._visible = False - if not remote_process: - self.fig = plt.figure(num=self._window_id) - self.ax = self.fig.add_subplot(111) + self._remote_process = remote_process + self.fig = None def plot(self, data: dict) -> None: """Draw plot in window. @@ -79,11 +78,19 @@ def plot(self, data: dict) -> None: self._min_x = min(self._min_x, min_x_value) if self._min_x else min_x_value self._max_x = max(self._max_x, max_x_value) if self._max_x else max_x_value - curve_lines = self.ax.lines - for curve, curve_line in zip(self._curves, curve_lines): - curve_line.set_data( - self._data[curve]["xvalues"], self._data[curve]["yvalues"] - ) + if not self._remote_process: + self.fig = plt.figure(num=self._window_id) + self.ax = self.fig.add_subplot(111) + if self._yscale: + self.ax.set_yscale(self._yscale) + self.fig.canvas.manager.set_window_title("PyFluent [" + self._window_id + "]") + plt.title(self._title) + plt.xlabel(self._xlabel) + plt.ylabel(self._ylabel) + for curve in self._curves: + self.ax.plot(self._data[curve]["xvalues"], self._data[curve]["yvalues"]) + plt.legend(labels=self._curves, loc="upper right") + if self._max_x > self._min_x: self.ax.set_xlim(self._min_x, self._max_x) y_range = self._max_y - self._min_y @@ -142,20 +149,16 @@ def __call__(self): # private methods def _reset(self): - plt.figure(self.fig.number) - self.ax.cla() - if self._yscale: - self.ax.set_yscale(self._yscale) for curve_name in self._curves: self._data[curve_name] = {} self._data[curve_name]["xvalues"] = [] self._data[curve_name]["yvalues"] = [] + if not self.fig: + return + plt.figure(self.fig.number) + self.ax.cla() + for curve_name in self._curves: self.ax.plot([], [], label=curve_name) - self.fig.canvas.manager.set_window_title("PyFluent [" + self._window_id + "]") - plt.title(self._title) - plt.xlabel(self._xlabel) - plt.ylabel(self._ylabel) - plt.legend(labels=self._curves, loc="upper right") class ProcessPlotter(Plotter):