Exemple #1
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')
Exemple #2
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)
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)
Exemple #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)
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)
Exemple #6
0
                       color='darkblue',
                       xy=(v * t_medio - 0.8, t_medio + 0.0),
                       size=fontsize)

# vdt
label = pylab.annotate(r"$v\Delta t$",
                       color='darkblue',
                       xy=(v * t_medio - 0.1, -0.45),
                       size=fontsize)

# cdt'
label = pylab.annotate(r"$c\Delta t^\prime$",
                       color='darkblue',
                       xy=(s0 + 0.1, t_medio * 0.8),
                       size=fontsize)

# # Legenda Luz 2
# x2, y2 = [s0+v*t_0, t_0]
# label = pylab.annotate(
#     r"$ t_0+dt$", color='darkblue',
#     xy=(x2, y2), xytext=(+70,+20), size=fontsize,
#     textcoords='offset points', ha='right', va='bottom',
#     arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0', color='darkblue')
# )

plt.axis('off')
ax.set_aspect('equal')
fig.set_size_inches(4, 4)
# plt.show()
texfig.savefig('Pitagoras', transparent=True)
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|\)')

handles, labels = plt.gca().get_legend_handles_labels()
slope_handle = plt.Line2D((0,1),(0,0), c='black', ls='dotted')
plt.legend(handles + [ slope_handle, bg_legend_handle ], labels + [ r"analytic slope $h(a) \propto a^{-\left(1+\frac{\alphaM}{2}\right)}$", "for  " + r"$k=0.01$, $\cT=1$" ], loc='lower left')

texfig.savefig('plots/growing_aM')


# varying both alphaM and beta

plt.clf()
fig, axes = texfig.subplots(width=tex_width, nrows=2, ncols=2, sharex=True, sharey=True)

for (i, row) in enumerate([["0", "0.1"], ["0.4", "1"]]):
    for (j, beta_str) in enumerate(row):
        ax = axes[i][j]
        plt.sca(ax)

        plot_parametric_evolution('varying_aM0_beta_' + beta_str, ur'\alphaMnot', LCDM_pvalue=0)

        ax.set_title(ur'$\beta=' + beta_str + '$')
Exemple #8
0
# #4 agents big range
# initial = [(33,0),(41,0),(7,0),(80,0)]
# targets = [[0,9],[60,69],[20,39],[69,95]]
# public_targets = [[0,9],[60,69],[20,39],[55,95]]
# obs_range = 4

time_i = 10
# con_dict = con_ar = con_init()
# bel_lines = belief_chart_init()
# belief_update(10)
# belief_update(20)
# belief_update(40)
ax_ar = grid_init(nrows, ncols, obs_range)
# grid_update(50)
# plt.show()
texfig.savefig("likelihood"+str(time_i))
# update()
# plt.show()
# ani = FuncAnimation(fig, update_all, frames=frames, interval=500, blit=True,repeat=False)
# plt.show()
# ani.save('8_agents-3range-wheel.mp4',writer = writer)
# ani.save('decen.gif',dpi=80,writer='imagemagick')


# fig = plt.figure(figsize=(4,4))
# ax = fig.add_subplot(111, projection='polar')
# ax.set_ylim(0,100)
#
# data = np.random.rand(50)*6+2
# theta = np.linspace(0,2.*np.pi, num=50)
# l,  = ax.plot([],[])
all_std_devs = np.array(all_std_devs)
#print ('all std shape',all_std_devs.shape)

# assemble x coordinates with correct number of image sets
x_coordinates = sorted(list(set(number_of_images_in_sets)))[:min_num_sets]

#print (x_coordinates)
for alpha_idx in range(5):
    y_coordinates = np.mean(all_std_devs[:, :, alpha_idx],
                            axis=0)  # [i[alpha_idx] for i in all_std_devs]
    y_deviation = np.std(all_std_devs[:, :, alpha_idx], axis=0)
    #plt.plot(x_coordinates, y_coordinates, label="alpha "+str(alpha_idx) , marker="s")
    plt.errorbar(x_coordinates,
                 y_coordinates,
                 y_deviation,
                 label="alpha " + str(alpha_idx),
                 marker="s")

