def draw_geometry( geometry,jobname,format='pdf', display=True, block_when_showing=True, anisotropic_component=0): """#FIXME: needs to be adapted to work with anisotropic material Draw and save the geometry. Save as file jobname+.+format. Only show figure if display=True (default). When showing, block script if block_when_showing=True (default). In case of anisotropic material, only draw anisotropic_component (default 0). """ global maxeps # I commented clf(), because it just opens an unnecessary new empty # figure window, the same that figure() does below. #plt.clf() maxeps = max_epsilon(geometry, anisotropic_component) drawing_dict = {objects.Rod : draw_rod} fig = plt.figure(figsize=fig_size) ax = fig.add_subplot(111,aspect='equal') X = geometry.width/2 Y = geometry.height/2 ax.set_xlim(-X,X) ax.set_ylim(-Y,Y) graphic_objs = ( [drawing_dict[obj.__class__](index, obj, anisotropic_component) for index,obj in enumerate(geometry.objects)]) for graph in graphic_objs: for elem in graph: ax.add_artist(elem) plt.savefig(jobname+'.'+format,format=format,transparent=True) if display: plt.show(block=block_when_showing) else: plt.close(fig)
def draw_geometry(geometry, jobname, format="pdf"): global maxeps clf() maxeps = max_epsilon(geometry) drawing_dict = {objects.Rod: draw_rod} fig = figure(figsize=fig_size) ax = fig.add_subplot(111, aspect="equal") X = geometry.width / 2 Y = geometry.height / 2 ax.set_xlim(-X, X) ax.set_ylim(-Y, Y) graphic_objs = [drawing_dict[obj.__class__](index, obj) for index, obj in enumerate(geometry.objects)] for graph in graphic_objs: for elem in graph: ax.add_artist(elem) show() savefig(jobname + "." + format, format=format, transparent=True)
def draw_geometry(geometry, jobname, format='pdf', display=True, block_when_showing=True, anisotropic_component=0): """#FIXME: needs to be adapted to work with anisotropic material Draw and save the geometry. Save as file jobname+.+format. Only show figure if display=True (default). When showing, block script if block_when_showing=True (default). In case of anisotropic material, only draw anisotropic_component (default 0). """ global maxeps # I commented clf(), because it just opens an unnecessary new empty # figure window, the same that figure() does below. #plt.clf() maxeps = max_epsilon(geometry, anisotropic_component) drawing_dict = {objects.Rod: draw_rod} fig = plt.figure(figsize=fig_size) ax = fig.add_subplot(111, aspect='equal') X = geometry.width / 2 Y = geometry.height / 2 ax.set_xlim(-X, X) ax.set_ylim(-Y, Y) graphic_objs = ([ drawing_dict[obj.__class__](index, obj, anisotropic_component) for index, obj in enumerate(geometry.objects) ]) for graph in graphic_objs: for elem in graph: ax.add_artist(elem) plt.savefig(jobname + '.' + format, format=format, transparent=True) if display: plt.show(block=block_when_showing) else: plt.close(fig)