diff --git a/jetpack/chart/plots.py b/jetpack/chart/plots.py index cc5a111..cdfa2b7 100644 --- a/jetpack/chart/plots.py +++ b/jetpack/chart/plots.py @@ -105,7 +105,7 @@ def errorplot(x, y, yerr, method='patch', color='k', xscale='linear', fmt='-', @plotwrapper -def img(data, mode='div', center=True, cmap=None, aspect='equal', vmin=None, vmax=None, cbar=False, **kwargs): +def img(data, mode='div', center=True, cmap=None, aspect='equal', vmin=None, vmax=None, cbar=False, interpolation='none', **kwargs): """ Visualize a matrix as an image @@ -165,7 +165,7 @@ def img(data, mode='div', center=True, cmap=None, aspect='equal', vmin=None, vma raise ValueError("Unrecognized mode: '" + mode + "'") # make the image - kwargs['ax'].imshow(img, cmap=cmap, interpolation=None, + kwargs['ax'].imshow(img, cmap=cmap, interpolation=interpolation, vmin=vmin, vmax=vmax, aspect=aspect) # colorbar @@ -240,5 +240,11 @@ def corrplot(C, cmap=None, cmap_range=(0.0, 1.0), cbar=True, fontsize=14, **kwar noticks(ax=ax) +@plotwrapper +def bars(*dicts, **kwargs): + ax = kwargs['ax'] + raise NotImplementedError + + # aliases imv = partial(img, mode='seq') diff --git a/jetpack/chart/utils.py b/jetpack/chart/utils.py index 571ea26..b8af54f 100644 --- a/jetpack/chart/utils.py +++ b/jetpack/chart/utils.py @@ -5,7 +5,7 @@ import matplotlib.pyplot as plt from functools import wraps -__all__ = ['setfontsize', 'noticks', 'nospines', 'breathe'] +__all__ = ['setfontsize', 'noticks', 'nospines', 'breathe', 'setcolor'] def plotwrapper(fun): @@ -71,6 +71,8 @@ def setfontsize(size=18, **kwargs): ax.set_xticklabels(ax.get_xticks(), fontsize=size) ax.set_yticklabels(ax.get_yticks(), fontsize=size) + return ax + @axwrapper def noticks(**kwargs): @@ -99,6 +101,8 @@ def nospines(**kwargs): ax.yaxis.set_ticks_position('left') ax.xaxis.set_ticks_position('bottom') + return ax + @axwrapper def breathe(factor=0.05, **kwargs): @@ -123,3 +127,22 @@ def breathe(factor=0.05, **kwargs): ax.spines['left'].set_bounds(ya, yb) nospines(**kwargs) + + return ax + + +@axwrapper +def setcolor(color='#444444', **kwargs): + ax = kwargs['ax'] + + # set the tick parameters + ax.tick_params(axis='x', colors=color) + ax.tick_params(axis='y', colors=color) + + # set the label colors + ax.xaxis.label.set_color(color) + ax.yaxis.label.set_color(color) + ax.set_xlabel(ax.get_xlabel(), color=color) + ax.set_ylabel(ax.get_ylabel(), color=color) + + return ax diff --git a/jetpack/signals.py b/jetpack/signals.py index d5f8ae4..3f81b26 100644 --- a/jetpack/signals.py +++ b/jetpack/signals.py @@ -12,7 +12,7 @@ from scipy.linalg import sqrtm, inv __all__ = ['peakdet', 'smooth', 'norms', 'sfthr', 'sfrct', 'sq', 'arr', - 'whiten', 'canoncorr', 'xcorr'] + 'whiten', 'canoncorr', 'xcorr', 'sqa'] def peakdet(v, delta, x=None): @@ -299,3 +299,8 @@ def arr(x): Converts a generator to a numpy array """ return np.array(list(x)) + + +def sqa(x): + """Squeeze(array)""" + return np.squeeze(np.array(x))