From 685a7629ea05d45fd296da7fc2b0b45486d2d604 Mon Sep 17 00:00:00 2001 From: Ernesto Oquelis <ernesto.oquelis@gmail.com> Date: Wed, 26 Sep 2018 19:32:17 +0200 Subject: [PATCH] why dient it work? --- fem_2d.py | 24 ++++++++++++------------ tests_2d.py | 2 ++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/fem_2d.py b/fem_2d.py index 1a4c611..6c3e247 100644 --- a/fem_2d.py +++ b/fem_2d.py @@ -324,10 +324,7 @@ class Visualizer: self.force_color = 'Magenta' self.displaced_element_color = 'Red' self.displaced_force = self.force_color - - import matplotlib.pyplot as plt - plt.figure(figsize=(self.plot_multiplier, self.plot_multiplier)) - self.plot = None + self.figure = None def draw_elements(self): """ @@ -336,9 +333,10 @@ class Visualizer: import matplotlib.pyplot as plt - self.plot = plt.triplot(self.struct.mesh_points[:, 0], - self.struct.mesh_points[:, 1], - self.struct.mesh_elements) + + plt.triplot(self.struct.mesh_points[:, 0], + self.struct.mesh_points[:, 1], + self.struct.mesh_elements) plt.gca().set_aspect('equal') plt.xlabel('X', fontsize=self.text_size) plt.ylabel('Y', fontsize=self.text_size) @@ -346,7 +344,9 @@ class Visualizer: for x_plot, y_plot in enumerate(self.struct.mesh_points): plt.text(y_plot[0] - 0.01, y_plot[1] + 0.01, x_plot, ha='right', fontsize=1.5 *self.text_size) - plt.show() + self.figure = plt.figure(figsize=(self.plot_multiplier, + self.plot_multiplier)) + plt.close('all') def draw_constraints(self): """ @@ -354,8 +354,8 @@ class Visualizer: """ import matplotlib.pyplot as plt - - self.plot + + self.figure for node in self.struct.node_list: constr = node.constraint_2d @@ -365,8 +365,8 @@ class Visualizer: if constr.value[0]: plt.text(pos[0], pos[1], '^', ha='center', fontsize=1.5 *self.text_size) - if constr.value[0]: - plt.text(pos[0], pos[1], '^', ha='center', + if constr.value[1]: + plt.text(pos[0], pos[1], '>', ha='center', fontsize=1.5 *self.text_size) ''' def draw_constraints(self): diff --git a/tests_2d.py b/tests_2d.py index 45c0f28..a36ae14 100644 --- a/tests_2d.py +++ b/tests_2d.py @@ -18,6 +18,8 @@ VIS = Visualizer(STR, plot_multiplier) STRUCT = list() STRUCT.append(STR) +VISUA = list() +VISUA.append(VIS) STR.node_list[0].constraint_2d = Constraint2D([1, 1]) STR.node_list[1].constraint_2d = Constraint2D([1, 1]) -- GitLab