plt.xlabel("Number of images")
plt.ylabel("Standard deviation of alphas")
#plt.ylim([0,1])
#plt.xlim([0,x_max])
plt.legend(loc=1)
#plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) #place to the right
plt.grid(True)

plt.show()

if SAVE:
    texfig.savefig(SAVE)
# Luz 2
tt_max = tt_max+v*dt_0
tt = np.linspace(0.0, tt_max, N)
t_0 = t_0 +dt_0
dist_0 = s0 + v*t_0
t_prime = np.linspace(t_0, tt_max+t_0, N)
li_1 = dist_0 - tt
ax.plot(li_1, t_prime, color='gold', zorder=0)


# Legenda Luz 2
x2, y2 = [s0+v*t_0, t_0]
label = pylab.annotate(
    r"$ t_0+dt$", color='darkblue',
    xy=(x2, y2), xytext=(+70,+20), size=fontsize,
    textcoords='offset points', ha='right', va='bottom',
    arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0', color='darkblue')
)

step_arrow = 0.05
plt.arrow(0, t_max, 0, step_arrow, shape='full', length_includes_head=True, head_width=.15, color='k', zorder=10)
plt.arrow(s0+v*t_max, t_max, v*step_arrow, 0.05, shape='full', length_includes_head=True, head_width=.15, color='k', zorder=10)

# ax.set(xlabel='x', ylabel='ct ',
#     title='About as simple as it gets, folks')
# ax.grid()
plt.axis('off')
ax.set_aspect('equal')
fig.set_size_inches(3, 3)
texfig.savefig('doppler', transparent=True)
Exemple #11
0
# #4 agents big range
# initial = [(33,0),(41,0),(7,0),(80,0)]
# targets = [[0,9],[60,69],[20,39],[69,95]]
# public_targets = [[0,9],[60,69],[20,39],[55,95]]
# obs_range = 4

time_i = 10
# con_dict = con_ar = con_init()
# bel_lines = belief_chart_init()
# belief_update(10)
# belief_update(20)
# belief_update(40)
ax_ar = grid_init(nrows, ncols, obs_range)
# grid_update(50)
# plt.show()
texfig.savefig("observation" + str(time_i))
# update()
# plt.show()
# ani = FuncAnimation(fig, update_all, frames=frames, interval=500, blit=True,repeat=False)
# plt.show()
# ani.save('8_agents-3range-wheel.mp4',writer = writer)
# ani.save('decen.gif',dpi=80,writer='imagemagick')

# fig = plt.figure(figsize=(4,4))
# ax = fig.add_subplot(111, projection='polar')
# ax.set_ylim(0,100)
#
# data = np.random.rand(50)*6+2
# theta = np.linspace(0,2.*np.pi, num=50)
# l,  = ax.plot([],[])
#
Exemple #12
0
step_arrow = 0.05
plt.arrow(0.3 * w,
          0.0,
          step_arrow,
          0.0,
          shape='full',
          length_includes_head=True,
          head_width=.45,
          color='gold',
          zorder=9,
          alpha=1.0)
plt.arrow(-0.3 * w,
          0.0,
          -step_arrow,
          0.0,
          shape='full',
          length_includes_head=True,
          head_width=.45,
          color='gold',
          zorder=9,
          alpha=1.0)

# ax.set(xlabel='x', ylabel='ct ',
#     title='About as simple as it gets, folks')
# ax.grid()
plt.axis('off')
ax.set_aspect('equal')
plt.tight_layout()
fig.set_size_inches(4, 2)
texfig.savefig('trem', transparent=True)
ax.text(A[0] + 0.1, A[1] - 0.15, r"$A$", color='darkblue', size=fontsize)  # A
ax.text(B[0] - 0.15, B[1] + 0.1, r"$B$", color='darkblue', size=fontsize)  # B
ax.text(0.5 * np.exp(t_max), 0.0, r"$x$", color='k', size=12)  # x
ax.text(0.0, 0.5 * np.exp(t_max), r"$y$", color='k', size=12)  # y
ax.text(0.5 * np.exp(t_max),
        0.5 * np.exp(t_max) * np.tanh(beta),
        r"$x^\prime$",
        color='k',
        size=12)  # x'
