Esempio n. 1
0
def drawplot(filein, fileout, model, offtot=0, offBs=0, offRK=0):
    '''
	Draw the plot using shaded areas for the global fit and contour lines for Bs-only and RK-only fits
	'''
    fig = texfig.figure()

    trgtot, ztot = triang(readfile(filein, -1, 9, offtot))
    plt.tricontourf(trgtot,
                    ztot,
                    levels=[0.0, 1.0, 4.0, 9.0],
                    colors=('#00B400', '#00FF00', '#BFFF80'))
    trgBs, zBs = triang(readfile(filein, -2, 6, offBs))
    plt.tricontour(trgBs,
                   zBs,
                   levels=[1.0, 4.0],
                   colors='b',
                   linestyles=('-', '--'))
    trgRK, zRK = triang(readfile(filein, -3, 6, offRK))
    plt.tricontour(trgRK,
                   zRK,
                   levels=[1.0, 4.0],
                   colors='#800000',
                   linestyles=('-.', ':'))

    if model == 'LQ':
        plt.xlabel(r"$M_{S_3} [\mathrm{TeV}]$")
        plt.ylabel(r'$\mathrm{Im}\ y^{QL}_{32}y^{QL*}_{32}$')
    if model == 'Z':
        plt.xlabel(r"$M_{Z'} [\mathrm{TeV}]$")
        plt.ylabel(r'$\mathrm{Im}\ \lambda^Q_{23}$')
    texfig.savefig(fileout)
Esempio n. 2
0
def plot(fast_fit, x):
    '''
	Plots the allowed regions in the C9-C10 plane for imaginary Wilson coefficients
	'''
    import texfig
    import flavio.plots
    import matplotlib.pyplot as plt
    fig = texfig.figure()
    opt = dict(x_min=-2,
               x_max=2,
               y_min=-2,
               y_max=2,
               n_sigma=(1, 2),
               interpolation_factor=5)
    flavio.plots.likelihood_contour(fast_fit.log_likelihood,
                                    col=0,
                                    **opt,
                                    threads=2)
    #flavio.plots.flavio_branding(y=0.07, x=0.05) #crashes LaTeX
    plt.gca().set_aspect(1)
    plt.axhline(0, c='k', lw=0.2)
    plt.axvline(0, c='k', lw=0.2)
    plt.plot(x[0], x[1], marker='x')  #compute best fit first!
    plt.xlabel(r'$\mathrm{Im}\ C_9$')
    plt.ylabel(r'$\mathrm{Im}\ C_{10}$')
    texfig.savefig('fitIm_C9C10')
Esempio n. 3
0
def page_plot(p, f, pol, p_front=0):
    pphi = p
    phi = pphi * f

    plt.clf()
    fig = texfig.figure(width=1.5, ratio=1)
    ax = fig.add_subplot(111, aspect='equal')
    plot_particles(phi=phi, ax=ax, pol=pol)
    ax.axis('off')
    if pol == '+':
        prefix = 'plus_'
    else:
        prefix = 'cross_'
    texfig.savefig('flipbook_frames/' + prefix + str(p+1+p_front))
    plt.close(fig)
Esempio n. 4
0
def page_plot(p, f, pol, p_front=0):
    pphi = p
    phi = pphi * f

    plt.clf()
    fig = texfig.figure(width=1.5, ratio=1)
    ax = fig.add_subplot(111, aspect='equal')
    plot_particles(phi=phi, ax=ax, pol=pol)
    ax.axis('off')
    if pol == '+':
        prefix = 'plus_'
    else:
        prefix = 'cross_'
    texfig.savefig('flipbook_frames/' + prefix + str(p + 1 + p_front))
    plt.close(fig)
Esempio n. 5
0
def single_plot(files_prefix, bg_parameters, *args, **kwargs):
    plt.clf()
    fig = texfig.figure(width=tex_width)

    plot_parametric_evolution(files_prefix=files_prefix, *args, **kwargs)

    plt.xscale('log')
    plt.yscale('log')
    
    plt.xlabel(r'scale factor \(a\)')
    plt.ylabel(r'tensor perturbations \(|h|\)')
    
    handles, labels = plt.gca().get_legend_handles_labels()
    plt.legend(handles + [ bg_legend_handle ], labels + [ "for " + bg_parameters ], loc='lower left')
        
    texfig.savefig('plots/' + files_prefix)
