示例#1
0
def put_network(j_mat, pos):
    ax1a = fig.add_axes(pos)
    ax1a = plot_network(ax1a, -j_mat, 0.9, 1.2, spring=True)
示例#2
0
#ax2 = plt.subplot(gs[1, 0])
ax3 = plt.subplot(gs[:2, 1:4])
ax4 = plt.subplot(gs[2, :2])
ax5 = plt.subplot(gs[2, 2:4])
ax6 = plt.subplot(gs[0, 4])
ax7 = plt.subplot(gs[1, 4])

axbait = fig.add_axes([0.2, 0.48, 0.012, 0.01])
axbait.axis('off')

topo_ind = topo_list[0, cur_ind] - 1
j_mat = -rec_net[:, :, topo_ind]

ax1.set_aspect('equal')
ax1 = move_axis(ax1, -0.01, -0.1)
plot_network(ax1, j_mat, 2, 2)

# manual arrowhead width and length
hw = 0.15
hl = 0.2
lw = 2  # axis line width
ohg = 0.3  # arrow overhang
ax1.annotate(1, (0.4, 0.6))
ax1.annotate(2, (0, -1))
ax1.annotate(3, (-0.4, 0.1))
ax1.set_xlim([-1, 1.2])
ax1.set_ylim([-1, 1])
cur_dir = rec_bestdir[cur_ind, :] * 1.3
arr1 = ax1.arrow(1.4,
                 -cur_dir[0] / 2,
                 0,
示例#3
0
w_coords.writerow(writing)
wn_coords.writerow(writing)
writing = ['t (ms)']
for i in range(len(vertices)):
    writing.append("Fx" + str(i))
    writing.append("Fy" + str(i))
w_forces.writerow(writing)
wn_forces.writerow(writing)
writing = ['t (ms)']
for i in range(len(cells)):
    writing.append("A" + str(i))
w_areas.writerow(writing)
wn_areas.writerow(writing)

# Plot initial network
plot_network(vertices, links, cells, 0000, folder_basename)

# Writing of the initial network in CSV file
writing = [0]
writing_n = [0]
for i in range(len(vertices)):
    writing.append(csvfloat(vertices[i].coordx))
    writing.append(csvfloat(vertices[i].coordy))
    writing_n.append(float(vertices[i].coordx))
    writing_n.append(float(vertices[i].coordy))
w_coords.writerow(writing)
wn_coords.writerow(writing_n)
writing = [0]
for i in range(len(vertices)):
    writing.append(0)
    writing.append(0)
ax2 = plt.subplot(gs[:, 3])

ax11 = plt.subplot(gs[0, 0])
ax12 = plt.subplot(gs[0, 1])
ax13 = plt.subplot(gs[0, 2])
ax14 = plt.subplot(gs[1, 0])
ax15 = plt.subplot(gs[1, 1])
ax16 = plt.subplot(gs[1, 2])
ax17 = plt.subplot(gs[2, 1])

ax1_list = [ax11, ax12, ax13, ax14, ax15, ax16, ax17]
for ii, ax in enumerate(ax1_list):
    ax.set_aspect('equal')
    ax = move_axis(ax, -0.02, 0)
    j_mat = -rec_net[:, :, topo_list[0, ii] - 1]
    plot_network(ax, j_mat, 1.5, 1.5)
    ax.annotate(ii + 1, (-0.1, -0.1), fontsize=16)
    ax.set_xlim([-1, 1.2])
    ax.set_ylim([-1.1, 1.1])

ax2 = move_axis(ax2, 0.05, 0)
gp0 = np.asarray([0, 4])
gp1 = np.asarray([2, 6])
gp2 = np.asarray([1, 3, 5])
gp_list = [gp0, gp1, gp2]
ax2.semilogy([0, 1],
             rec_ctrinv[:, gp0],
             color='C0',
             linestyle='--',
             marker='o',
             markersize=10,
ax64.set_title('Ground truth')
ax61.set_title('No perturbation')
ax62.set_title('2 perturbations')
ax63.set_title('5 perturbations')

ax6c = fig.add_axes([0.95, 0.13, 0.01, 0.25])
cbar = fig.colorbar(im_ax6, cax=ax6c, ticks=[-3, 0, 3])
ax6c.set_ylabel('Interaction strength', position=[0.8, 0.62], labelpad=-4)

ax3c = fig.add_axes([0.95, 0.63, 0.01, 0.25])
cbar = fig.colorbar(im_ax3, cax=ax3c, ticks=[-1, 0, 1])
ax3c.set_ylabel('Correlation', position=[0.6, 0.5], labelpad=-5)

pos = np.load('pos16.npy', allow_pickle=True).item()
ax1, pos = plot_network(ax1, j_mat, 1, 1.3, pos=pos, labeldist=0.06)
ax1.set_ylim([-0.771, 1.09])
ax1.set_aspect('equal')

ax2.semilogy(np.diag(reald) * 6)
ax2.semilogy(rec_reald[:, 1] * 2, '--')
ax2.semilogy(rec_reald[:, 4], '-.')
ax2.set_yticks([1e-10, 1e-5, 1])
ax2.set_ylim([1e-12, 1e3])
ax2.set_xticks([0, 40, 80, 120])
ax2.set_xticklabels([120, 80, 40, 0])
ax2.set_xlabel('Eigenvalue index')
ax2.set_ylabel('Eigenvalues of $\mathcal{I}$')
ax2.yaxis.set_label_coords(-0.18, 0.52)

xx_cutoff = 2000
ax44.set_aspect('equal')

move_axis(ax44, -0.035, 0)
move_axis(ax42, -0.03, 0)

mdata = sio.loadmat("fig1_data_two_spinn")
locals().update(mdata)
xxm = -xxm
yym = -yym
j_mat = -j_mat.astype(np.float32)
h_pert = -h_pert

ax11 = fig.add_axes([0.15, 0.56, 0.08, 0.2])
# ax11 = fig.add_axes([0.24, 0.77, 0.08, 0.2])
ax11.set_aspect('equal')
ax11, pos = plot_network(ax11, j_mat, 1, 3)
ax11.set_ylim([-0.6, 0.6])
ax11.set_xlim([-1.4, 1.4])
cors = np.array(list(pos.values()))
sca = 4
#ax11.quiver(cors[:, 0] - 0.24, cors[:, 1] - h_pert[:, 0] / sca,
qv11 = ax11.quiver(cors[:, 0],
                   cors[:, 1] - h_pert[:, 0] / sca,
                   0,
                   h_pert[:, 0],
                   scale=sca,
                   color='k',
                   edgecolor='k',
                   width=0.02)
ax11.text(-0.85, -0.95, r'$h = h^*$', fontsize=14)
qv11.set_zorder(10)