Exemple #1
0
def plot_eig(ax, eigw, eigv):
    ax = move_axis(ax, 0, -0.12)
    ax = large_axis(ax)
    ax.set_aspect('equal')
    cax = ax.imshow(eigv, cmap='bwr', vmin=-1, vmax=1)
    ax.set_xticks([0, 1, 2])
    ax.set_xticklabels(np.round(eigw, 2))
    ax.set_xticks(np.arange(3) - 0.5, minor=True)
    ax.set_yticks(np.arange(3) - 0.5, minor=True)
    ax.grid(which='minor', color='w', linestyle='-', linewidth=3)
    ax.set_ylabel('Edge index')
    ax.set_yticklabels([1, 1, 2, 3])
    return cax
Exemple #2
0
fig = plt.figure(figsize=[figw, figh])
gs = gridspec.GridSpec(1,
                       4,
                       width_ratios=[0.6, 0.6, 1, 1],
                       left=0.08,
                       right=0.92,
                       top=0.92,
                       bottom=0.15,
                       wspace=0.3)

ax0 = plt.subplot(gs[0])
ax1 = plt.subplot(gs[1])
ax2 = plt.subplot(gs[2])
ax3 = plt.subplot(gs[3])

move_axis(ax0, 0, -0.1)
move_axis(ax1, -0.035, -0.1)
move_axis(ax2, -0.015, 0)

ax0.set_aspect('equal')
jlim = np.max(j_mat)
im0 = ax0.imshow(j_mat, cmap='bwr', clim=[-jlim, jlim])

ax1.set_aspect('equal')
im1 = ax1.imshow(np.mean(rec_estij, axis=2), cmap='bwr', clim=[-jlim, jlim])
ax1.set_yticks([])
node_ind = np.array([4, 9, 14])
node_tick = node_ind + 1
ax0.set_xticks(node_ind)
ax0.set_xticklabels(node_tick)
ax1.set_xticks(node_ind)
Exemple #3
0
num_spin = np.squeeze(num_spin)
num_j = np.squeeze(num_j)
num_data = np.squeeze(num_data)
num_round = np.squeeze(num_round)

figw = 11.4 / 2.54 * 2
figh = figw
fig = plt.figure(figsize=[figw, figh])
gs = gridspec.GridSpec(2, 2, width_ratios=[1, 1], height_ratios=[1, 1])

ax1 = plt.subplot(gs[0])
ax2 = plt.subplot(gs[1])
ax3 = plt.subplot(gs[2])
ax4 = plt.subplot(gs[3])

ax1 = move_axis(ax1, -0.02, 0)
ax2 = move_axis(ax2, 0, 0.03)
ax3 = move_axis(ax3, -0.02, 0)

ax1.set_axis_off()


def put_network(j_mat, pos):
    ax1a = fig.add_axes(pos)
    ax1a = plot_network(ax1a, -j_mat, 0.9, 1.2, spring=True)


net_sz = 0.18
net_sz2 = net_sz * figw / figh
pos_st = 0.07
pos_hi = 0.53
Exemple #4
0
ax1 = plt.subplot(gs[0, 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,
                       height_ratios=[1, 1, 1])  #, hspace=0.4, wspace=0.5)

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='--',
                        left=leftpos,
                        right=rightpos,
                        top=ax2pos.y1,
                        bottom=ax2pos.y0,
                        wspace=0.23,
                        hspace=0.05)
ax31 = plt.subplot(gs1[0])
process_axis(ax31)
ax32 = plt.subplot(gs1[1])
process_axis(ax32)
ax33 = plt.subplot(gs1[2])
process_axis(ax33)
ax34 = plt.subplot(gs1[3])
process_axis(ax34)

move_axis(ax1, -0.02, 0.02)

move_axis(ax31, 0, 0.02)
move_axis(ax32, 0, 0.02)
move_axis(ax33, 0, -0.01)

move_axis(ax63, 0, -0.03)
move_axis(ax64, 0, -0.03)

im_ax3 = ax31.imshow(rec_all_corr[:, :, 0], cmap='PiYG_r', clim=[-1, 1])
ax32.imshow(np.mean(rec_all_corr[:, :, :3], axis=2),
            cmap='PiYG_r',
            clim=[-1, 1])
ax33.imshow(np.mean(rec_all_corr[:, :, :6], axis=2),
            cmap='PiYG_r',
            clim=[-1, 1])
mdata = sio.loadmat('fish_with_sznn')
locals().update(mdata)
rec_ftrinv = rec_ftrinv * np.arange(1, 7)


figw = 17.8 / 2.54 * 2
figh = 17.8 / 2.54 * 13 / 40 * 2
fig = plt.figure(figsize=[figw, figh])
gs = gridspec.GridSpec(1, 3, width_ratios=[1, 1, 1], wspace=0.35, 
                       left=0.08, right=0.94)

ax1 = plt.subplot(gs[0])
ax3 = plt.subplot(gs[1])
ax2 = plt.subplot(gs[2])
ax2 = move_axis(ax2, 0.022, 0)

net_sz = np.array([8, 12, 16])
lin0 = ax1.plot(net_sz, np.log10(rec_ftrinv[:, :, 0]), color='C3', linestyle='none', 
         marker='o', label='No perturbations')
ax1.plot(net_sz, np.mean(np.log10(rec_ftrinv[:, :, 0]), axis=1), color='C3')
lin1 = ax1.plot(net_sz, np.log10(rec_ftrinv[:, :, 2]), color='C4', linestyle='none', 
         marker='X', label='2 perturbations')
ax1.plot(net_sz, np.mean(np.log10(rec_ftrinv[:, :, 2]), axis=1), color='C4')
lin2 = ax1.plot(net_sz, np.log10(rec_ftrinv[:, :, 5]), color='C5', linestyle='none', 
         marker='P', label='5 perturbations')
ax1.plot(net_sz, np.mean(np.log10(rec_ftrinv[:, :, 5]), axis=1), color='C5')
ax1.set_xticks([8, 12, 16])
ax1.set_xlabel('Network size')
ax1.set_yticks([2, 6, 10])
ax1.set_yticklabels(['1e2', '1e6', '1e10'])
ax43p = ax43.get_position()
ax43p.y0 += 0.023
ax43p.y1 -= 0.008
ax43.set_position(ax43p)

ax44p = ax44.get_position()
ax44p.y0 += 0.023
ax44p.y1 -= 0.008
ax44.set_position(ax44p)

ax41.set_aspect('equal')
ax42.set_aspect('equal')
ax43.set_aspect('equal')
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])