z_21 = r * cos(phi_2[0])
x_12 = r * sin(phi_1) * cos(theta_1[1])
y_12 = r * sin(phi_1) * sin(theta_1[1])
z_12 = r * cos(phi_1)
x_22 = r * sin(phi_2[1]) * cos(theta_2)
y_22 = r * sin(phi_2[1]) * sin(theta_2)
z_22 = r * cos(phi_2[1])
xx_21 = r * sin(phi_2[0]) * cos(theta_22)
yy_21 = r * sin(phi_2[0]) * sin(theta_22)
zz_21 = r * cos(phi_2[0])
xx_22 = r * sin(phi_2[1]) * cos(theta_22)
yy_22 = r * sin(phi_2[1]) * sin(theta_22)
zz_22 = r * cos(phi_2[1])

#Ajustes da Imagem
fig = texfig.figure()
ax = fig.add_subplot(111, projection='3d')
ax.view_init(azim=-azim_init, elev=elev_init)  # vista da imagem
fig.set_size_inches(4, 4, 4)
cut = 0.65
ax.set_xlim([-r * cut, r * cut])
ax.set_ylim([-r * cut, r * cut])
ax.set_zlim([-r * cut, r * cut])

#Renderizar
ax.plot_surface(x,
                y,
                z,
                rstride=1,
                cstride=1,
                color='c',
Esempio n. 7
0
import obj_analysis_lib as oal

OUTPUTPATH = "/user/HS204/m09113/my_project_folder/Results/imageNet_performance"
SAVE4PRES = None
SAVE4LATEX = None

SAVE4LATEX = OUTPUTPATH
#SAVE4PRES =OUTPUTPATH

if SAVE4LATEX:
    import texfig
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

if SAVE4LATEX:
    fig = texfig.figure(width=5.8)  #entire page

if SAVE4PRES:
    #plt.rcParams["font.family"] ="monospace"
    plt.figure(figsize=(10, 5))

plt.rc('axes',
       prop_cycle=(cycler(
           'color',
           ['r', 'g', 'b', 'y', 'c', 'gold', 'm', 'k', 'slategray', 'peru'])))

years = ["2010", "2011", "2012", "2013", "2014", "Human", "2015", "2016"]

bar_width = 0.6
x_coordinates = np.arange(len(years))
y_coordinates = [28, 25.7, 16.4, 11.7, 7.4, 5.0, 3.6, 2.9]
from matplotlib.animation import FuncAnimation
from matplotlib.offsetbox import (DrawingArea, OffsetImage, AnnotationBbox)
import numpy as np
from gridworld import *
import texfig

# ---------- PART 1: Globals

with open('5agents_4range_async.json') as json_file:
    data = json.load(json_file)
df = pd.DataFrame(data)
my_dpi = 100
scale_factor = 0.33
# Writer = matplotlib.animation.writers['ffmpeg']
# writer = Writer(fps=2.5, metadata=dict(artist='Me'), bitrate=1800)
fig = texfig.figure(width=3.3 * scale_factor, ratio=2, dpi=my_dpi)
my_palette = plt.cm.get_cmap("tab10", len(df.index))
cat = [str(d_i) for d_i in df['0'][0]['Id_no']]
# categories = [cat[0],cat[3],cat[1],cat[4],cat[2]] # sync
categories = [cat[0], cat[3], cat[1], cat[2], cat[4]]  # async
belief_good = df['0'][0]['GoodBelief']
belief_bad = df['0'][0]['BadBelief']
N = len(categories)
categories = [categories[0], categories[2], categories[3]]
angles = [n / float(N) * 2 * pi for n in range(N)]
angles += angles[:1]
axis_array = []
l_data = []
f_data = []
belief_x_good = []
belief_x_bad = []
import numpy as np
from cycler import cycler
import glob
import obj_analysis_lib as oal

#SAVE="/user/HS204/m09113/my_project_folder/Results/alpha_deviations_KF-ITW_mix_of_expressions"
SAVE = "/user/HS204/m09113/my_project_folder/Results/alpha_deviations_KF-ITW_all_videos_thesis"
#SAVE=None

if SAVE:
    import texfig
import matplotlib.pyplot as plt

if SAVE:
    #fig = texfig.figure(width=8.268) #entire page
    fig = texfig.figure(width=5.8)

plt.rc('axes',
       prop_cycle=(cycler(
           'color',
           ['r', 'g', 'b', 'y', 'c', 'gold', 'm', 'k', 'slategray', 'peru'])))

#id_and_expression_dirs = glob.glob('/user/HS204/m09113/my_project_folder/KF-ITW-prerelease_alpha_experiments/*/expression_mix')
#id_and_expression_dirs = glob.glob('/user/HS204/m09113/my_project_folder/KF-ITW-prerelease_alpha_experiments/02/happy_only')
id_and_expression_dirs = glob.glob(
    '/user/HS204/m09113/my_project_folder/KF-ITW-prerelease_alpha_experiments/multi_iter75_reg30/*/*_only'
)
if len(id_and_expression_dirs) == 0:
    print("ERROR: no videos found!!")
    exit(0)
Esempio n. 10
0
# import texfig first to configure Matplotlib's backend
import texfig
# then, import PyPlot
import matplotlib.pyplot as plt

# obtain a nicely configured figure from texfig (or make your own)
fig = texfig.figure()
# plot as usual
plt.title(r'Title with $\vect{x}$')
plt.plot(range(10))
# save your plot as both a PDF and a PGF file with texfig (or save a '.pfg' file on your own)
texfig.savefig("example_plot")
# Now \usepackage{pgf} and \input the .pgf file in your LaTeX document. Admire the beauty of LaTeX vector plots.
#!/usr/bin/env python3.5
import sys, os
import numpy as np
from cycler import cycler
import glob
import obj_analysis_lib as oal

SAVE = "/user/HS204/m09113/my_project_folder/Results/alpha_deviations_KF-ITW_over_pose_prepared"
#SAVE=None

if SAVE:
    import texfig
import matplotlib.pyplot as plt

if SAVE:
    fig = texfig.figure(width=8.268)  #entire page
    fig = texfig.figure(width=4.8)  #entire page

plt.rc('axes',
       prop_cycle=(cycler(
           'color',
           ['r', 'g', 'b', 'y', 'c', 'gold', 'm', 'k', 'slategray', 'peru'])))
NUMBER_OF_ALPHAS_TO_PLOT = 10

#id_and_expression_dirs = glob.glob('/user/HS204/m09113/my_project_folder/KF-ITW-prerelease_alpha_experiments/*/expression_mix')
id_and_expression_dirs = glob.glob(
    '/user/HS204/m09113/my_project_folder/KF-ITW-prerelease_alpha_experiments/*/*_only'
)
if len(id_and_expression_dirs) == 0:
    print("ERROR: no videos found!!")
    exit(0)
Esempio n. 12
0
    handles, labels = plt.gca().get_legend_handles_labels()
    plt.legend(handles + [ bg_legend_handle ], labels + [ "for " + bg_parameters ], loc='lower left')
        
    texfig.savefig('plots/' + files_prefix)


single_plot(files_prefix="varying_aM", bg_parameters=r"$k=0.01$, $\cT=1$", plabel=r'\alphaM', LCDM_pvalue=0)
single_plot(files_prefix="varying_k", bg_parameters=r"$\alphaM=0$, $\cT=1$", plabel='k')
single_plot(files_prefix="varying_cT", bg_parameters=r"$k=0.01$, $\alphaM=0$", plabel=r'\cT', LCDM_pvalue=1)

single_plot(files_prefix="varying_beta", bg_parameters=r"$k=0.01$, $\alphaMnot=-1$, $\cT=1$", plabel=r'\betaexp')


# show growing modes and slope of the amplitude
plt.clf()
fig = texfig.figure(width=tex_width)

plots = plot_parametric_evolution(files_prefix="growing_aM", plabel=r'\alphaM', LCDM_pvalue=0)

def slope_analytic(a, alpha_M, h_0):
    return a**(-1 - alpha_M/2.) * h_0

a = np.logspace(-5, 0, 100)
plt.plot(a, slope_analytic(a, alpha_M=-2, h_0=10**-4.977515978085766), ls='dotted', c=plots[1][0].get_color())
plt.plot(a, slope_analytic(a, alpha_M=-3, h_0=10**0.02414219792993043), ls='dotted', c=plots[0][0].get_color())

plt.xscale('log')
plt.yscale('log')

plt.xlabel(r'scale factor \(a\)')
plt.ylabel(r'tensor perturbations \(|h|\)')
Esempio n. 13
0
def plot(fin, fout, x0=None):
    '''
	Read data from file and plot it in flavio-style
	'''
    f = open(fin, 'rt')
    _x = []
    _y = []
    for l in f.readlines():
        ls = l.split('\t')
        _x.append(float(ls[1]))
        _y.append(float(ls[2]))
    f.close()
    stepx = float('Inf')
    stepy = float('Inf')
    minx = min(_x)
    miny = min(_y)
    maxx = max(_x)
    maxy = max(_y)
    for i in range(0, len(_x)):
        if _x[i] != minx:
            stepx = min(stepx, _x[i] - minx)
    for i in range(0, len(_y)):
        if _y[i] != miny:
            stepy = min(stepy, _y[i] - miny)
    x, y = np.meshgrid(np.arange(minx, maxx, stepx),
                       np.arange(miny, maxy, stepy))
    shape1, shape2 = x.shape
    f = open(fin, 'rt')
    i = 0
    zbs = np.zeros(x.shape)
    zDMs = np.zeros(x.shape)
    zACP = np.zeros(x.shape)
    zglob = np.zeros(x.shape)
    for l in f.readlines():
        i1 = i % shape1
        i2 = i // shape1
        i += 1
        ls = l.split('\t')
        zbs[i1, i2] = float(ls[-4])
        zACP[i1, i2] = float(ls[-2])
        zDMs[i1, i2] = float(ls[-3])
        zglob[i1, i2] = float(ls[-1])
    f.close()
    zbs = zbs - np.min(zbs)
    zDMs = zDMs - np.min(zDMs)
    zACP = zACP - np.min(zACP)
    zglob = zglob - np.min(zglob)
    levels = [delta_chi2(n, dof=2) for n in (1, 2)]
    plotbs = {
        'x': x,
        'y': y,
        'z': zbs,
        'levels': levels,
        'interpolation_factor': 5,
        'col': 0,
        'label': r'$b \to s \mu^+ \mu^-$'
    }
    plotDMs = {
        'x': x,
        'y': y,
        'z': zDMs,
        'levels': levels,
        'interpolation_factor': 5,
        'col': 1,
        'label': r'$\Delta B_s$'
    }
    plotACP = {
        'x': x,
        'y': y,
        'z': zACP,
        'levels': levels,
        'interpolation_factor': 5,
        'col': 2,
        'label': r'$A_{CP}^{\mathrm{mix}}$'
    }
    plotglob = {
        'x': x,
        'y': y,
        'z': zglob,
        'levels': levels,
        'interpolation_factor': 5,
        'col': 3,
        'label': 'Global'
    }
    fig = texfig.figure()
    #fig = plt.figure()
    plt.xlim([-0.15, 0.15])
    plt.ylim([-0.15, 0.15])
    flavio.plots.contour(**plotbs)
    flavio.plots.contour(**plotDMs)
    flavio.plots.contour(**plotACP)
    flavio.plots.contour(**plotglob)
    plt.axhline(0, c='k', lw=0.2)
    plt.axvline(0, c='k', lw=0.2)
    if x0 is not None:
        plt.plot(x0[0], x0[1], marker='x', c='k')
    plt.xlabel(r'$\mathrm{Re}\ y^{QL}_{32} y^{QL*}_{22}$')
    plt.ylabel(r'$\mathrm{Im}\ y^{QL}_{32} y^{QL*}_{22}$')
    #plt.xlabel(r'$\mathrm{Re}\ \lambda^Q_{23}$')
    #plt.ylabel(r'$\mathrm{Im}\ \lambda^Q_{23}$')
    plt.legend(loc=2, bbox_to_anchor=(1.05, 1))
    texfig.savefig(fout)
Esempio n. 14
0
def errorplot(data, smdata, expdata, obslabels, leglabels, fout):
    '''
	Plots the model predictions as dots+errorbars, and SM predictions and experimental values as shaded rectangles
	'''
    fig = texfig.figure()
    nobs = len(obslabels)
    nhyp = len(leglabels)
    ax = plt.gca()
    plt.xlim([0, nobs + 0.7])
    #plt.ylim([-0.055, 0.015])
    markers = ['o', '^', 's', 'o', '^', 's']
    colors = ['b', 'b', 'b', 'r', 'r', 'r']
    for o in range(0, nobs):
        for i in range(0, nhyp):
            if o == 0:
                plt.plot(o + (i + 1) / (nhyp + 1),
                         data[o][i][0],
                         marker=markers[i],
                         color=colors[i],
                         label=leglabels[i])
            else:
                plt.plot(o + (i + 1) / (nhyp + 1),
                         data[o][i][0],
                         marker=markers[i],
                         color=colors[i])
            plt.errorbar(o + (i + 1) / (nhyp + 1),
                         data[o][i][0],
                         yerr=data[o][i][1],
                         color=colors[i])

        if o == 0:
            ax.add_patch(
                Rectangle((o, smdata[o][0] - smdata[o][1]),
                          1,
                          2 * smdata[o][1],
                          color='orange',
                          alpha=0.7,
                          label='SM'))
            ax.add_patch(
                Rectangle((o, expdata[o][0] - expdata[o][1]),
                          1,
                          2 * expdata[o][1],
                          color='green',
                          alpha=0.7,
                          label='Experimental'))
        else:
            ax.add_patch(
                Rectangle((o, expdata[o][0] - expdata[o][1]),
                          1,
                          2 * expdata[o][1],
                          color='green',
                          alpha=0.7))
            ax.add_patch(
                Rectangle((o, smdata[o][0] - smdata[o][1]),
                          1,
                          2 * smdata[o][1],
                          color='orange',
                          alpha=0.7))

    ax.set_xticks(np.linspace(0.5, nobs + 0.5, nobs + 1))
    ax.set_xticklabels(obslabels + [''])
    plt.legend()
    texfig.savefig(fout)
OUTPUTPATH = "/user/HS204/m09113/my_project_folder/Results/mesh_distances_KF-ITW_patrik_thesis"
#OUTPUTPATH="/user/HS204/m09113/my_project_folder/Results/mesh_distances_KF-ITW_iterations_thesis"
#OUTPUTPATH='mesh_distances_KF-ITW_fitting_types_BMVC'
SAVE4PRES = None
SAVE4LATEX = None

SAVE4LATEX = OUTPUTPATH
#SAVE4PRES =OUTPUTPATH

if SAVE4LATEX:
    import texfig
import matplotlib.pyplot as plt

if SAVE4LATEX:
    #fig = texfig.figure(width=8.268) #entire page
    fig = texfig.figure(width=4.8)  #philipp thesis 5.8

if SAVE4PRES:
    #plt.rcParams["font.family"] ="monospace"
    plt.figure(figsize=(10, 8 / 3 * 2))

# each curve has: label, marker, [log files]
#comparing every multifit
#distance_files = [ ['02 neutral','*',['/user/HS204/m09113/my_project_folder/KF-ITW-prerelease/02/neutral/distances.log']],
#				   ['02 surprised','o',['/user/HS204/m09113/my_project_folder/KF-ITW-prerelease/02/surprised/distances.log']],
#				   ['02 happy','+',['/user/HS204/m09113/my_project_folder/KF-ITW-prerelease/02/happy/distances.log']],
#				   ['08 neutral','*',['/user/HS204/m09113/my_project_folder/KF-ITW-prerelease/08/neutral/distances.log']],
#				   ['08 surprised','o',['/user/HS204/m09113/my_project_folder/KF-ITW-prerelease/08/surprised/distances.log']],
#				   ['11 neutral','*',['/user/HS204/m09113/my_project_folder/KF-ITW-prerelease/11/neutral/distances.log']],
#				   ['11 surprised','o',['/user/HS204/m09113/my_project_folder/KF-ITW-prerelease/11/surprised/distances.log']],
#				   ['11 happy','+',['/user/HS204/m09113/my_project_folder/KF-ITW-prerelease/11/happy/distances.log']],
Esempio n. 16
0
#else:
#f, axarr = plt.subplots(len(plots), sharex=True, squeeze=False)
#
#for plot_idx, plot in enumerate(plots):
#alphas = load_alphas( plot[1])
#x_coordinates = range(len(alphas))
#
#for num_alpha in range(len(alphas[0])):
#axarr[plot_idx,0].plot(x_coordinates, alphas[:,num_alpha])
#axarr[plot_idx,0].set_title(plot[0])
#axarr[plot_idx,0].set_ylim([-1.2,1])

##### Plot without subfigures:
if SAVE:
    #fig = texfig.figure(width=8.268) #entire page
    fig = texfig.figure(width=4.8)

alphas = load_alphas(plots[0][1])
x_coordinates = range(len(alphas))

for alpha_idx in range(len(alphas[0])):
    plt.plot(x_coordinates,
             alphas[:, alpha_idx],
             label="alpha " + str(alpha_idx + 1))
    #axarr[plot_idx,0].set_title(plot[0])
    #axarr[plot_idx,0].set_ylim([-1.2,1])

plt.xlabel("Iterations")
plt.ylabel("Coefficient value")
plt.ylim([-1.0, 0.6])
plt.xlim([0, 100])