def plot_structure( self, figsize, verbosity, show=False, supports=True, scale=1, offset=(0, 0), gridplot=False, annotations=True, ): """ :param show: (boolean) if True, plt.figure will plot. :param supports: (boolean) if True, supports are plotted. :param annotations: (boolean) if True, structure annotations are plotted. It includes section name. :return: """ if not gridplot: self.__start_plot(figsize) x, y = super().structure() max_x = np.max(x) min_x = np.min(x) max_y = np.max(y) min_y = np.min(y) center_x = (max_x - min_x) / 2 + min_x + -offset[0] center_y = (max_y - min_y) / 2 + min_x + -offset[1] max_plot_range = max(max_x, max_y) ax_range = max_plot_range * scale plusxrange = center_x + ax_range plusyrange = center_y + ax_range * figsize[1] / figsize[0] minxrange = center_x - ax_range minyrange = center_y - ax_range * figsize[1] / figsize[0] self.one_fig.axis([minxrange, plusxrange, minyrange, plusyrange]) for el in self.system.element_map.values(): x_val, y_val = plot_values_element(el) self.one_fig.plot(x_val, y_val, color="black", marker="s") if verbosity == 0: # add node ID to plot ax_range = max_plot_range * 0.015 self.one_fig.text( x_val[0] + ax_range, y_val[0] + ax_range, "%d" % el.node_id1, color="g", fontsize=9, zorder=10, ) self.one_fig.text( x_val[-1] + ax_range, y_val[-1] + ax_range, "%d" % el.node_id2, color="g", fontsize=9, zorder=10, ) # add element ID to plot factor = 0.02 * self.max_val_structure x_val = (x_val[0] + x_val[-1]) / 2 - np.sin(el.angle) * factor y_val = (y_val[0] + y_val[-1]) / 2 + np.cos(el.angle) * factor self.one_fig.text(x_val, y_val, str(el.id), color="r", fontsize=9, zorder=10) # add element annotation to plot # TODO: check how this holds with multiple structure scales. if annotations: x_val += +np.sin(el.angle) * factor * 2.3 y_val += -np.cos(el.angle) * factor * 2.3 self.one_fig.text(x_val, y_val, el.section_name, color="b", fontsize=9, zorder=10) # add supports if supports: self.__fixed_support_patch(max_plot_range * scale) self.__hinged_support_patch(max_plot_range * scale) self.__rotational_support_patch(max_plot_range * scale) self.__roll_support_patch(max_plot_range * scale) self.__rotating_spring_support_patch(max_plot_range * scale) self.__spring_support_patch(max_plot_range * scale) if verbosity == 0: # add_loads self.__q_load_patch(max_plot_range, verbosity) self.__point_load_patch(max_plot_range, verbosity) self.__moment_load_patch(max_plot_range) if show: self.plot() else: return self.fig
def plot_structure(self, figsize, verbosity, show=False, supports=True, scale=1, offset=(0, 0), gridplot=False): """ :param show: (boolean) if True, plt.figure will plot. :param supports: (boolean) if True, supports are plotted. :return: """ if not gridplot: self.__start_plot(figsize) x, y = super().structure() max_x = np.max(x) min_x = np.min(x) max_y = np.max(y) min_y = np.min(y) center_x = (max_x - min_x) / 2 + min_x + -offset[0] center_y = (max_y - min_y) / 2 + min_x + -offset[1] max_plot_range = max(max_x, max_y) ax_range = max_plot_range * scale plusxrange = center_x + ax_range plusyrange = center_y + ax_range * figsize[1] / figsize[0] minxrange = center_x - ax_range minyrange = center_y - ax_range * figsize[1] / figsize[0] self.one_fig.axis([minxrange, plusxrange, minyrange, plusyrange]) for el in self.system.element_map.values(): x_val, y_val = plot_values_element(el) self.one_fig.plot(x_val, y_val, color='black', marker='s') if verbosity == 0: # add node ID to plot ax_range = max_plot_range * 0.015 self.one_fig.text(x_val[0] + ax_range, y_val[0] + ax_range, '%d' % el.node_id1, color='g', fontsize=9, zorder=10) self.one_fig.text(x_val[-1] + ax_range, y_val[-1] + ax_range, '%d' % el.node_id2, color='g', fontsize=9, zorder=10) # add element ID to plot factor = 0.02 * self.max_val_structure x_val = (x_val[0] + x_val[-1]) / 2 - np.sin(el.angle) * factor y_val = (y_val[0] + y_val[-1]) / 2 + np.cos(el.angle) * factor self.one_fig.text(x_val, y_val, str(el.id), color='r', fontsize=9, zorder=10) # add supports if supports: self.__fixed_support_patch(max_plot_range * scale) self.__hinged_support_patch(max_plot_range * scale) self.__roll_support_patch(max_plot_range * scale) self.__rotating_spring_support_patch(max_plot_range * scale) self.__spring_support_patch(max_plot_range * scale) if verbosity == 0: # add_loads self.__q_load_patch(max_plot_range, verbosity) self.__point_load_patch(max_plot_range, verbosity) self.__moment_load_patch(max_plot_range) if show: self.plot() else: return self.fig
def plot_structure( self, figsize, verbosity, show=False, supports=True, scale=1, offset=(0, 0), gridplot=False, annotations=True, free_body_diagram=0, figure=None, ): """ :param show: (boolean) if True, plt.figure will plot. :param supports: (boolean) if True, supports are plotted. :param annotations: (boolean) if True, structure annotations are plotted. It includes section name. :param free_body_diagram: (int) if 0, structure will be plotted normally; if 1 free body diagram will be plotted with results; if 2 free body diagram will be plotted and results for support reactions will be replaced by unknown variables (this third option currently only works if structure is isostatic). :return: """ if not gridplot: self.__start_plot(figsize, figure) x, y = super().structure() max_x = np.max(x) min_x = np.min(x) max_y = np.max(y) min_y = np.min(y) center_x = (max_x - min_x) / 2 + min_x + -offset[0] center_y = (max_y - min_y) / 2 + min_y + -offset[1] max_plot_range = max(max_x - min_x, max_y - min_y) ax_range = max_plot_range * scale plusxrange = center_x + ax_range plusyrange = center_y + ax_range * figsize[1] / figsize[0] minxrange = center_x - ax_range minyrange = center_y - ax_range * figsize[1] / figsize[0] self.one_fig.axis([minxrange, plusxrange, minyrange, plusyrange]) for el in self.system.element_map.values(): x_val, y_val = plot_values_element(el) self.one_fig.plot(x_val, y_val, color=self.cs.structure_element, marker="s") if verbosity == 0: # add node ID to plot ax_range = max_plot_range * 0.015 self.one_fig.text( x_val[0] + ax_range, y_val[0] + ax_range, "%d" % el.node_id1, color=self.cs.structure_node_id, fontsize=settings.size, zorder=10, ) self.one_fig.text( x_val[-1] + ax_range, y_val[-1] + ax_range, "%d" % el.node_id2, color=self.cs.structure_node_id, fontsize=settings.size, zorder=10, ) # add element ID to plot factor = 0.02 * self.max_val_structure x_val = (x_val[0] + x_val[-1]) / 2 - np.sin(el.angle) * factor y_val = (y_val[0] + y_val[-1]) / 2 + np.cos(el.angle) * factor self.one_fig.text( x_val, y_val, str(el.id), color=self.cs.structure_element_id, fontsize=settings.size, zorder=10 ) # add element annotation to plot # TODO: check how this holds with multiple structure scales. if annotations: x_val += +np.sin(el.angle) * factor * 2.3 y_val += -np.cos(el.angle) * factor * 2.3 self.one_fig.text( x_val, y_val, el.section_name, color=self.cs.structure_annotations, fontsize=settings.size, zorder=10 ) if supports and not free_body_diagram: # add supports self.__fixed_support_patch(max_plot_range * scale) self.__hinged_support_patch(max_plot_range * scale) self.__roll_support_patch(max_plot_range * scale) self.__rotating_spring_support_patch(max_plot_range * scale) self.__spring_support_patch(max_plot_range * scale) elif free_body_diagram: self.reaction_force(figsize, verbosity, scale, offset, show, free_body_diagram=free_body_diagram) if verbosity == 0: # add_loads self.__q_load_patch(max_plot_range, verbosity, free_body_diagram=free_body_diagram) self.__point_load_patch(max_plot_range, verbosity) self.__moment_load_patch(max_plot_range) if show: self.plot() else: return self.fig
def plot_structure(self, figsize, verbosity, show=False, supports=True, scale=1, offset=(0, 0), gridplot=False, annotations=True): """ :param show: (boolean) if True, plt.figure will plot. :param supports: (boolean) if True, supports are plotted. :param annotations: (boolean) if True, structure annotations are plotted. It includes section name. :return: """ if not gridplot: self.__start_plot(figsize) x, y = super().structure() max_x = np.max(x) min_x = np.min(x) max_y = np.max(y) min_y = np.min(y) center_x = (max_x - min_x) / 2 + min_x + -offset[0] center_y = (max_y - min_y) / 2 + min_x + -offset[1] max_plot_range = max(max_x, max_y) ax_range = max_plot_range * scale plusxrange = center_x + ax_range plusyrange = center_y + ax_range * figsize[1] / figsize[0] minxrange = center_x - ax_range minyrange = center_y - ax_range * figsize[1] / figsize[0] self.one_fig.axis([minxrange, plusxrange, minyrange, plusyrange]) for el in self.system.element_map.values(): x_val, y_val = plot_values_element(el) self.one_fig.plot(x_val, y_val, color='black', marker='s') if verbosity == 0: # add node ID to plot ax_range = max_plot_range * 0.015 self.one_fig.text(x_val[0] + ax_range, y_val[0] + ax_range, '%d' % el.node_id1, color='g', fontsize=9, zorder=10) self.one_fig.text(x_val[-1] + ax_range, y_val[-1] + ax_range, '%d' % el.node_id2, color='g', fontsize=9, zorder=10) # add element ID to plot factor = 0.02 * self.max_val_structure x_val = (x_val[0] + x_val[-1]) / 2 - np.sin(el.angle) * factor y_val = (y_val[0] + y_val[-1]) / 2 + np.cos(el.angle) * factor self.one_fig.text(x_val, y_val, str(el.id), color='r', fontsize=9, zorder=10) # add element annotation to plot # TODO: check how this holds with multiple structure scales. if annotations: x_val += + np.sin(el.angle) * factor * 2.3 y_val += - np.cos(el.angle) * factor * 2.3 self.one_fig.text(x_val, y_val, el.section_name, color='b', fontsize=9, zorder=10) # add supports if supports: self.__fixed_support_patch(max_plot_range * scale) self.__hinged_support_patch(max_plot_range * scale) self.__roll_support_patch(max_plot_range * scale) self.__rotating_spring_support_patch(max_plot_range * scale) self.__spring_support_patch(max_plot_range * scale) if verbosity == 0: # add_loads self.__q_load_patch(max_plot_range, verbosity) self.__point_load_patch(max_plot_range, verbosity) self.__moment_load_patch(max_plot_range) if show: self.plot() else: return self.fig