Skip to content

Commit

Permalink
Update plotting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Hoffman committed Jun 3, 2015
1 parent 1afa28d commit 5e47706
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mwhutils/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,17 @@ def scatter(self, x, y, marker='o', color='k', alpha=1):
self._ax.scatter(x, y, **kwargs)
self._draw()

def plot(self, x, y):
def plot(self, x, y=None, color=None, alpha=1):
"""
Add a simple plot to the axis.
"""
self._ax.plot(x, y)
if y is None:
y = x
x = np.arange(len(y))
self._ax.plot(x, y, lw=2, color=color, alpha=alpha)
self._draw()

def plot_banded(self, x, y, a=None, b=None):
def plot_banded(self, x, y, a=None, b=None, label=''):
if a is None and b is None:
lo = np.zeros_like(y)
hi = y
Expand All @@ -109,7 +112,7 @@ def plot_banded(self, x, y, a=None, b=None):
else:
lo = y - a
hi = y + b
lines = self._ax.plot(x, y)
lines = self._ax.plot(x, y, lw=2, label=label)
color = lines[0].get_color()
alpha = 0.25
self._ax.fill_between(x, lo, hi, color=color, alpha=alpha)
Expand All @@ -132,6 +135,7 @@ def hline(self, y):
def _draw(self):
self._ax.axis('tight')
self._ax.axis(self._lim)
self._ax.legend()
self._hook()
if not self._hold and pl.isinteractive():
self.draw()
Expand Down

0 comments on commit 5e47706

Please sign in to comment.