ax.text(0.5 * np.exp(t_max) * np.tanh(beta),
        0.5 * np.exp(t_max),
        r"$y^\prime$",
        color='k',
        size=12)  # y'
ax.text(0.5 * A[0] - 0.13,
        0.5 * A[1],
        r"$\beta$",
        color='darkblue',
        size=fontsize)  # Beta A
ax.text(0.5 * B[0],
        0.5 * B[1] - 0.13,
        r"$\beta$",
        color='darkblue',
        size=fontsize)  # Beta B

plt.axis('off')
ax.set_aspect('equal')
fig.set_size_inches(4, 4)
# plt.show()
texfig.savefig('Hiperbole', transparent=True)
    global con_dict, df
    change_array = []
    for id_no in categories:
        for id_other in categories:
            if int(id_other) in df[str(i)][id_no]['Visible']:
                if con_dict[(id_no, id_other)]._visible != True:
                    con_dict[(id_no, id_other)].set(visible=True, zorder=0)
                    change_array.append(con_dict[(id_no, id_other)])
            else:
                if con_dict[(id_no, id_other)]._visible == True:
                    con_dict[(id_no, id_other)].set(visible=False, zorder=0)
                    change_array.append(con_dict[(id_no, id_other)])
    return change_array


def coords(s, ncols):
    return (int(s / ncols), int(s % ncols))


# ---------- PART 2:

nrows = 10
ncols = 10
obs_range = 3
con_dict = con_ar = con_init()

t_i = 40
for s_i in range(0, t_i):
    update_all(s_i)
    texfig.savefig("images/Connections_a" + str(s_i))
        cat_range = range(N)
        value_dict = dict([[c_r, 0.0] for c_r in cat_range])
        for v_d in value_dict.keys():
            for k_i in values.keys():
                if literal_eval(k_i)[v_d] == 1:
                    value_dict[v_d] += 100 * values[k_i]

        val = list(value_dict.values())
        val += val[:1]
        l.set_data(angles, val)
        l_f.set_xy(np.array([angles, val]).T)
    # plot_data = [l_d,f_d]
    return l_d + f_d


def coords(s, ncols):
    return (int(s / ncols), int(s % ncols))


# ---------- PART 2:

nrows = 10
ncols = 10
obs_range = 3
update_all(1)
texfig.savefig("images/initial_belief")
# t_i = 40
# for s_i in range(1,50):
# 	update_all(s_i)
# 	texfig.savefig("images/Belief_simplex_async"+str(s_i))
Exemple #16
0
        size=fontsize)  # gamma til
t_leg = 1.02 * t_max
ax.text(t_leg, f1(t_leg) - 0.01, r"$x^a(u)$", color='darkblue',
        size=fontsize)  # x^a
ax.text(t_leg,
        f2(t_leg) - 0.01,
        r"$\tilde{x}^a(u)$",
        color='darkblue',
        size=fontsize)  # x^a til

# Xi
x2, y2 = [t0, f1(t0) + (t_medio - 0.05) * (f2(t0) - f1(t0))]
label = pylab.annotate(r"$ \xi^a(u) $",
                       color='darkblue',
                       xy=(x2, y2),
                       xytext=(60, 5.0),
                       size=fontsize,
                       textcoords='offset points',
                       ha='right',
                       va='bottom',
                       arrowprops=dict(arrowstyle='->',
                                       connectionstyle='arc3,rad=0',
                                       color='darkblue'))

plt.axis('off')
ax.set_aspect('equal')
fig.set_size_inches(4, 4)
plt.tight_layout()
texfig.savefig('DesvioGeodesico', transparent=True)
# plt.show()
light = (0.1+0.2*t)*w
ax.plot(light, 0*t, color='gold', lw=2)
ax.plot(-light, 0*t, color='gold', lw=2)

