Example #1
0
def make_plot_ax():
    fig = figure(figsize=(6, 5));
    ax = SubplotZero(fig, 111); fig.add_subplot(ax)
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
    xlim(-0.1, 2.1); ylim(xlim())
    ticks = [0.5 * i for i in range(1, 5)]
    labels = [str(i) if i == int(i) else "" for i in ticks]
    ax.set_xticks(ticks); ax.set_yticks(ticks)
    ax.set_xticklabels(labels); ax.set_yticklabels(labels)
    ax.axis["yzero"].set_axis_direction("left")
    return ax
Example #2
0
def make_plot_ax():
    fig = figure(figsize=(6, 5))
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
    xlim(-0.1, 2.1)
    ylim(xlim())
    ticks = [0.5 * i for i in range(1, 5)]
    labels = [str(i) if i == int(i) else "" for i in ticks]
    ax.set_xticks(ticks)
    ax.set_yticks(ticks)
    ax.set_xticklabels(labels)
    ax.set_yticklabels(labels)
    ax.axis["yzero"].set_axis_direction("left")
    return ax
Example #3
0
q = 3  # xの最大値
n = 12  # 引く包絡線の数
a_min = -10  # 表示させるaの最小値
a_max = 10  # 表示させるaの最大値
y_min = -6  # 表示させるbの最小値(最大値はa軸とb軸の縮尺が1:1になるよう自動で決まる)
# アスペクト比を定めただけだと異常に縦長なグラフが出てくるのでylimを定めた
y_max = y_min+a_max-a_min  # これは変数ではない
plt.figtext(0.85, 0.35, '$a$')  # 直接位置を指定しているので、グラフの位置を変えるときにこれも変える
plt.figtext(0.5, 0.95, '$b$')
# ここより上に変数が入る
fig = plt.figure(1)
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)
ax.axhline(linewidth=1.0, color="black")
ax.axvline(linewidth=1.0, color="black")
ax.set_xticks([])  # 空のlistを指定することでticksが入らない
ax.set_yticks([])
ax.set(aspect=1)
for direction in ["xzero", "yzero"]:
    ax.axis[direction].set_axisline_style("-|>")
    ax.axis[direction].set_visible(True)
plt.ylim(ymin=y_min)  # この位置より前に置くとx方向が狭くなってしまった
plt.ylim(ymax=y_max)
a = linspace(a_min, a_max, (a_max-a_min) * 10)  # 点の数はaの動く範囲の長さ×10,これで曲線にも対応する
# linspaceの点の数に小数が来ることがあり得るのですが、その場合は勝手に小数点以下を切り捨てた数の点をとってくれるようです
for i in range(n):
    r = p+(q-p)*i/(n-1)  # n個の接線を引き2個は両端にあるので区間はn-1等分される
    b = f(r, a)
    ax.plot(a, b, 'k', linewidth=0.5, alpha=1)
# linewidth:線の太さ, alpha:濃さ(1以下), 黒色の線は'k'
plt.show()
Example #4
0
ax3.plot(foursphereParams['r'][:, 0],
         foursphereParams['r'][:, 2],
         'ko',
         label='EEG/MEG sites')
for i, (x, y, z) in enumerate(foursphereParams['r']):
    # theta = np.arcsin(x / foursphereParams['radii'][-1])
    # if x >= 0:
    #     ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi))
    # else:
    #     ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi), ha='right')
    ax3.text(x, z + 2500, r'{}'.format(i + 1), ha='center')

# dipole location
ax3.plot([0], [dipole_position[-1]], 'k.', label='dipole site')
ax3.axis('equal')
ax3.set_xticks(np.r_[-np.array(foursphereParams['radii']), 0,
                     foursphereParams['radii']])
ax3.set_xticklabels([])
ax3.legend(loc=(0.25, 0.15), frameon=False)

# four-sphere volume conductor
sphere = LFPy.FourSphereVolumeConductor(**foursphereParams)
phi_p = sphere.calc_potential(cell.current_dipole_moment, rz=dipole_position)

