whitecanvas package

Subpackages

Submodules

whitecanvas.core module

whitecanvas.core.grid(nrows: int = 1, ncols: int = 1, *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasGrid[source]

Create a canvas grid with uniform cell sizes.

Parameters
  • nrows (int, optional) – Number of rows, by default 1

  • ncols (int, optional) – Number of columns, by default 1

  • link_x (bool, optional) – Whether to link x axes, by default False

  • link_y (bool, optional) – Whether to link y axes, by default False

  • backend (Backend or str, optional) – Backend name.

Returns

Grid of empty canvases.

Return type

CanvasGrid

whitecanvas.core.grid_nonuniform(heights: list[int], widths: list[int], *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasGrid[source]
whitecanvas.core.hgrid(ncols: int = 1, *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasHGrid[source]
whitecanvas.core.hgrid_nonuniform(widths: list[int], *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasHGrid[source]
whitecanvas.core.new_canvas(backend: whitecanvas.backend._instance.Backend | str | None = None, *, size: tuple[int, int] | None = None, palette: Optional[Union[str, cmap._colormap.Colormap, Any]] = None) whitecanvas.canvas._grid.SingleCanvas[source]

Create a new canvas with a single cell.

whitecanvas.core.vgrid(nrows: int = 1, *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasVGrid[source]
whitecanvas.core.vgrid_nonuniform(heights: list[int], *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasVGrid[source]
whitecanvas.core.wrap_canvas(obj: Any, palette=None) whitecanvas.canvas._base.Canvas[source]

Wrap a backend object into a whitecanvas Canvas.

>>> import matplotlib.pyplot as plt
>>> canvas = wrap_canvas(plt.gca())

Module contents

class whitecanvas.Canvas(backend: str | None = None, *, palette: Optional[Union[str, cmap._colormap.Colormap, Any]] = None)[source]

Bases: whitecanvas.canvas._base.CanvasBase

classmethod from_backend(obj: protocols.CanvasProtocol, *, palette: ColormapType | None = None, backend: str | None = None) Self[source]

Create a canvas object from a backend object.

class whitecanvas.CanvasGrid(heights: list[int], widths: list[int], *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None)[source]

Bases: object

add_canvas(row: int, col: int, rowspan: int = 1, colspan: int = 1, palette: str | None = None) whitecanvas.canvas._base.Canvas[source]

Add a canvas to the grid at the given position

property background_color: numpy.ndarray[Any, numpy.dtype[numpy.floating]]

Background color of the canvas.

iter_add_canvas(**kwargs) Iterator[whitecanvas.canvas._base.Canvas][source]
iter_canvas() Iterator[tuple[tuple[int, int], whitecanvas.canvas._base.Canvas]][source]
screenshot() numpy.ndarray[Any, numpy.dtype[numpy.uint8]][source]

Return a screenshot of the grid.

property shape: tuple[int, int]

The (row, col) shape of the grid

show(block=False) None[source]

Show the grid.

property size: tuple[float, float]
classmethod uniform(nrows: int = 1, ncols: int = 1, *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasGrid[source]

Create a canvas grid with uniform row and column sizes.

Parameters
  • nrows (int) – The number of rows in the grid.

  • ncols (int) – The number of columns in the grid.

  • backend (backend-like, optional) – The backend to use for the grid.

property x_linked: bool

Whether the x-axis of all canvases are linked.

property y_linked: bool

Whether the y-axis of all canvases are linked.

whitecanvas.grid(nrows: int = 1, ncols: int = 1, *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasGrid[source]

Create a canvas grid with uniform cell sizes.

Parameters
  • nrows (int, optional) – Number of rows, by default 1

  • ncols (int, optional) – Number of columns, by default 1

  • link_x (bool, optional) – Whether to link x axes, by default False

  • link_y (bool, optional) – Whether to link y axes, by default False

  • backend (Backend or str, optional) – Backend name.

Returns

Grid of empty canvases.

Return type

CanvasGrid

whitecanvas.grid_nonuniform(heights: list[int], widths: list[int], *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasGrid[source]
whitecanvas.hgrid(ncols: int = 1, *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasHGrid[source]
whitecanvas.hgrid_nonuniform(widths: list[int], *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasHGrid[source]
whitecanvas.new_canvas(backend: whitecanvas.backend._instance.Backend | str | None = None, *, size: tuple[int, int] | None = None, palette: Optional[Union[str, cmap._colormap.Colormap, Any]] = None) whitecanvas.canvas._grid.SingleCanvas[source]

Create a new canvas with a single cell.

whitecanvas.vgrid(nrows: int = 1, *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasVGrid[source]
whitecanvas.vgrid_nonuniform(heights: list[int], *, link_x: bool = False, link_y: bool = False, backend: whitecanvas.backend._instance.Backend | str | None = None) whitecanvas.canvas._grid.CanvasVGrid[source]
whitecanvas.wrap_canvas(obj: Any, palette=None) whitecanvas.canvas._base.Canvas[source]

Wrap a backend object into a whitecanvas Canvas.

>>> import matplotlib.pyplot as plt
>>> canvas = wrap_canvas(plt.gca())