Skip to content

Commit

Permalink
remove plot_signal(), everything done with graph.plot()
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeff committed Nov 8, 2018
1 parent 50274a5 commit 771cfec
Show file tree
Hide file tree
Showing 26 changed files with 81 additions and 152 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ structure!
>>> s = np.zeros(G.N)
>>> s[DELTAS] = 1
>>> s = g.filter(s)
>>> fig, ax = G.plot_signal(s, highlight=DELTAS)
>>> fig, ax = G.plot(s, highlight=DELTAS)

.. image:: ../pygsp/data/readme_example_graph.png
:alt:
Expand Down
10 changes: 5 additions & 5 deletions doc/tutorials/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ which assign a set of values (a vector in :math:`\mathbb{R}^d`) at every node
>>>
>>> fig, axes = plt.subplots(1, 2, figsize=(10, 3))
>>> for i, ax in enumerate(axes):
... _ = G.plot_signal(G.U[:, i+1], size=30, ax=ax)
... _ = G.plot(G.U[:, i+1], size=30, ax=ax)
... _ = ax.set_title('Eigenvector {}'.format(i+2))
... ax.set_axis_off()
>>> fig.tight_layout()
Expand All @@ -168,9 +168,9 @@ plot best represents the graph.
>>> G2 = graphs.Ring(N=50)
>>> G2.compute_fourier_basis()
>>> fig, axes = plt.subplots(1, 2, figsize=(10, 4))
>>> _ = G2.plot_signal(G2.U[:, 4], ax=axes[0])
>>> _ = G2.plot(G2.U[:, 4], ax=axes[0])
>>> G2.set_coordinates('line1D')
>>> _ = G2.plot_signal(G2.U[:, 1:4], ax=axes[1])
>>> _ = G2.plot(G2.U[:, 1:4], ax=axes[1])
>>> fig.tight_layout()

Filters
Expand Down Expand Up @@ -227,9 +227,9 @@ low-pass filter.
>>> s2 = g.filter(s)
>>>
>>> fig, axes = plt.subplots(1, 2, figsize=(10, 3))
>>> _ = G.plot_signal(s, size=30, title='noisy', ax=axes[0])
>>> _ = G.plot(s, size=30, title='noisy', ax=axes[0])
>>> axes[0].set_axis_off()
>>> _ = G.plot_signal(s2, size=30, title='cleaned', ax=axes[1])
>>> _ = G.plot(s2, size=30, title='cleaned', ax=axes[1])
>>> axes[1].set_axis_off()
>>> fig.tight_layout()

Expand Down
8 changes: 4 additions & 4 deletions doc/tutorials/optimization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This tutorial focuses on the problem of recovering a label signal on a graph fro
>>> # Create label signal
>>> label_signal = np.copysign(np.ones(G.N), G.U[:, 3])
>>>
>>> fig, ax = G.plot_signal(label_signal)
>>> fig, ax = G.plot(label_signal)

The first figure shows a plot of the original label signal, that we wish to recover, on the graph.

Expand All @@ -39,7 +39,7 @@ The first figure shows a plot of the original label signal, that we wish to reco
>>> sigma = 0.1
>>> subsampled_noisy_label_signal = M * (label_signal + sigma * rs.standard_normal(G.N))
>>>
>>> fig, ax = G.plot_signal(subsampled_noisy_label_signal)
>>> fig, ax = G.plot(subsampled_noisy_label_signal)

This figure shows the label signal on the graph after the application of the subsampling mask and the addition of noise. The label of more than half of the vertices has been set to :math:`0`.