# import example_parallel_network_plotting as plotting
vlimround = draw_lineplot(
    ax=ax4,
    data=phi_p * 1E9,
    unit=r'pV',  #mV -> pV unit conversion
    dt=cell.dt,
    ztransform=False,
    T=(0, cell.tstop),
Example #5
0
    for i, r, label in zip(range(4), PSET.foursphereParams['radii'], ['brain', 'CSF', 'skull', 'scalp']):
        ax.plot(np.cos(theta)*r, np.sin(theta)*r, 'C{}'.format(i), label=label + r', $r_%i=%i$ mm' % (i+1, r / 1000), clip_on=False)
    
    # draw measurement points
    ax.plot(PSET.foursphereParams['r'][:, 0], PSET.foursphereParams['r'][:, 2], 'ko', label='EEG/MEG sites')
    
    for i, (x, y, z) in enumerate(PSET.foursphereParams['r']):
        ax.text(x, z+2500, r'{}'.format(i+1), ha='center')
        
    # dipole location
    ax.plot([0], [PSET.foursphereParams['radii'][0] + PSET.layer_data['center'][3]], 'k.', label='dipole site')
    
    ax.axis('equal')
    ax.set_ylim(top=max(PSET.foursphereParams['radii']) + 5000)

    ax.set_xticks(np.r_[-np.array(PSET.foursphereParams['radii']), 0, PSET.foursphereParams['radii']])
    ax.set_xticklabels([])                       
    
    ax.legend(loc=(0.25, 0.05), frameon=False)
    
    ax.text(-0.1, 1.05, alphabet[5],
        horizontalalignment='center',
        verticalalignment='center',
        fontsize=16, fontweight='demibold',
        transform=ax.transAxes)




    # PANEL G. EEG signal
    ax = fig.add_subplot(gs[2, 2])
Example #6
0
from numpy import *
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.axislines import SubplotZero

x = linspace(-5 * pi, 5 * pi, 500)
y = (sin(x) / x)**2
fig = plt.figure(figsize=(8, 4))
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)
ax.grid(True)
ax.set_xticks([
    -5 * pi, -4 * pi, -3 * pi, -2 * pi, -pi, 0, pi, 2 * pi, 3 * pi, 4 * pi,
    5 * pi
])
ax.set_xticklabels([
    "$-5 \pi$", "$-4 \pi$", "$-3 \pi$", "$-2 \pi$", "$- \pi$", "0", "$\pi$",
    "$2 \pi$", "$3 \pi$", "$4 \pi$", "$5 \pi$"
])
ax.set_ylim((-.3, 1.2))
ax.set_yticklabels([])
for direction in ["xzero", "yzero"]:
    ax.axis[direction].set_axisline_style("->")
    ax.axis[direction].set_visible(True)
for direction in ["left", "right", "bottom", "top"]:
    ax.axis[direction].set_visible(False)
ax.plot(x, y, label=r"$sinc^{2} \ x$", color="k", linewidth=3, alpha=0.8)
ax.text(5.5 * pi, 0., "x")
ax.text(0.1, 1, "1")
ax.legend()
plt.tight_layout()
plt.savefig("sinc.png")
Example #7
0
    ax3.plot(np.cos(theta)*r, np.sin(theta)*r, 'C{}'.format(i), label=label + r', $r_%i=%i$ mm' % (i+1, r / 1000), clip_on=False)

# draw measurement points
ax3.plot(foursphereParams['r'][:, 0], foursphereParams['r'][:, 2], 'ko', label='EEG/MEG sites')
for i, (x, y, z) in enumerate(foursphereParams['r']):
    # theta = np.arcsin(x / foursphereParams['radii'][-1])
    # if x >= 0:
    #     ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi))
    # else:
    #     ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi), ha='right')
    ax3.text(x, z+2500, r'{}'.format(i + 1), ha='center')
    
# dipole location
ax3.plot([0], [dipole_position[-1]], 'k.', label='dipole site')
ax3.axis('equal')
ax3.set_xticks(np.r_[-np.array(foursphereParams['radii']), 0, foursphereParams['radii']])
ax3.set_xticklabels([])                       
ax3.legend(loc=(0.25, 0.15), frameon=False)



# four-sphere volume conductor
sphere = LFPy.FourSphereVolumeConductor(
    **foursphereParams
)
phi_p = sphere.calc_potential(cell.current_dipole_moment, rz=dipole_position)

# import example_parallel_network_plotting as plotting
vlimround = draw_lineplot(ax=ax4, data=phi_p*1E9, unit=r'pV', #mV -> pV unit conversion
                          dt=cell.dt, ztransform=False,
                          T=(0, cell.tstop), color='k', scalebarbasis='log10')      
Example #8
0
            'ko',
            label='EEG/MEG sites')

    for i, (x, y, z) in enumerate(PSET.foursphereParams['r']):
        ax.text(x, z + 2500, r'{}'.format(i + 1), ha='center')

    # dipole location
    ax.plot([0],
            [PSET.foursphereParams['radii'][0] + PSET.layer_data['center'][3]],
            'k.',
            label='dipole site')

    ax.axis('equal')
    ax.set_ylim(top=max(PSET.foursphereParams['radii']) + 5000)

    ax.set_xticks(np.r_[-np.array(PSET.foursphereParams['radii']), 0,
                        PSET.foursphereParams['radii']])
    ax.set_xticklabels([])

    ax.legend(loc=(0.25, 0.05), frameon=False)

    ax.text(-0.1,
            1.05,
            alphabet[5],
            horizontalalignment='center',
            verticalalignment='center',
            fontsize=16,
            fontweight='demibold',
            transform=ax.transAxes)

    # PANEL G. EEG signal
    ax = fig.add_subplot(gs[2, 2])