# setas
step_arrow = 0.05
plt.arrow(0.3*w, 0.0, step_arrow, 0.0, shape='full', length_includes_head=True, head_width=.45, color='gold', zorder=9, alpha=1.0)
plt.arrow(-0.3*w, 0.0, -step_arrow, 0.0, shape='full', length_includes_head=True, head_width=.45, color='gold', zorder=9, alpha=1.0)


# Velocidade
x2, y2 = [(0.3+0.1*t)*w, 0.65*h + 0*t]
ax.plot(x2, y2, color='darkblue', lw=2)
plt.arrow(0.42*w, 0.65*h, step_arrow, 0.0, shape='full', length_includes_head=True, head_width=.35, color='darkblue', zorder=9, alpha=1.0)
label = pylab.annotate(
    r"$\mathbf{v}$", color='darkblue',
    xy=(0.3*w, 0.65*h), xytext=(0.25*w,0.63*h), size=fontsize
)


# ax.set(xlabel='x', ylabel='ct ',
#     title='About as simple as it gets, folks')
# ax.grid()
plt.axis('off')
ax.set_aspect('equal')
plt.tight_layout()
fig.set_size_inches(4, 2)
# plt.show()
texfig.savefig('TremMovimento', transparent=True)
plt.plot(angulo[0],
         angulo[1],
         angulo[2],
         color="red",
         alpha=0.9,
         lw=1.2,
         zorder=5)

#Legenda Vetores
for i in range(0, 3):
    ax.text(P_0[0] + base[i][0] + 0.05,
            P_0[1] + base[i][1] - 0.04,
            P_0[2] + base[i][2] - 0.15,
            base_label[i],
            color='k',
            zorder=10,
            size=14)
ax.text(P_0[0] + 0.43 * (base[0][0] + 0.23 * base[2][0]),
        P_0[1] + 0.43 * (base[0][1] + 0.23 * base[2][1]),
        P_0[2] + 0.43 * (base[0][2] + 0.23 * base[2][2]),
        r'$\alpha$',
        color='r',
        zorder=10,
        alpha=0.7,
        size=14)

plt.tight_layout()
fig.set_size_inches(4, 4, 4)
plt.axis('off')
texfig.savefig('EsferaTransporteParalelo', transparent=True)
Exemple #19
0
# #4 agents big range
# initial = [(33,0),(41,0),(7,0),(80,0)]
# targets = [[0,9],[60,69],[20,39],[69,95]]
# public_targets = [[0,9],[60,69],[20,39],[55,95]]
# obs_range = 4

# con_dict = con_ar = con_init()
# bel_lines = belief_chart_init()
ax_ar = grid_init(nrows, ncols, obs_range)
# update_all(50)
# texfig.savefig("test")
# update()
# plt.show()
# ani = FuncAnimation(fig, update_all, frames=frames, interval=1000, blit=True,repeat=False)
# plt.show()
texfig.savefig("case_environment_5")
# ani.save('decen.gif',dpi=80,writer='imagemagick')

# fig = plt.figure(figsize=(4,4))
# ax = fig.add_subplot(111, projection='polar')
# ax.set_ylim(0,100)
#
# data = np.random.rand(50)*6+2
# theta = np.linspace(0,2.*np.pi, num=50)
# l,  = ax.plot([],[])
#
# def update(i):
#     global data
#     data += (np.random.rand(50)+np.cos(i*2.*np.pi/50.))*2
#     data[-1] = data[0]
#     l.set_data(theta, data )
Exemple #20
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)
obs_range = 3

# #4 agents big range
# initial = [(33,0),(41,0),(7,0),(80,0)]
# targets = [[0,9],[60,69],[20,39],[69,95]]
# public_targets = [[0,9],[60,69],[20,39],[55,95]]
# obs_range = 4

