Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into main
  • Loading branch information
prmukherj committed Aug 19, 2024
2 parents 9c7a215 + a16e46f commit 616dea1
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions src/ansys/fluent/visualization/matplotlib/plotter_defns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 616dea1

Please sign in to comment.