def mpl_thumbnails(usetex=False): """ Make png thumbnails """ plt.rcdefaults() plt.rc('font', family='serif') plt.rc('xtick', labelsize='x-small') plt.rc('ytick', labelsize='x-small') plt.rc('text', usetex=usetex) plt.rc('savefig', format='pdf', bbox='tight') plt.rc('savefig', format='png', bbox='tight') plt.rc('figure', figsize=(4,3))
def mpl_thumbnails(usetex=False): """ Make png thumbnails """ plt.rcdefaults() plt.rc('font', family='serif') plt.rc('xtick', labelsize='x-small') plt.rc('ytick', labelsize='x-small') plt.rc('text', usetex=usetex) plt.rc('savefig', format='pdf', bbox='tight') plt.rc('savefig', format='png', bbox='tight') plt.rc('figure', figsize=(4, 3))
def mpl_span_columns(usetex=False): """ Set matplotlib to make pretty plots for publishing a full-page figure """ plt.rcdefaults() plt.rc('font', family='serif', size=12.0, style='normal') plt.rc('figure', figsize=(7, 5.25)) plt.rc('axes', titlesize=12, labelsize=10) plt.rc('legend', fontsize=8, numpoints=1, scatterpoints=1) plt.rc('xtick', labelsize='x-small') plt.rc('ytick', labelsize='x-small') plt.rc('text', usetex=usetex) plt.rc('savefig', format='pdf', bbox='tight')
def mpl_slides(usetex=False): """ Set matplotlibrc to make pretty slides """ plt.rcdefaults() plt.rc('font', family='serif', size=24) # The default PowerPoint page setup plt.rc('figure', figsize=(7,5.5)) plt.rc('axes', titlesize=24, labelsize=20, linewidth=3) plt.rc('legend', fontsize=18, numpoints=1, scatterpoints=1) plt.rc('xtick', labelsize='small') plt.rc('ytick', labelsize='small') plt.rc('text', usetex=usetex) plt.rc('lines', linewidth=5) plt.rc('savefig', format='pdf', bbox='tight')
def mpl_slides(usetex=False): """ Set matplotlibrc to make pretty slides """ plt.rcdefaults() plt.rc('font', family='serif', size=24) # The default PowerPoint page setup plt.rc('figure', figsize=(7, 5.5)) plt.rc('axes', titlesize=24, labelsize=20, linewidth=3) plt.rc('legend', fontsize=18, numpoints=1, scatterpoints=1) plt.rc('xtick', labelsize='small') plt.rc('ytick', labelsize='small') plt.rc('text', usetex=usetex) plt.rc('lines', linewidth=5) plt.rc('savefig', format='pdf', bbox='tight')
import numpy as np from glob import glob from matplotlib import pylab as plt plt.rcdefaults() from baselines.bench import load_results def plot(experiment_path, save_dir="/tmp/", save_name="results", limit_steps=None): fig = plt.figure(figsize=(20, 10)) if len(glob(os.path.join(experiment_path, "train/*monitor*"))) != 0: exps = glob(experiment_path) print(exps) # Get data df = load_results(os.path.join(experiment_path, "train")) roll = 5 rdf = df.rolling(5) df['steps'] = df['l'].cumsum() / 1000000 # Plots ax = plt.subplot(1, 1, 1) df.rolling(roll).mean().plot('steps', 'r', style='-', ax=ax,
def hor_hist(): import matplotlib.pylab as plt import numpy as np from matplotlib import rc import sys plt.rcdefaults() fig, ax = plt.subplots() f = open("{}".format(sys.argv[1]), "r") ft = f.readlines() f.close() if len(ft) == 0: print("ERROR IN THE INPUT FILE {}".format(sys.argv[1])) quit() ft1 = ft[0].split() print(ft1) print("ENTER THE COLUMN FOR X AXIS") xcol = input() xcol = xcol - 1 xtest = "{}".format(ft1[int(xcol)]).isdigit() if xtest != "True": cc = "x" print("ENTER THE COLUMN FOR Y AXIS") ycol = input() ycol = ycol - 1 ytest = "{}".format(ft1[int(ycol)]).isdigit() if ytest != "True": cc = "y" if "{}".format(xtest) != "True" and "{}".format(ytest) != "True": print("ERROR: BOTH COLUMNS ARE CHARACTER TYPES") quit() print(cc) k = 0 x = [] y = [] xlabel = [] ylabel = [] while k < len(ft): ft1 = ft[k].split() t1 = ft1[int(xcol)] t2 = ft1[int(ycol)] if cc == "x": xlabel.append(t1) x.append((k + 1)) y.append(int(t2)) if cc == "y": x.append(int(t1)) ylabel.append(t2) y.append((k + 1)) k = k + 1 ax.barh(y, x, align='center') if cc == "x": ax.set_xticks(x) ax.set_xticklabels(xlabel) if cc == "y": ax.set_yticks(y) ax.set_yticklabels(ylabel, fontweight='bold') ax.set_xlabel('MUTANTS', fontweight='bold') rc('font', weight='bold') ax.set_title('Distribution of mutants across the taxonomy', fontweight='bold') plt.show()
# 显示colorbar cbar = fig.colorbar(surf, ax=ax,shrink=0.5, aspect=10, spacing = 'uniform') # cbar.set_label('微伏',fontproperties = ChineseFont2,fontsize = 30) cbar.set_ticks(np.arange(-150,200,50)) cbar.ax.tick_params(labelsize=20) cbar.set_ticklabels(tuple([str(ticklabels) for ticklabels in np.arange(-150,200,50)])) plt.show() # save filename_fig = file_path + '_' + title + '_' + ConditionName[i] + '.jpg' savefig(filename_fig) #%% pylab.rcdefaults() params={'axes.titlesize': 50, 'axes.labelsize': 40, 'axes.grid' : 'True', 'axes.prop_cycle': cycler('color',['cyan', 'indigo', 'seagreen', 'yellow', 'blue','navy','turquoise', 'darkorange', 'cornflowerblue', 'teal']), 'xtick.labelsize':20, 'ytick.labelsize':20, 'lines.linewidth' :4, 'lines.markersize':15, 'legend.fontsize':30,
import numpy as np from glob import glob from matplotlib import pylab as plt; plt.rcdefaults() from baselines.bench import load_results def plot(experiment_path, save_dir="/tmp/", save_name="results", limit_steps=None): fig = plt.figure(figsize=(20, 10)) if len(glob(os.path.join(experiment_path, "train/*monitor*"))) != 0: exps = glob(experiment_path) print(exps) # Get data df = load_results(os.path.join(experiment_path, "train")) roll = 5 rdf = df.rolling(roll) df['steps'] = df['l'].cumsum() if 'rrr' in df: df = df[df['lives'] == 0] df['r'] = df['rrr'] ax = plt.subplot(1, 1, 1) df.rolling(roll).mean().plot('steps', 'r', style='-', ax=ax, legend=False) rdf.max().plot('steps', 'r', style='-', ax=ax, legend=False, color="#28B463", alpha=0.65) rdf.min().plot('steps', 'r', style='-', ax=ax, legend=False, color="#F39C12", alpha=0.65) # X axis gap = 1
data = get_data(test) tree = get_tree(test) bench(test,data) save_data(test,data) datestr = time.strftime("%Y-%m-%d-%H-%M-%S") pickle.dump(results,file('bench-results-%s.pickle' % (datestr),'w')) pickle.dump(results,file('bench-results.pickle','w')) else: results = pickle.load(file('bench-results.pickle','r')) mat = scipy.io.loadmat('bench-tree.mat')['R'][0] # matlab indices are: [dim,depth,func] fgcolor = np.array([20,50,100])/255. bgcolor = 0.9 + 0.1*fgcolor plt.rcdefaults() plt.rcParams['figure.subplot.right']='0.9' plt.rcParams['figure.subplot.left']='0.2' plt.rcParams['figure.subplot.top']='0.8' plt.rcParams['ytick.major.pad']='10' plt.rcParams['ytick.color']=fgcolor plt.rcParams['xtick.color']=fgcolor plt.rcParams['ytick.major.size']=4 plt.rcParams['xtick.major.size']=4 plt.rc('lines', linewidth=2) plt.rc('text', color=fgcolor) plt.rc('axes', linewidth=2, facecolor=bgcolor, edgecolor=fgcolor, labelcolor=fgcolor) plt.show() plotfuncs = [1,3] labels = ['Insert','Search']