plotind = [1, 3, 5, 7][i + 2 * j]
        ax = plt.subplot(4, 2, plotind)
        ax.plot(t, fr, 'k', linewidth=.5)
        plf.spineless(ax)
        if cond == 'M':
            plf.drawonoff(ax, preframedur, stimdur, h=.1)
            plf.subplottext(['A', 'B'][j], ax, x=-0.1)
        elif cond != 'M' and j == 0:
            scalebars.add_scalebar(
                ax,
                matchx=False,
                sizex=.5,
                labelx='500 ms',
                matchy=False,
                sizey=30,
                labely='30 Hz',
                #                       labely=fr'{dist_set} $\upmu$m',
                hidey=False,
                barwidth=1.2,
                loc='upper right',
                sep=2,
                pad=0)
        for pos in [2, 3, 5, 6]:
            ax.axvline(pos,
                       color='k',
                       alpha=.5,
                       linestyle='dashed',
                       linewidth=1)
        ax.set_ylabel(cond)
        ax.set_xticks([])
        ax.set_yticks([])
示例#2
0
def FORMAT_FIG(fig=None,
               ax=None,
               remove_top=True,
               remove_bottom=False,
               remove_right=True,
               remove_left=False,
               adjust_left=settings.FIG_ADJUST_LEFT,
               adjust_top=settings.FIG_ADJUST_TOP,
               scalebar=None):
    """

    :param fig:
    :param ax:
    :param remove_top:
    :param remove_bottom:
    :param remove_right:
    :param remove_left:
    :param adjust_left:
    :param adjust_top:
    :param scalebar:

    :type ax: np.ndarray or plt.Axes
    :type scalebar: dict or bool


    """
    if type(ax) == list or type(ax) == np.ndarray:
        for sub_ax in ax:
            FORMAT_FIG(fig,
                       sub_ax,
                       remove_top=remove_top,
                       remove_bottom=remove_bottom,
                       remove_right=remove_right,
                       remove_left=remove_left,
                       adjust_left=adjust_left,
                       adjust_top=adjust_top)
    else:
        if scalebar is not None:
            from scalebars import add_scalebar
            if type(scalebar) is dict:
                sb = add_scalebar(ax, **scalebar)
            else:
                sb = add_scalebar(ax)
        elif ax is not None:
            if remove_top:
                ax.spines['top'].set_visible(False)
            if remove_right:
                ax.spines['right'].set_visible(False)
            if remove_bottom:
                ax.spines['bottom'].set_visible(False)
                x_axis = ax.axes.get_xaxis()
                x_axis.set_visible(False)
            if remove_left:
                ax.spines['left'].set_visible(False)
                y_axis = ax.axes.get_yaxis()
                y_axis.set_visible(False)
        if fig is not None:
            fig.tight_layout()
            # tight_layout doesn't take row labels into account. We'll need
            # to make some room. These numbers are manually tweaked.
            # You could automatically calculate them, but it's a pain.
            if adjust_left:
                fig.subplots_adjust(left=adjust_left)
            if adjust_top:
                fig.subplots_adjust(top=adjust_top)
colors.seaborn.set_context('paper',
                           font_scale=3.0,
                           rc={"lines.linewidth": 1.5})
colors.seaborn.set_style('whitegrid', {"axes.linewidth": 1.5})

lw = 1.5

fig = pl.figure(figsize=[16, 10])
fig.set_tight_layout(True)

ax0 = fig.add_subplot(1, 1, 1)

scalebars.add_scalebar(ax0,
                       matchx=False,
                       matchy=False,
                       hidex=False,
                       hidey=False,
                       size=3,
                       label="3 Hz",
                       horizontal=False)

x = np.arange(0, 30, 0.001 * step_size)
collection = collections.BrokenBarHCollection.span_where(
    x,
    ymin=26.5,
    ymax=29.5,
    where=switching > 0,
    facecolor=colors.colors[0],
    alpha=1.0)
ax0.add_collection(collection)

collection = collections.BrokenBarHCollection.span_where(
示例#4
0
    checkercolors = ['black', 'orange']

    with warnings.catch_warnings():
        warnings.filterwarnings('ignore', category=UserWarning)
        warnings.filterwarnings('ignore', '.*invalid value encountered*.')
        ax1.contour(Y, X, Zm, [inner_b, outer_b], linewidths=.5,
                   cmap=plf.RFcolormap(checkercolors))

    barsize_set_checker = 100 # micrometers
    checker_scalebarsize = barsize_set_checker/(stx_h*px_size)

    scalebars.add_scalebar(ax1,
                           matchx=False, sizex=checker_scalebarsize,
                           labelx=f'{barsize_set_checker} µm',
                           barwidth=1.2,
                           loc='lower right',
                           sep=3,
                           pad=.5)

    with warnings.catch_warnings():
        warnings.filterwarnings('ignore',
                                '.*invalid value encountered in*.',
                                RuntimeWarning)
        center_mask = np.logical_not(Zm < inner_b)
        center_mask_3d = np.broadcast_arrays(sta,
                                             center_mask[..., None])[1]
        surround_mask = np.logical_not(np.logical_and(Zm > inner_b,
                                                      Zm < outer_b))
        surround_mask_3d = np.broadcast_arrays(sta,
                                               surround_mask[..., None])[1]
示例#5
0
for n in range(80, 120, 4):
    plt.plot(np.arange(pots.shape[1]) * 0.0025,
             pots[n, :].T / scale - (n - 100) * 100.,
             color='black')
plt.plot(np.arange(pots.shape[1]) * 0.0025,
         pots[100, :].T / scale,
         color='black',
         lw=lw)
plt.xlim(1.4, 1.9)
plt.axis('off')

add_scalebar(ax1,
             sizex=.2,
             sizey=0.02e6 / scale,
             matchx=False,
             matchy=False,
             labelx='0.2 ms',
             labely='20 $\mu$V',
             loc=8,
             bbox_to_anchor=(170.5, 170.5))

plt.axes([4 * axes_w, axes_h, axes_ws, axes_hs],
         sharey=ax1)  #plt.subplot(2,8,2*order[n_p]+1,sharey=ax1)
for n in range(180, 220, 4):
    plt.plot(np.arange(pots.shape[1]) * 0.0025,
             pots[n, :].T / scale - (n - 200) * 100.,
             color='black')
plt.plot(np.arange(pots.shape[1]) * 0.0025,
         pots[200, :].T / scale,
         color='black',
         lw=lw)