def plot_results(self, results, agent, obs_name, thresh=50): plt.figure() plt.ion() max_val_lim = max( max((numpy.max(results[0][1][obs_name]) + 0.25 * numpy.max(results[0][1][obs_name])), 101.0), thresh) max_time = max([result[0][-1] for result in results]) lr = matplotlib.patches.Rectangle((0, 0), max_time, thresh, color='red', alpha=0.1) hr = matplotlib.patches.Rectangle((0, thresh), max_time, max_val_lim - thresh, color='green', alpha=0.1) ax = plt.gca() ax.add_patch(lr) ax.add_patch(hr) if thresh + 0.05 * max_val_lim < max_val_lim: plt.text(10, thresh + 0.05 * max_val_lim, 'High', fontsize=10) plt.text(10, thresh - 0.05 * max_val_lim, 'Low') for tspan, yobs in results: plt.plot(tspan, yobs[obs_name]) plt.ylim(-5, max_val_lim) plt.xlim(-100, 10100) plt.xlabel('Time (s)') plt.ylabel('Amount (molecules)') agent_str = english_assembler._assemble_agent_str(agent).agent_str plt.title('Simulation results for %s' % agent_str) fig_path = get_img_path(obs_name + '.png') plt.savefig(fig_path) return fig_path
def plot_results(self, results, agent, obs_name, thresh=50): plt.figure() plt.ion() max_val_lim = max(max(numpy.max(results[0][1][obs_name]), 101.0), thresh) max_time = max([result[0][-1] for result in results]) lr = matplotlib.patches.Rectangle((0, 0), max_time, thresh, color='red', alpha=0.1) hr = matplotlib.patches.Rectangle((0, thresh), max_time, max_val_lim-thresh, color='green', alpha=0.1) ax = plt.gca() ax.add_patch(lr) ax.add_patch(hr) if thresh + 5 < max_val_lim: plt.text(10, thresh + 5, 'High', fontsize=10) plt.text(10, thresh - 5, 'Low') for tspan, yobs in results: plt.plot(tspan, yobs[obs_name]) plt.ylim(-1, max_val_lim) plt.xlim(-100, 10100) plt.xlabel('Time (s)') plt.ylabel('Amount (molecules)') agent_str = english_assembler._assemble_agent_str(agent) plt.title('Simulation results for %s' % agent_str) fig_path = get_img_path(obs_name + '.png') plt.savefig(fig_path) return fig_path
def report_paths_graph(self, paths_list): from indra.assemblers.graph import GraphAssembler from indra.util import flatten path_stmts = [stmts_from_json(l) for l in paths_list] all_stmts = flatten(path_stmts) ga = GraphAssembler(all_stmts) ga.make_model() resource = get_img_path('qca_paths.png') ga.save_pdf(resource) content = KQMLList('display-image') content.set('type', 'simulation') content.sets('path', resource) self.tell(content)
def plot_compare_conditions(self, ts, results, agent, obs_name): plt.figure() plt.ion() plt.plot(ts, results[0][:len(ts)], label='Without condition') plt.plot(ts, results[-1][:len(ts)], label='With condition') plt.xlabel('Time (s)') plt.ylabel('Amount (molecules)') agent_str = english_assembler._assemble_agent_str(agent).agent_str plt.title('Simulation results for %s' % agent_str) plt.legend() fig_path = get_img_path(obs_name + '.png') plt.savefig(fig_path) return fig_path
def plot_compare_conditions(self, ts, results, agent, obs_name): plt.figure() plt.ion() plt.plot(ts, results[0][:len(ts)], label='Without condition') plt.plot(ts, results[-1][:len(ts)], label='With condition') plt.xlabel('Time (s)') plt.ylabel('Amount (molecules)') agent_str = english_assembler._assemble_agent_str(agent) plt.title('Simulation results for %s' % agent_str) plt.legend() fig_path = get_img_path(obs_name + '.png') plt.savefig(fig_path) return fig_path
def make_pic_name(model_id, token): """Create a standardized picture name.""" s = 'model%d_%s' % (model_id, token) return get_img_path(s)