diff --git a/README.rst b/README.rst index ce2c3896..f1757b94 100644 --- a/README.rst +++ b/README.rst @@ -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: diff --git a/doc/tutorials/intro.rst b/doc/tutorials/intro.rst index dc004d26..b1cca151 100644 --- a/doc/tutorials/intro.rst +++ b/doc/tutorials/intro.rst @@ -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() @@ -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 @@ -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() diff --git a/doc/tutorials/optimization.rst b/doc/tutorials/optimization.rst index 69372519..e495cf08 100644 --- a/doc/tutorials/optimization.rst +++ b/doc/tutorials/optimization.rst @@ -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. @@ -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`. @@ -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. @@ -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. diff --git a/doc/tutorials/wavelet.rst b/doc/tutorials/wavelet.rst index b618d5ca..287a0118 100644 --- a/doc/tutorials/wavelet.rst +++ b/doc/tutorials/wavelet.rst @@ -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() @@ -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() @@ -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() diff --git a/playground.ipynb b/playground.ipynb index c530a12a..c22fd25f 100644 --- a/playground.ipynb +++ b/playground.ipynb @@ -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')" ] }, { diff --git a/pygsp/__init__.py b/pygsp/__init__.py index cbd127aa..4e7e75b8 100644 --- a/pygsp/__init__.py +++ b/pygsp/__init__.py @@ -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' diff --git a/pygsp/filters/abspline.py b/pygsp/filters/abspline.py index ae985bed..2bd23e33 100644 --- a/pygsp/filters/abspline.py +++ b/pygsp/filters/abspline.py @@ -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]) """ diff --git a/pygsp/filters/expwin.py b/pygsp/filters/expwin.py index d02edab7..3152d7f2 100644 --- a/pygsp/filters/expwin.py +++ b/pygsp/filters/expwin.py @@ -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]) """ diff --git a/pygsp/filters/filter.py b/pygsp/filters/filter.py index da245a23..544fd331 100644 --- a/pygsp/filters/filter.py +++ b/pygsp/filters/filter.py @@ -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 @@ -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 @@ -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) diff --git a/pygsp/filters/gabor.py b/pygsp/filters/gabor.py index 9002b49e..6ffc9ac1 100644 --- a/pygsp/filters/gabor.py +++ b/pygsp/filters/gabor.py @@ -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]) """ diff --git a/pygsp/filters/halfcosine.py b/pygsp/filters/halfcosine.py index 13f41284..253793e6 100644 --- a/pygsp/filters/halfcosine.py +++ b/pygsp/filters/halfcosine.py @@ -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]) """ diff --git a/pygsp/filters/heat.py b/pygsp/filters/heat.py index fde434d6..7bd62a11 100644 --- a/pygsp/filters/heat.py +++ b/pygsp/filters/heat.py @@ -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]) """ diff --git a/pygsp/filters/held.py b/pygsp/filters/held.py index 5c6290f0..37ebf973 100644 --- a/pygsp/filters/held.py +++ b/pygsp/filters/held.py @@ -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]) """ diff --git a/pygsp/filters/itersine.py b/pygsp/filters/itersine.py index 2fd04987..856a56b8 100644 --- a/pygsp/filters/itersine.py +++ b/pygsp/filters/itersine.py @@ -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]) """ diff --git a/pygsp/filters/mexicanhat.py b/pygsp/filters/mexicanhat.py index 04de75f8..92740aa6 100644 --- a/pygsp/filters/mexicanhat.py +++ b/pygsp/filters/mexicanhat.py @@ -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]) """ diff --git a/pygsp/filters/meyer.py b/pygsp/filters/meyer.py index 5311e444..4c03c703 100644 --- a/pygsp/filters/meyer.py +++ b/pygsp/filters/meyer.py @@ -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]) """ diff --git a/pygsp/filters/papadakis.py b/pygsp/filters/papadakis.py index 6f9e1da3..b1f96a6e 100644 --- a/pygsp/filters/papadakis.py +++ b/pygsp/filters/papadakis.py @@ -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]) """ diff --git a/pygsp/filters/rectangular.py b/pygsp/filters/rectangular.py index 909f69f5..c70524b1 100644 --- a/pygsp/filters/rectangular.py +++ b/pygsp/filters/rectangular.py @@ -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]) """ diff --git a/pygsp/filters/regular.py b/pygsp/filters/regular.py index 9bb249ef..085e443b 100644 --- a/pygsp/filters/regular.py +++ b/pygsp/filters/regular.py @@ -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]) """ diff --git a/pygsp/filters/simoncelli.py b/pygsp/filters/simoncelli.py index d19621d1..97d78fa5 100644 --- a/pygsp/filters/simoncelli.py +++ b/pygsp/filters/simoncelli.py @@ -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]) """ diff --git a/pygsp/filters/simpletight.py b/pygsp/filters/simpletight.py index 4266824e..c5aad96b 100644 --- a/pygsp/filters/simpletight.py +++ b/pygsp/filters/simpletight.py @@ -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]) """ diff --git a/pygsp/graphs/__init__.py b/pygsp/graphs/__init__.py index 84659170..3f4732a7 100644 --- a/pygsp/graphs/__init__.py +++ b/pygsp/graphs/__init__.py @@ -84,7 +84,6 @@ .. autosummary:: Graph.plot - Graph.plot_signal Graph.plot_spectrogram Others diff --git a/pygsp/graphs/fourier.py b/pygsp/graphs/fourier.py index da33bfb3..1afaedd4 100644 --- a/pygsp/graphs/fourier.py +++ b/pygsp/graphs/fourier.py @@ -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. @@ -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', diff --git a/pygsp/graphs/graph.py b/pygsp/graphs/graph.py index 40496b1b..0f781f73 100644 --- a/pygsp/graphs/graph.py +++ b/pygsp/graphs/graph.py @@ -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.""" diff --git a/pygsp/plotting.py b/pygsp/plotting.py index 778dfede..71079348 100644 --- a/pygsp/plotting.py +++ b/pygsp/plotting.py @@ -8,8 +8,8 @@ Most users won't use this module directly. Graphs (from :mod:`pygsp.graphs`) are to be plotted with -:meth:`pygsp.graphs.Graph.plot`, :meth:`pygsp.graphs.Graph.plot_spectrogram`, -and :meth:`pygsp.graphs.Graph.plot_signal`. +:meth:`pygsp.graphs.Graph.plot` and +:meth:`pygsp.graphs.Graph.plot_spectrogram`. Filters (from :mod:`pygsp.filters`) are to be plotted with :meth:`pygsp.filters.Filter.plot`. @@ -141,76 +141,6 @@ def close(*args, **kwargs): plt.close(*args, **kwargs) -def _plot_graph(G, edges, index, backend, vertex_size, title, ax): - r"""Plot the graph. - - Parameters - ---------- - edges : bool - True to draw edges, false to only draw vertices. - Default True if less than 10,000 edges to draw. - Note that drawing many edges can be slow. - index : bool - Whether to print the node index (in the adjacency / Laplacian matrix - and signal vectors) on top of each node. - Useful to locate a node of interest. - Only available with the matplotlib backend. - backend: {'matplotlib', 'pyqtgraph'} - Defines the drawing backend to use. Defaults to :data:`BACKEND`. - vertex_size : float - Size of circle representing each node. - Defaults to G.plotting['vertex_size']. - title : str - Title of the figure. - ax : :class:`matplotlib.axes.Axes` - Axes where to draw the graph. Optional, created if not passed. - Only available with the matplotlib backend. - - Returns - ------- - fig : :class:`matplotlib.figure.Figure` - The figure the plot belongs to. Only with the matplotlib backend. - ax : :class:`matplotlib.axes.Axes` - The axes the plot belongs to. Only with the matplotlib backend. - - Examples - -------- - >>> import matplotlib - >>> G = graphs.Logo() - >>> fig, ax = G.plot() - - """ - if not hasattr(G, 'coords'): - raise AttributeError('Graph has no coordinate set. ' - 'Please run G.set_coordinates() first.') - if (G.coords.ndim != 2) or (G.coords.shape[1] not in [2, 3]): - raise AttributeError('Coordinates should be in 2D or 3D space.') - - if edges is None: - edges = G.Ne < 10e3 - - if backend is None: - backend = BACKEND - - if vertex_size is None: - vertex_size = G.plotting['vertex_size'] - - if title is None: - title = G.__repr__(limit=4) - - G = _handle_directed(G) - - if backend == 'pyqtgraph': - _qtg_plot_graph(G, edges=edges, vertex_size=vertex_size, title=title) - elif backend == 'matplotlib': - return _plt_plot_signal(G, color=None, edges=edges, - size=vertex_size, highlight=[], - index=index, colorbar=False, limits=[0, 0], - title=title, ax=ax) - else: - raise ValueError('Unknown backend {}.'.format(backend)) - - def _qtg_plot_graph(G, edges, vertex_size, title): qtg, gl, QtGui = _import_qtg() @@ -354,8 +284,8 @@ def _plt_plot_filter(filters, n, eigenvalues, sum, ax, **kwargs): ax.set_ylabel(r'$\hat{g}(\lambda)$: filter response') -def _plot_signal(G, color, size, highlight, edges, index, colorbar, - limits, ax, title, backend): +def _plot_graph(G, color, size, highlight, edges, index, colorbar, + limits, ax, title, backend): r"""Plot a graph with signals as color or vertex size. Parameters @@ -410,7 +340,7 @@ def _plot_signal(G, color, size, highlight, edges, index, colorbar, >>> import matplotlib >>> graph = graphs.Sensor(seed=42) >>> signal = np.random.RandomState(42).normal(size=graph.n_nodes) - >>> fig, ax = graph.plot_signal(color=signal, size=graph.dw) + >>> fig, ax = graph.plot(color=signal, size=graph.dw) """ if not hasattr(G, 'coords'): @@ -420,8 +350,11 @@ def _plot_signal(G, color, size, highlight, edges, index, colorbar, if G.coords.ndim != 1 and check_2d_3d: raise AttributeError('Coordinates should be in 1D, 2D or 3D space.') - mpl, _ = _import_plt() - if color is None or mpl.colors.is_color_like(color): + if backend is None: + backend = BACKEND + + if color is None or (backend == 'matplotlib' and + _import_plt()[0].colors.is_color_like(color)): limits = [0, 0] colorbar = False else: @@ -455,25 +388,25 @@ def _plot_signal(G, color, size, highlight, edges, index, colorbar, if title is None: title = G.__repr__(limit=4) - if backend is None: - backend = BACKEND - G = _handle_directed(G) if backend == 'pyqtgraph': - _qtg_plot_signal(G, signal=color, vertex_size=size, edges=edges, - limits=limits, title=title) + if color is None: + _qtg_plot_graph(G, edges=edges, vertex_size=size, title=title) + else: + _qtg_plot_signal(G, signal=color, vertex_size=size, edges=edges, + limits=limits, title=title) elif backend == 'matplotlib': - return _plt_plot_signal(G, color=color, size=size, highlight=highlight, - edges=edges, index=index, colorbar=colorbar, - limits=limits, ax=ax, title=title) + return _plt_plot_graph(G, color=color, size=size, highlight=highlight, + edges=edges, index=index, colorbar=colorbar, + limits=limits, ax=ax, title=title) else: raise ValueError('Unknown backend {}.'.format(backend)) @_plt_handle_figure -def _plt_plot_signal(G, color, size, highlight, edges, index, colorbar, - limits, ax): +def _plt_plot_graph(G, color, size, highlight, edges, index, colorbar, + limits, ax): if edges: diff --git a/pygsp/tests/test_plotting.py b/pygsp/tests/test_plotting.py index 45bbdb46..2e80c842 100644 --- a/pygsp/tests/test_plotting.py +++ b/pygsp/tests/test_plotting.py @@ -78,17 +78,17 @@ def test_plot_graphs(self): G.plot(backend='pyqtgraph') G.plot(backend='matplotlib') - G.plot_signal(signal, backend='pyqtgraph') - G.plot_signal(signal, backend='matplotlib') + G.plot(signal, backend='pyqtgraph') + G.plot(signal, backend='matplotlib') plotting.close_all() def test_highlight(self): def test(G): s = np.arange(G.N) - G.plot_signal(s, backend='matplotlib', highlight=0) - G.plot_signal(s, backend='matplotlib', highlight=[0]) - G.plot_signal(s, backend='matplotlib', highlight=[0, 1]) + G.plot(s, backend='matplotlib', highlight=0) + G.plot(s, backend='matplotlib', highlight=[0]) + G.plot(s, backend='matplotlib', highlight=[0, 1]) # Test for 1, 2, and 3D graphs. G = graphs.Ring(10) @@ -113,17 +113,19 @@ def test(G): def test_signals(self): """Test the different kind of parameters that can be passed.""" G = graphs.Sensor() - G.plot_signal() - G.plot_signal(G.dw) - G.plot_signal(G.dw, list(G.dw)) - G.plot_signal(list(G.dw), G.dw) - G.plot_signal(G.dw[:, np.newaxis], G.dw[np.newaxis, :]) - G.plot_signal('r', 100) - G.plot_signal((0.5, 0.5, 0.5, 0.5)) - self.assertRaises(ValueError, G.plot_signal, 10) - self.assertRaises(ValueError, G.plot_signal, (0.5, 0.5)) - self.assertRaises(ValueError, G.plot_signal, size=[2, 3, 4, 5]) - self.assertRaises(ValueError, G.plot_signal, size=[G.dw, G.dw]) + G.plot() + G.plot(G.dw) + G.plot(G.dw, list(G.dw)) + G.plot(list(G.dw), G.dw) + G.plot(G.dw[:, np.newaxis], G.dw[np.newaxis, :]) + G.plot('r', 100) + G.plot((0.5, 0.5, 0.5, 0.5)) + self.assertRaises(ValueError, G.plot, 'r', backend='pyqtgraph') + self.assertRaises(ValueError, G.plot, 3*(.5), backend='pyqtgraph') + self.assertRaises(ValueError, G.plot, 10) + self.assertRaises(ValueError, G.plot, (0.5, 0.5)) + self.assertRaises(ValueError, G.plot, size=[2, 3, 4, 5]) + self.assertRaises(ValueError, G.plot, size=[G.dw, G.dw]) suite = unittest.TestLoader().loadTestsFromTestCase(TestCase)