Skip to content

Commit 50277b3

Browse files
authored
Merge pull request #22 from epfl-lts2/plotting
Plotting improvements
2 parents 361f025 + f8c221d commit 50277b3

File tree

9 files changed

+194
-194
lines changed

9 files changed

+194
-194
lines changed

doc/history.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
History
33
=======
44

5+
0.6.0 (2018-03-xx)
6+
------------------
7+
8+
The plotting interface was updated to be more user-friendly. First, the
9+
documentation is now shown for filters.plot(), G.plot(), and co. Second, the
10+
API in the plotting library has been deprecated. That module is now mostly for
11+
implementation only. Finally, the following parameter names were changed:
12+
* plot_name => title
13+
* plot_eigenvalues => eigenvalues
14+
* show_sum => sum
15+
* show_edges => edges
16+
* npoints => n
17+
* save_as => save
18+
519
0.5.1 (2017-12-15)
620
------------------
721

doc/tutorials/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ let's define and plot that low-pass filter:
193193
>>> g = filters.Filter(G, g)
194194
>>>
195195
>>> fig, ax = plt.subplots()
196-
>>> g.plot(plot_eigenvalues=True, ax=ax)
196+
>>> g.plot(eigenvalues=True, ax=ax)
197197
>>> _ = ax.set_title('Filter frequency response')
198198

199199
The filter is plotted along all the spectrum of the graph. The black crosses

pygsp/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,20 @@
3030

3131
_utils.import_modules(__all__[::-1], 'pygsp', 'pygsp')
3232

33+
# Users only call the plot methods from the objects.
34+
# It's thus more convenient for them to have the doc there.
35+
# But it's more convenient for developers to have the doc alongside the code.
36+
try:
37+
filters.Filter.plot.__doc__ = plotting._plot_filter.__doc__
38+
graphs.Graph.plot.__doc__ = plotting._plot_graph.__doc__
39+
graphs.Graph.plot_signal.__doc__ = plotting._plot_signal.__doc__
40+
graphs.Graph.plot_spectrogram.__doc__ = plotting._plot_spectrogram.__doc__
41+
except AttributeError:
42+
# For Python 2.7.
43+
filters.Filter.plot.__func__.__doc__ = plotting._plot_filter.__doc__
44+
graphs.Graph.plot.__func__.__doc__ = plotting._plot_graph.__doc__
45+
graphs.Graph.plot_signal.__func__.__doc__ = plotting._plot_signal.__doc__
46+
graphs.Graph.plot_spectrogram.__func__.__doc__ = plotting._plot_spectrogram.__doc__
47+
3348
__version__ = '0.5.1'
3449
__release_date__ = '2017-12-15'

pygsp/filters/filter.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,9 @@ def can_dual_func(g, n, x):
497497

498498
return Filter(self.G, kernels)
499499

500-
def plot(self, **kwargs):
501-
r"""Plot the filter bank's frequency response.
502-
503-
See :func:`pygsp.plotting.plot_filter`.
504-
"""
505-
from pygsp import plotting
506-
plotting.plot_filter(self, **kwargs)
500+
def plot(self, n=500, eigenvalues=None, sum=None, title='', save=None,
501+
ax=None, **kwargs):
502+
r"""Docstring overloaded at import time."""
503+
from pygsp.plotting import _plot_filter
504+
_plot_filter(self, n=n, eigenvalues=eigenvalues, sum=sum, title=title,
505+
save=save, ax=ax, **kwargs)

pygsp/graphs/airfoil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Airfoil(Graph):
1616
>>> G = graphs.Airfoil()
1717
>>> fig, axes = plt.subplots(1, 2)
1818
>>> _ = axes[0].spy(G.W, markersize=0.5)
19-
>>> G.plot(show_edges=True, ax=axes[1])
19+
>>> G.plot(edges=True, ax=axes[1])
2020
2121
"""
2222

pygsp/graphs/graph.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -658,29 +658,26 @@ def modulate(self, f, k):
658658
fm *= np.sqrt(self.N)
659659
return fm
660660

661-
def plot(self, **kwargs):
662-
r"""Plot the graph.
663-
664-
See :func:`pygsp.plotting.plot_graph`.
665-
"""
666-
from pygsp import plotting
667-
plotting.plot_graph(self, **kwargs)
668-
669-
def plot_signal(self, signal, **kwargs):
670-
r"""Plot a signal on that graph.
671-
672-
See :func:`pygsp.plotting.plot_signal`.
673-
"""
674-
from pygsp import plotting
675-
plotting.plot_signal(self, signal, **kwargs)
676-
677-
def plot_spectrogram(self, **kwargs):
678-
r"""Plot the graph's spectrogram.
679-
680-
See :func:`pygsp.plotting.plot_spectrogram`.
681-
"""
682-
from pygsp import plotting
683-
plotting.plot_spectrogram(self, **kwargs)
661+
def plot(self, edges=None, backend=None, vertex_size=None, title=None,
662+
save=None, ax=None):
663+
r"""Docstring overloaded at import time."""
664+
from pygsp.plotting import _plot_graph
665+
_plot_graph(self, edges=edges, backend=backend,
666+
vertex_size=vertex_size, title=title, save=save, ax=ax)
667+
668+
def plot_signal(self, signal, edges=None, vertex_size=None, highlight=[],
669+
colorbar=True, limits=None, backend=None, title=None,
670+
save=None, ax=None):
671+
r"""Docstring overloaded at import time."""
672+
from pygsp.plotting import _plot_signal
673+
_plot_signal(self, signal=signal, edges=edges, vertex_size=vertex_size,
674+
highlight=highlight, colorbar=colorbar, limits=limits,
675+
backend=backend, title=title, save=save, ax=ax)
676+
677+
def plot_spectrogram(self, node_idx=None):
678+
r"""Docstring overloaded at import time."""
679+
from pygsp.plotting import _plot_spectrogram
680+
_plot_spectrogram(self, node_idx=node_idx)
684681

685682
def _fruchterman_reingold_layout(self, dim=2, k=None, pos=None, fixed=[],
686683
iterations=50, scale=1.0, center=None,

pygsp/graphs/nngraphs/twomoons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class TwoMoons(NNGraph):
4040
>>> G = graphs.TwoMoons()
4141
>>> fig, axes = plt.subplots(1, 2)
4242
>>> _ = axes[0].spy(G.W, markersize=0.5)
43-
>>> G.plot(show_edges=True, ax=axes[1])
43+
>>> G.plot(edges=True, ax=axes[1])
4444
4545
"""
4646

0 commit comments

Comments
 (0)