def test_save_and_show_figure(): fig = plt.figure() plt.imshow(np.random.randn(10, 10)) plt.title('Test Figure') path = get_artemis_data_path('tests/test_fig.pdf') save_figure(fig, path=path) show_saved_figure(path)
def save_current_figure(path=""): fig = plt.gcf() file_name = format_filename(file_string = '%T', current_time = datetime.now()) if path != "": save_path = os.path.join(path,"%s.pdf"%file_name) else: save_path = get_artemis_data_path('output/{file_name}.png'.format(file_name=file_name)) save_figure(fig,path=save_path)
def save_current_figure(): print("Attempting to save figure") fig = plt.gcf() file_name = format_filename(file_string='%T', current_time=datetime.now()) save_path = get_local_path( 'output/{file_name}.pdf'.format(file_name=file_name)) print("Current figure saved to {}".format(save_path)) save_figure(fig, path=save_path)
def save_figure_in_record(name, fig=None, default_ext='.pkl'): ''' Saves the given figure in the experiment directory. If no figure is passed, plt.gcf() is saved instead. :param name: The name of the figure to be saved :param fig: The figure to be saved, can be None :param default_ext: See artemis.plotting.saving_plots.save_figure() for information :return: The path to the figure ''' import matplotlib.pyplot as plt from artemis.plotting.saving_plots import save_figure if fig is None: fig = plt.gcf() save_path = os.path.join(get_current_record_dir(), name) save_figure(fig, path=save_path, default_ext=default_ext) return save_path
def test_save_and_show_figure_3(): fig = plt.figure() plt.imshow(np.random.randn(10, 10)) plt.title('Test Figure') path = get_local_path('tests/test_fig.with.strangely.formatted.ending') path = save_figure(fig, path=path, ext='pdf') show_saved_figure(path)
def test_save_and_show_figure_2(): fig = plt.figure() plt.imshow(np.random.randn(10, 10)) plt.title('Test Figure') path = get_local_path('tests/test_fig') path = save_figure(fig, path=path) show_saved_figure(path)