Exemple #1
0
 def makeXCorr(self, spk_times: np.array, ax: matplotlib.axes = None,
               **kwargs) -> matplotlib.axes:
     # spk_times in samples provided in seconds but convert to
     # ms for a more display friendly scale
     spk_times = spk_times / 3e4 * 1000.
     S = SpikeCalcsGeneric(spk_times)
     y = S.xcorr(spk_times)
     if ax is None:
         fig = plt.figure()
         ax = fig.add_subplot(111)
     ax.hist(
             y[y != 0], bins=201, range=[-500, 500],
             color='k', histtype='stepfilled')
     ax.set_xlim(-500, 500)
     ax.set_xticks((-500, 0, 500))
     ax.set_xticklabels('')
     ax.tick_params(
         axis='both', which='both', left=False, right=False,
         bottom=False, top=False)
     ax.set_yticklabels('')
     ax.spines['right'].set_visible(False)
     ax.spines['top'].set_visible(False)
     ax.spines['left'].set_visible(False)
     ax.xaxis.set_ticks_position('bottom')
     return ax
Exemple #2
0
def format_axes(in_ax: matplotlib.axes,
                labelsize: int = 12,
                ticksize: int = 10,
                legendsize: int = 8,
                box: bool = False) -> None:
    """Formats ticks, tick label sizes, and axes label sizes for box plots.

    Parameters
    ----------
    in_ax : matplotlib.axes
        Axes containing a plot.
    labelsize : int, optional
        Size of axes labels.
    ticksize : int, optional
        Size of tick labels.
    legendsize : int, optional
        Specifies font size of strings in legend.
    box : bool, optional
        Specifies whether or not a box plot has been plotted.

    Returns
    -------
    None
    """
    in_ax.xaxis.set_minor_locator(AutoMinorLocator())
    in_ax.yaxis.set_minor_locator(AutoMinorLocator())
    in_ax.xaxis.label.set_size(labelsize)
    in_ax.yaxis.label.set_size(labelsize)
    in_ax.tick_params(axis='both',
                      which='major',
                      direction='in',
                      length=4,
                      bottom=True,
                      top=True,
                      left=True,
                      right=True,
                      labelsize=ticksize,
                      color='grey')
    in_ax.tick_params(axis='both',
                      which='minor',
                      direction='in',
                      length=2,
                      bottom=True,
                      top=True,
                      left=True,
                      right=True,
                      color='grey')
    if not box:
        legend = in_ax.legend(fontsize=legendsize,
                              edgecolor=(1, 1, 1, 0.),
                              facecolor=(1, 1, 1, 0))
        legend.get_frame().set_alpha(0)