def save_data_frame(df, save_dir, name=None, timestamp=False): ensure_dir_exists(save_dir) timestamp_str = ("_" + now_as_string()) if timestamp else "" name = name if name else "" fileName = "{}{}.csv".format(name, timestamp_str) df = df.sort_index(axis=1) df.to_csv(os.path.join(save_dir, fileName))
import os import matplotlib import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sb import results from files import ensure_dir_exists # CAMERA_READY_FONT = 'Calibri' CAMERA_READY_FONT = 'DejaVu Sans' SAVE_DIR = os.path.expanduser('~/Desktop/bolt/figs/') ensure_dir_exists(SAVE_DIR) def save_fig(name): plt.savefig(os.path.join(SAVE_DIR, name + '.pdf'), bbox_inches='tight') def save_fig_png(name): plt.savefig(os.path.join(SAVE_DIR, name + '.png'), dpi=300, bbox_inches='tight') def set_palette(ncolors=8): # use this to change color palette in all plots pal = sb.color_palette("Set1", n_colors=ncolors) sb.set_palette(pal)