Skip to content

Commit

Permalink
adds a setcolor utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Niru Maheswaranathan committed Jun 27, 2016
1 parent a284b4a commit faeb676
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
10 changes: 8 additions & 2 deletions jetpack/chart/plots.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
25 changes: 24 additions & 1 deletion jetpack/chart/utils.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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
7 changes: 6 additions & 1 deletion jetpack/signals.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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))

0 comments on commit faeb676

Please sign in to comment.