API

chessplotlib.plot_board(ax: matplotlib.axes._axes.Axes, board: chess.Board, checkers: bool = True)[source]

Creates a board image on the specified axis.

Parameters
ax: plt.Axes

Axes to apply the board to.

board: chess.Board

Board object to plot.

checkers: bool, default=True

Whether or not to apply a checker pattern to the background.

Examples

>>> import chess
>>> from chessplotlib import plot_board
>>> import matplotlib.pyplot as plt
>>> board = chess.Board()
>>> ax = plt.gca()
>>> plot_board(ax, board)
>>> plt.show()
_images/starting_board.png
chessplotlib.plot_move(ax: matplotlib.axes._axes.Axes, board: chess.Board, move: chess.Move, alpha: float = 1.0, color: str = 'red', piece_alpha: float = 1.0, piece_color: str = 'black')[source]

Visualizes a move on top of a plotted board.

Parameters
ax: plt.Axes

Axes containing the state of the board in which the move with take place

move: chess.Move

Potential move represented with a chess.Move object

alpha: float, default=1.0

Alpha value for move visual

color: str, default=black

Color for move visual

Examples

>>> import chess
>>> from chessplotlib import plot_board, plot_move
>>> import matplotlib.pyplot as plt
>>> board = chess.Board()
>>> ax = plt.gca()
>>> plot_board(ax, board)
>>> plot_move(ax, board, "e2e4")
>>> plt.show()
_images/opening_move.png
chessplotlib.mark_square(ax: matplotlib.axes._axes.Axes, square: str)[source]

Highlights a square in red.

Parameters
ax: plt.Axes

Axes containing the state of the board

square: str

String name for square, (i.e. e1)

Examples

>>> import chess
>>> from chessplotlib import plot_board, mark_square
>>> import matplotlib.pyplot as plt
>>> board = chess.Board()
>>> ax = plt.gca()
>>> plot_board(ax, board)
>>> mark_square(ax, "e2")
>>> plt.show()
_images/starting_board_marked.png
chessplotlib.mark_move(ax: matplotlib.axes._axes.Axes, move: chess.Move)[source]

Marks the two squares used in a move

Parameters
ax: plt.Axes

Axes containing the state of the board

move: chess.Move

String name for square, (i.e. e1)