# con_dict = con_ar = con_init()'874' (140647750019760) = {dict} <class 'dict'>: {'BeliefCalls': 736, 'BadTrace': {'37': [85, 1], '43': [78, 0], '27': [76, 0], '11': [85, 0], '49': [76, 1], '20': [66, 1], '9': [85, 1], '26': [86, 0], '5': [67, 1], '31': [69, 0], '1': [78, 0], '25': [85, 0], '41': [76, 0], '33': [67, 1], '23': [85, 1], '2': [79, 0], '6': [66, 1], '4': [68, 1], '3': [69, 0], '24': [95, 1], '7': [76, 1], '21': [76, 1], '14': [77, 0], '13': [76, 0], '38': [95, 1], '29': [78, 0], '46': [68, 1], '34': [66, 1], '22': [75, 1], '19': [67, 1], '45': [69, 0], '15': [78, 0], '40': [86, 0], '16': [79, 0], '39': [85, 0], '47': [67, 1], '12': [86, 0], '10': [95, 1], '30': [79, 0], '8': [75, 1], '18': [68, 1], '17': [69, 0], '48': [66, 1], '35': [76, 1], '28': [77, 0], '0': [77, 0], '44': [79, 0], '32': [68, 1], '50': [75, 1], '42': [77, 0], '36': [75, 1]}, 'LastSeen': {'37': [[67, 0], 0], '874': [[77, 0], 0], '122': [[34, 0], 0], '684': [[33, 0], 50], '168': [[27, 0], 8]}, 'ActBelief': {'(0, 0, 1, 0, 0)': 0.0042983371692197755, '(1, 1, 1, 0, 1)': ...… View
time_i = 50
bel_lines = belief_chart_init()
for j in range(time_i+1):
	belief_update(j)
# ax_ar = grid_init(nrows, ncols, obs_range)
# update_all(50)
texfig.savefig("Call_results_"+str(time_i))
# update()
# plt.show()
# ani = FuncAnimation(fig, update_all, frames=frames, interval=500, blit=True,repeat=False)
# plt.show()
# ani.save('8_agents-3range-wheel.mp4',writer = writer)
# ani.save('decen.gif',dpi=80,writer='imagemagick')


# fig = plt.figure(figsize=(4,4))
# ax = fig.add_subplot(111, projection='polar')
# ax.set_ylim(0,100)
#
# data = np.random.rand(50)*6+2
# theta = np.linspace(0,2.*np.pi, num=50)
# l,  = ax.plot([],[])
Exemple #22
0
#plt.ylim([0,1])
x_coordinates = x_coordinates + bar_width / 2
plt.xlim([
    np.min(x_coordinates) - x_coordinates.shape[0] / (len(years)),
    np.max(x_coordinates) + x_coordinates.shape[0] / (len(years))
])
#plt.legend(loc=9, ncol=NUMBER_OF_ALPHAS_TO_PLOT, numpoints=1, handletextpad=0, columnspacing=0.5)
#plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) #place to the right
#plt.grid(True)

traditional_patch = mpatches.Patch(color=(242 / 255, 242 / 255, 242 / 255),
                                   label='Traditional')
deep_learning_patch = mpatches.Patch(color=(000 / 255, 70 / 255, 160 / 255),
                                     label='Deep Learning')
human_patch = mpatches.Patch(color=(201 / 255, 169 / 255, 000 / 255),
                             label='Human')
plt.legend(loc=1,
           handles=[traditional_patch, deep_learning_patch, human_patch])
#plt.title("Top-5 Error at ImageNet Classification Challenge")

plt.gca().yaxis.grid(True)
plt.gca().set_axisbelow(True)

if SAVE4PRES:
    plt.savefig(SAVE4PRES + ".png")

if SAVE4LATEX:
    texfig.savefig(SAVE4LATEX)

plt.show()
Exemple #23
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.
Exemple #24
0
ax.scatter(xx, yy, color='darkblue', s=20, zorder=5)  # pontos
ax.plot(xi_1, xi_2, color='darkblue', lw=1.5, zorder=0)  # vetor
step_arrow = 0.05

# seta vetor
plt.arrow(P[0] + (1 - step_arrow) * (x_1 - P[0]),
          P[1] + (1 - step_arrow) * (y_1 - P[1]), (x_1 - P[0]) * step_arrow,
          (y_1 - P[1]) * step_arrow,
          shape='full',
          length_includes_head=True,
          head_width=.15,
          color='darkblue',
          zorder=10)

# Legendas

