pos_shifts_by_netw = {original_A.graph['name']: {'x': 0, 'y': 0}, original_B.graph['name']: {'x': area_size + area_size * dist_perc, 'y': 0}} print('times ' + str(times)) # debug # draw graphs for eachs step pdf_fpaths = [] for time in times: print('time ' + str(time)) # copypaste plt.figure(figsize=(15 + 1.6, 10)) plt.xlim(-margin, area_size * 2 + area_size * dist_perc + margin) plt.ylim(-margin, area_size + margin) A = nx.read_graphml(os.path.join(step_graphs_dir, str(time) + '_' + netw_a_fname)) sf.paint_netw_graph(A, original_A, {'power': 'r', 'generator': 'r', 'transmission_substation': 'plum', 'distribution_substation': 'magenta'}, 'r') B = nx.read_graphml(os.path.join(step_graphs_dir, str(time) + '_' + netw_b_fname)) sf.paint_netw_graph(B, original_B, {'communication': 'b', 'controller': 'c', 'relay': 'b'}, 'b', pos_shifts_by_netw[B.graph['name']]) I = nx.read_graphml(os.path.join(step_graphs_dir, str(time) + '_' + netw_inter_fname)) edge_col_per_type = {'power': 'r', 'generator': 'r', 'transmission_substation': 'plum', 'distribution_substation': 'magenta', 'communication': 'b', 'controller': 'c', 'relay': 'b'} # sf.paint_inter_graph(I, original_I, 'orange', pos_shifts_by_netw, edge_col_per_type) pdf_fpaths.append(os.path.join(step_graphs_dir, str(time) + '_full.pdf')) plt.savefig(pdf_fpaths[-1]) # get last element in list # plt.show() plt.close() # free memory
x_max = x elif x < x_min: x_min = x if y > y_max: y_max = y elif y < y_min: y_min = y span = max(x_max - x_min, y_max - y_min) # draw networks dist_perc = 0.16 plt.figure(figsize=(15 + 1.6, 10)) # map used to separate nodes of the 2 networks (e.g. draw A nodes on the left side and B nodes on the right) # pos_shifts_by_netw = {netw_a_name: {'x': 0, 'y': 0}, # netw_b_name: {'x': span + span * dist_perc, 'y': 0}} pos_shifts_by_netw = {netw_a_name: {'x': 0, 'y': 0}, netw_b_name: {'x': 0, 'y': 0}} edge_col_per_type = {'power': 'r', 'generator': 'r', 'transmission_substation': 'plum', 'distribution_substation': 'magenta', 'communication': 'b', 'controller': 'c', 'relay': 'b'} sf.paint_netw_graph(A, original_A, edge_col_per_type, 'r') sf.paint_netw_graph(B, original_B, edge_col_per_type, 'b', pos_shifts_by_netw[netw_b_name]) # sf.paint_inter_graph(I, I, 'orange', pos_shifts_by_netw, edge_col_per_type) plt.savefig(os.path.join(output_dir, '_finish.pdf')) # plt.show() plt.close() # free memory
y_min = y span = max(x_max - x_min, y_max - y_min) # draw networks dist_perc = 0.16 plt.figure(figsize=(15 + 1.6, 10)) # map used to separate nodes of the 2 networks (e.g. draw A nodes on the left side and B nodes on the right) # pos_shifts_by_netw = {netw_a_name: {'x': 0, 'y': 0}, # netw_b_name: {'x': span + span * dist_perc, 'y': 0}} pos_shifts_by_netw = {netw_a_name: {"x": 0, "y": 0}, netw_b_name: {"x": 0, "y": 0}} edge_col_per_type = { "power": "r", "generator": "r", "transmission_substation": "plum", "distribution_substation": "magenta", "communication": "b", "controller": "c", "relay": "b", } sf.paint_netw_graph(A, original_A, edge_col_per_type, "r") sf.paint_netw_graph(B, original_B, edge_col_per_type, "b", pos_shifts_by_netw[netw_b_name]) # sf.paint_inter_graph(I, I, 'orange', pos_shifts_by_netw, edge_col_per_type) plt.savefig(os.path.join(output_dir, "_finish.pdf")) # plt.show() plt.close() # free memory