Kinda finished analysis and figure for Log-HP invariance (WIP).
This commit is contained in:
@@ -17,6 +17,12 @@ def prepare_fig(nrows, ncols, width=8, height=None, rheight=2, unit=1/2.54,
|
||||
axes[i, j].set_facecolor('none')
|
||||
return fig, axes
|
||||
|
||||
def hide_ticks(ax, side='bottom', ticks=True):
|
||||
axis = 'x' if side in ['top', 'bottom'] else 'y'
|
||||
params = {side: ticks, 'label' + side: False}
|
||||
ax.tick_params(axis=axis, which='both', **params)
|
||||
return None
|
||||
|
||||
def hide_axis(ax, side='bottom'):
|
||||
ax.spines[side].set_visible(False)
|
||||
params = {side: False, 'label' + side: False}
|
||||
@@ -33,7 +39,7 @@ def letter_subplots(axes, labels=None, x=0.02, y=1, ha='left', va='bottom',
|
||||
fontsize=fontsize, fontweight=fontweight, **kwargs)
|
||||
return None
|
||||
|
||||
def xlimits(ax, time, minval=None, maxval=None, pad=0.05):
|
||||
def xlimits(time, ax=None, minval=None, maxval=None, pad=0.05):
|
||||
limits = [minval, maxval]
|
||||
if minval is None:
|
||||
limits[0] = time[0]
|
||||
@@ -44,9 +50,11 @@ def xlimits(ax, time, minval=None, maxval=None, pad=0.05):
|
||||
limits[0] -= span * pad
|
||||
if pad and maxval is None:
|
||||
limits[1] += span * pad
|
||||
return ax.set_xlim(limits)
|
||||
if ax is not None:
|
||||
return ax.set_xlim(limits)
|
||||
return limits
|
||||
|
||||
def ylimits(ax, signal, minval=None, maxval=None, pad=0.05):
|
||||
def ylimits(signal, ax=None, minval=None, maxval=None, pad=0.05):
|
||||
limits = [minval, maxval]
|
||||
if minval is None:
|
||||
limits[0] = signal.min()
|
||||
@@ -57,7 +65,9 @@ def ylimits(ax, signal, minval=None, maxval=None, pad=0.05):
|
||||
limits[0] -= span * pad
|
||||
if pad and maxval is None:
|
||||
limits[1] += span * pad
|
||||
return ax.set_ylim(limits)
|
||||
if ax is not None:
|
||||
return ax.set_ylim(limits)
|
||||
return limits
|
||||
|
||||
def xlabel(ax, label, y=-0.1, fontsize=20, **kwargs):
|
||||
ax.set_xlabel(label, fontsize=fontsize, **kwargs)
|
||||
@@ -82,8 +92,8 @@ def super_ylabel(label, fig, high_ax, low_ax, x=0.005, **kwargs):
|
||||
def plot_line(ax, time, signal, ymin=None, ymax=None, xmin=None, xmax=None,
|
||||
xpad=None, ypad=0.05, yloc=None, xloc=None, **kwargs):
|
||||
handles = ax.plot(time, signal, **kwargs)
|
||||
xlimits(ax, time, minval=xmin, maxval=xmax, pad=xpad)
|
||||
ylimits(ax, signal, minval=ymin, maxval=ymax, pad=ypad)
|
||||
xlimits(time, ax=ax, minval=xmin, maxval=xmax, pad=xpad)
|
||||
ylimits(signal, ax=ax, minval=ymin, maxval=ymax, pad=ypad)
|
||||
if xloc is not None:
|
||||
ax.xaxis.set_major_locator(plt.MultipleLocator(xloc))
|
||||
if yloc is not None:
|
||||
@@ -98,7 +108,7 @@ def plot_barcode(ax, time, binary, offset=0.5, xmin=None, xmax=None, **kwargs):
|
||||
if i < binary.shape[1] - 1:
|
||||
lower += offset + 1
|
||||
upper += offset + 1
|
||||
xlimits(ax, time, minval=xmin, maxval=xmax, pad=0)
|
||||
xlimits(time, ax=ax, minval=xmin, maxval=xmax, pad=0)
|
||||
ax.set_ylim(0, upper)
|
||||
hide_axis(ax, 'bottom')
|
||||
hide_axis(ax, 'left')
|
||||
|
||||
Reference in New Issue
Block a user