Plotting¶
The pygsp.plotting
module implements functionality to plot PyGSP objects
with a pyqtgraph or matplotlib drawing backend (which can be controlled by the
BACKEND
constant or individually for each plotting call):
- graphs from
pygsp.graphs
withplot_graph()
,plot_spectrogram()
, andplot_signal()
, - filters from
pygsp.filters
withplot_filter()
.
-
pygsp.plotting.
BACKEND
¶ Indicates which drawing backend to use if none are provided to the plotting functions. Should be either ‘matplotlib’ or ‘pyqtgraph’. In general pyqtgraph is better for interactive exploration while matplotlib is better at generating figures to be included in papers or elsewhere.
-
pygsp.plotting.
plot
(O, **kwargs)[source]¶ Main plotting function.
This convenience function either calls
plot_graph()
orplot_filter()
given the type of the passed object. Parameters can be passed to those functions.Parameters: O : Graph, Filter
object to plot
Examples
>>> from pygsp import plotting >>> G = graphs.Logo() >>> plotting.plot(G)
-
pygsp.plotting.
plot_graph
(G, backend=None, **kwargs)[source]¶ Plot a graph or a list of graphs.
Parameters: G : Graph
Graph to plot.
show_edges : bool
True to draw edges, false to only draw vertices. Default True if less than 10,000 edges to draw. Note that drawing a large number of edges might be particularly slow.
backend: {‘matplotlib’, ‘pyqtgraph’}
Defines the drawing backend to use. Defaults to
BACKEND
.vertex_size : float
Size of circle representing each node.
plot_name : str
name of the plot
save_as : str
Whether to save the plot as save_as.png and save_as.pdf. Shown in a window if None (default). Only available with the matplotlib backend.
ax : matplotlib.axes
Axes where to draw the graph. Optional, created if not passed. Only available with the matplotlib backend.
Examples
>>> from pygsp import plotting >>> G = graphs.Logo() >>> plotting.plot_graph(G)
-
pygsp.plotting.
plot_signal
(G, signal, backend=None, **kwargs)[source]¶ Plot a signal on top of a graph.
Parameters: G : Graph
Graph to plot a signal on top.
signal : array of int
Signal to plot. Signal length should be equal to the number of nodes.
show_edges : bool
True to draw edges, false to only draw vertices. Default True if less than 10,000 edges to draw. Note that drawing a large number of edges might be particularly slow.
cp : list of int
NOT IMPLEMENTED. Camera position when plotting a 3D graph.
vertex_size : float
Size of circle representing each node.
highlight : iterable
List of indices of vertices to be highlighted. Useful to e.g. show where a filter was localized. Only available with the matplotlib backend.
colorbar : bool
Whether to plot a colorbar indicating the signal’s amplitude. Only available with the matplotlib backend.
limits : [vmin, vmax]
Maps colors from vmin to vmax. Defaults to signal minimum and maximum value. Only available with the matplotlib backend.
bar : boolean
NOT IMPLEMENTED. Signal values are displayed using colors when False, and bars when True (default False).
bar_width : int
NOT IMPLEMENTED. Width of the bar (default 1).
backend: {‘matplotlib’, ‘pyqtgraph’}
Defines the drawing backend to use. Defaults to
BACKEND
.plot_name : string
Name of the plot.
save_as : str
Whether to save the plot as save_as.png and save_as.pdf. Shown in a window if None (default). Only available with the matplotlib backend.
ax : matplotlib.axes
Axes where to draw the graph. Optional, created if not passed. Only available with the matplotlib backend.
Examples
>>> from pygsp import plotting >>> G = graphs.Grid2d(4) >>> signal = np.sin((np.arange(16) * 2*np.pi/16)) >>> plotting.plot_signal(G, signal)