Skip to content

Commit

Permalink
Improvements to makefigure chart wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Niru Maheswaranathan committed Sep 3, 2015
1 parent e60f42e commit 8f8bb14
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions jetpack/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ def plotwrapper(fun):
@wraps(fun)
def wrapper(*args, **kwargs):

if 'fig' not in kwargs:
kwargs['fig'] = plt.figure()

if 'ax' not in kwargs:

if 'fig' not in kwargs:
kwargs['fig'] = plt.figure()

kwargs['ax'] = kwargs['fig'].add_subplot(111)

else:

if 'fig' not in kwargs:
kwargs['fig'] = kwargs['ax'].get_figure()

res = fun(*args, **kwargs)
plt.show()
plt.draw()
return res

return wrapper
Expand Down Expand Up @@ -72,6 +77,10 @@ def image(img, symmetric=True, colormap='seismic', **kwargs):
kwargs['ax'].imshow(img, cmap=colormap, interpolation=None,
vmin=vmin, vmax=vmax, aspect='equal')

# clear ticks
noticks(ax=kwargs['ax'])
noticks(kwargs['ax'])

# display
plt.show()
plt.draw()
Expand Down Expand Up @@ -172,3 +181,16 @@ def setfontsize(size=18, **kwargs):
ax = kwargs['ax']
ax.set_xticklabels(ax.get_xticks(), fontsize=size)
ax.set_yticklabels(ax.get_yticks(), fontsize=size)


def noticks(ax=None):
"""
Clears tick marks (useful for images)
"""

if ax is None:
ax = plt.gca()

ax.set_xticks([])
ax.set_yticks([])
plt.draw()

0 comments on commit 8f8bb14

Please sign in to comment.