-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy pathmatrix.py
More file actions
26 lines (17 loc) · 762 Bytes
/
matrix.py
File metadata and controls
26 lines (17 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""This module provides implementation for a Matplotlib-specific matrix drawer."""
from igraph.drawing.baseclasses import AbstractDrawer
__all__ = ("MatplotlibMatrixDrawer",)
class MatplotlibMatrixDrawer(AbstractDrawer):
"""Matplotlib drawer object for matrices."""
def __init__(self, ax):
"""Constructs the drawer and associates it to the given Axes.
@param ax: the Axes on which we will draw
"""
self.context = ax
def draw(self, matrix, **kwds):
"""Draws the given Matrix in a matplotlib Axes.
@param matrix: the igraph.Matrix to plot.
Keyword arguments are passed to Axes.imshow.
"""
ax = self.context
ax.imshow(matrix.data, interpolation="nearest", **kwds)