Expand Down Expand Up @@ -88,7 +88,7 @@ We start with the graph TV regularization. We will use the :class:`pyunlocbox.so
objective function f(sol) = 2.024594e+02
stopping criterion: MAXIT
>>>
>>> fig, ax = G.plot_signal(prob1['sol'])
>>> fig, ax = G.plot(prob1['sol'])

This figure shows the label signal recovered by graph total variation regularization. We can confirm here that this sort of regularization does indeed promote piecewise-constant solutions.

Expand All @@ -110,6 +110,6 @@ This figure shows the label signal recovered by graph total variation regulariza
objective function f(sol) = 9.555135e+01
stopping criterion: MAXIT
>>>
>>> fig, ax = G.plot_signal(prob2['sol'])
>>> fig, ax = G.plot(prob2['sol'])

This last figure shows the label signal recovered by Tikhonov regularization. As expected, the recovered label signal has smoother transitions than the one obtained by graph TV regularization.
6 changes: 3 additions & 3 deletions doc/tutorials/wavelet.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ scales.
>>> for i in range(g.Nf):
... ax = fig.add_subplot(1, g.Nf, i+1, projection='3d')
... title = r'Heat diffusion, $\tau={}$'.format(taus[i])
... _ = G.plot_signal(s[:, i], colorbar=False, title=title, ax=ax)
... _ = G.plot(s[:, i], colorbar=False, title=title, ax=ax)
... ax.set_axis_off()
>>> fig.tight_layout()

Expand Down Expand Up @@ -124,7 +124,7 @@ a Kronecker delta placed at one specific vertex.
>>> fig = plt.figure(figsize=(10, 2.5))
>>> for i in range(3):
... ax = fig.add_subplot(1, 3, i+1, projection='3d')
... _ = G.plot_signal(s[:, i], title='Wavelet {}'.format(i+1), ax=ax)
... _ = G.plot(s[:, i], title='Wavelet {}'.format(i+1), ax=ax)
... ax.set_axis_off()
>>> fig.tight_layout()

Expand Down Expand Up @@ -165,6 +165,6 @@ curvature at different scales.
>>> for i in range(4):
... ax = fig.add_subplot(2, 2, i+1, projection='3d')
... title = 'Curvature estimation (scale {})'.format(i+1)
... _ = G.plot_signal(s[:, i], title=title, ax=ax)
... _ = G.plot(s[:, i], title=title, ax=ax)
... ax.set_axis_off()
>>> fig.tight_layout()
2 changes: 1 addition & 1 deletion playground.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"s = np.zeros(G.N)\n",
"s[DELTAS] = 1\n",
"s = g.filter(s)\n",
"G.plot_signal(s, highlight=DELTAS, backend='matplotlib')"
"G.plot(s, highlight=DELTAS, backend='matplotlib')"
]
},
{
Expand Down
2 changes: 0 additions & 2 deletions pygsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@
try:
filters.Filter.plot.__doc__ = plotting._plot_filter.__doc__
graphs.Graph.plot.__doc__ = plotting._plot_graph.__doc__
graphs.Graph.plot_signal.__doc__ = plotting._plot_signal.__doc__
graphs.Graph.plot_spectrogram.__doc__ = plotting._plot_spectrogram.__doc__
except AttributeError:
# For Python 2.7.
filters.Filter.plot.__func__.__doc__ = plotting._plot_filter.__doc__
graphs.Graph.plot.__func__.__doc__ = plotting._plot_graph.__doc__
graphs.Graph.plot_signal.__func__.__doc__ = plotting._plot_signal.__doc__
graphs.Graph.plot_spectrogram.__func__.__doc__ = plotting._plot_spectrogram.__doc__

__version__ = '0.5.1'
Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/abspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Abspline(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/expwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Expwin(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
8 changes: 4 additions & 4 deletions pygsp/filters/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def filter(self, s, method='chebyshev', order=30):
>>> fig, ax = plt.subplots()
>>> G.set_coordinates('line1D') # To visualize multiple signals in 1D.
>>> _ = G.plot_signal(s[:, 9, :], ax=ax)
>>> _ = G.plot(s[:, 9, :], ax=ax)
>>> legend = [r'$\tau={}$'.format(t) for t in taus]
>>> ax.legend(legend) # doctest: +ELLIPSIS
<matplotlib.legend.Legend object at ...>
Expand Down Expand Up @@ -218,8 +218,8 @@ def filter(self, s, method='chebyshev', order=30):
Look how well we were able to reconstruct:
>>> fig, axes = plt.subplots(1, 2)
>>> _ = G.plot_signal(s1, ax=axes[0])
>>> _ = G.plot_signal(s2, ax=axes[1])
>>> _ = G.plot(s1, ax=axes[0])
>>> _ = G.plot(s2, ax=axes[1])
>>> print('{:.5f}'.format(np.linalg.norm(s1 - s2)))
0.29620
Expand Down Expand Up @@ -351,7 +351,7 @@ def localize(self, i, **kwargs):
>>> G.estimate_lmax()
>>> g = filters.Heat(G, 100)
>>> s = g.localize(DELTA)
>>> _ = G.plot_signal(s, highlight=DELTA)
>>> _ = G.plot(s, highlight=DELTA)
"""
s = np.zeros(self.G.N)
Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/gabor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Gabor(Filter):
>>> s = g.localize(G.N // 2, method='exact')
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0], sum=False)
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/halfcosine.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HalfCosine(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/heat.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Heat(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/held.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Held(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/itersine.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Itersine(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/mexicanhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MexicanHat(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/meyer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Meyer(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/papadakis.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Papadakis(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/rectangular.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Rectangular(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/regular.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Regular(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/simoncelli.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Simoncelli(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
2 changes: 1 addition & 1 deletion pygsp/filters/simpletight.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SimpleTight(Filter):
>>> s = g.localize(G.N // 2)
>>> fig, axes = plt.subplots(1, 2)
>>> _ = g.plot(ax=axes[0])
>>> _ = G.plot_signal(s, ax=axes[1])
>>> _ = G.plot(s, ax=axes[1])
"""

Expand Down
1 change: 0 additions & 1 deletion pygsp/graphs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
.. autosummary::
Graph.plot
Graph.plot_signal
Graph.plot_spectrogram
Others
Expand Down
4 changes: 2 additions & 2 deletions pygsp/graphs/fourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def coherence(self):
>>> # Plot some delocalized eigenvectors.
>>> import matplotlib.pyplot as plt
>>> graph.set_coordinates('line1D')
>>> _ = graph.plot_signal(graph.U[:, :5])
>>> _ = graph.plot(graph.U[:, :5])
Localized eigenvectors.
Expand All @@ -83,7 +83,7 @@ def coherence(self):
>>> # Plot the most localized eigenvector.
>>> import matplotlib.pyplot as plt
>>> idx = np.argmax(np.max(graph.U, axis=0))
>>> _ = graph.plot_signal(graph.U[:, idx])
>>> _ = graph.plot(graph.U[:, idx])
"""
return self._check_fourier_properties('coherence',
Expand Down
21 changes: 9 additions & 12 deletions pygsp/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,21 +683,18 @@ def modulate(self, f, k):
fm *= np.sqrt(self.N)
return fm

def plot(self, edges=None, index=False, backend=None, vertex_size=None,
title=None, ax=None):
def plot(self, color=None, size=None, highlight=[], edges=None,
index=False, colorbar=True, limits=None, ax=None,
title=None, backend=None):
r"""Docstring overloaded at import time."""
from pygsp.plotting import _plot_graph
return _plot_graph(self, edges=edges, index=index, backend=backend,
vertex_size=vertex_size, title=title, ax=ax)
return _plot_graph(self, color=color, size=size, highlight=highlight,
edges=edges, index=index, colorbar=colorbar,
limits=limits, ax=ax, title=title, backend=backend)

def plot_signal(self, color=None, size=None, highlight=[], edges=None,
index=False, colorbar=True, limits=None, ax=None,
title=None, backend=None):
r"""Docstring overloaded at import time."""
from pygsp.plotting import _plot_signal
return _plot_signal(self, color=color, size=size, highlight=highlight,
edges=edges, index=index, colorbar=colorbar,
limits=limits, ax=ax, title=title, backend=backend)
def plot_signal(self, *args, **kwargs):
r"""Deprecated, use plot() instead."""
return self.plot(*args, **kwargs)

def plot_spectrogram(self, node_idx=None):
r"""Docstring overloaded at import time."""
Expand Down
Loading

0 comments on commit 771cfec

Please sign in to comment.