ax.text(P[0] - 0.5, P[1] - 0.5, r"$P$", color='darkblue', size=fontsize)  # P
ax.text(O[0] + 0.1, O[1] - 0.1, r"$O$", color='darkblue', size=fontsize)  # O
G = [a * np.cos(0.7 * np.pi), b * np.sin(0.7 * np.pi)]
ax.text(G[0] - 0.5, G[1] + 0.3, r"$\gamma$", color='darkblue',
        size=fontsize)  # gamma
XI = [(0.5) * (O[0] + P[0]), (0.5) * (O[1] + P[1])]
ax.text(XI[0] - 0.3, XI[1] + 0.7, r"$\xi^a$", color='darkblue',
        size=fontsize)  # xi

plt.axis('off')
ax.set_aspect('equal')
fig.set_size_inches(4, 4)
# plt.show()
texfig.savefig('SmallLoop', transparent=True)
        values = df[str(i)][id_no]['ActBelief']
        cat_range = range(N)
        value_dict = dict([[c_r, 0.0] for c_r in cat_range])
        for v_d in value_dict.keys():
            for k_i in values.keys():
                if literal_eval(k_i)[v_d] == 1:
                    value_dict[v_d] += 100 * values[k_i]

        val = list(value_dict.values())
        val += val[:1]
        l.set_data(angles, val)
        l_f.set_xy(np.array([angles, val]).T)
    # plot_data = [l_d,f_d]
    return l_d + f_d


def coords(s, ncols):
    return (int(s / ncols), int(s % ncols))


# ---------- PART 2:

nrows = 10
ncols = 10
obs_range = 3

t_i = 40
for s_i in range(0, 1):
    update_all(s_i)
    texfig.savefig("images/Belief_simplex_sync_short" + str(s_i))
obs_range = 3

# #4 agents big range
# initial = [(33,0),(41,0),(7,0),(80,0)]
# targets = [[0,9],[60,69],[20,39],[69,95]]
# public_targets = [[0,9],[60,69],[20,39],[55,95]]
# obs_range = 4

# con_dict = con_ar = con_init()
time_i = 75
bel_lines = belief_chart_init()
for j in range(time_i + 1):
    belief_update(j)
# ax_ar = grid_init(nrows, ncols, obs_range)
# update_all(50)
texfig.savefig("Avg_thin_results_lv_" + str(time_i))
# update()
# plt.show()
# ani = FuncAnimation(fig, update_all, frames=frames, interval=500, blit=True,repeat=False)
# plt.show()
# ani.save('8_agents-3range-wheel.mp4',writer = writer)
# ani.save('decen.gif',dpi=80,writer='imagemagick')

# fig = plt.figure(figsize=(4,4))
# ax = fig.add_subplot(111, projection='polar')
# ax.set_ylim(0,100)
#
# data = np.random.rand(50)*6+2
# theta = np.linspace(0,2.*np.pi, num=50)
# l,  = ax.plot([],[])
#
                       ha='right',
                       va='bottom',
                       arrowprops=dict(arrowstyle='->',
                                       connectionstyle='arc3,rad=0',
                                       color='darkblue'))

# theta-menos
phi_leg = phi_0 - epsilon
theta_leg = 0.1 * pi
x_leg = r * sin(phi_leg) * cos(theta_leg)
y_leg = r * sin(phi_leg) * sin(theta_leg)
z_leg = r * cos(phi_leg)
x2, y2, _ = proj3d.proj_transform(x_leg, y_leg, z_leg, ax.get_proj())
label = pylab.annotate(r"$ \theta=\theta_0-\varepsilon$",
                       color='darkblue',
                       xy=(x2, y2),
                       xytext=(-5, +35),
                       size=fontsize,
                       textcoords='offset points',
                       ha='right',
                       va='bottom',
                       arrowprops=dict(arrowstyle='->',
                                       connectionstyle='arc3,rad=0',
                                       color='darkblue'))

# Plotar
plt.tight_layout()
fig.set_size_inches(4, 4, 4)
plt.axis('off')
texfig.savefig('EsferaLoop', transparent=True)
Exemple #28
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)