shnitsel.vis.plot.common#

Functions#

outlabel(ax, label)

Adds a label just outside the top left corner of a plot (outside the axes).

inlabel(ax, label)

Helper function to add a text label inside of the axes to ax.

figax([fig, ax])

Create figure and axes-object if an axes-object is not supplied.

extrude(x, y, xmin, xmax, ymin, ymax)

Calculate the endpoint of extrusion of the point (x,y) from point (0,0) until it intersects either x or y boundary.

mpl_imshow_png(ax, png, **imshow_kws)

Helper function to display an image from a bytestream input, e.g. an encoded png in axes.

mpl_svg_into_axes(ax, svg_string[, chord_length])

Helper function to plot an SVG image represented by its str representation into

Module Contents#

outlabel(ax, label)#

Adds a label just outside the top left corner of a plot (outside the axes).

Parameters:
  • ax (Axes) – The Axes object to annotate

  • label (str) – The label to be added

Return type:

The matplotlib.text.Text instance created

inlabel(ax, label)#

Helper function to add a text label inside of the axes to ax.

Parameters:
  • ax (Axes) – The Axes object to annotate

  • label (str) – The label to be added

Return type:

The matplotlib.text.Annotation instance created representing the inserted label.

figax(fig=None, ax=None)#

Create figure and axes-object if an axes-object is not supplied.

Parameters:
  • fig (Figure | SubFigure | None, optional) – The optional figure to use as a basis for ax if the latter is not provided. Defaults to None.

  • ax (Axes | None, optional) – The axes object provided. Will be used to populate fig if provided.. Defaults to None.

Returns:

A complete combination of figure and axes.

Return type:

tuple[Figure | SubFigure, Axes]

extrude(x, y, xmin, xmax, ymin, ymax)#

Calculate the endpoint of extrusion of the point (x,y) from point (0,0) until it intersects either x or y boundary.

Parameters:
  • x (float) – Coordinates of the vector to extrapolate

  • y (float) – Coordinates of the vector to extrapolate

  • xmin (float) – Bounds of the rectangle to the edge of which the ray should be extended

  • xmax (float) – Bounds of the rectangle to the edge of which the ray should be extended

  • ymin (float) – Bounds of the rectangle to the edge of which the ray should be extended

  • ymax (float) – Bounds of the rectangle to the edge of which the ray should be extended

Returns:

The position at the end of the extrusion, where the origin-ray through (x,y) intersects the boundary of the axes.

Return type:

tuple[float, float]

mpl_imshow_png(ax, png, **imshow_kws)#

Helper function to display an image from a bytestream input, e.g. an encoded png in axes.

Removes axes labels from ax.

Parameters:
  • ax (Axes) – The Axes object into which to plot

  • png (bytes) – The bytestream data of the image to plot

Return type:

AxesImage, as returned by ax.imshow

mpl_svg_into_axes(ax, svg_string, chord_length=0.01)#

Helper function to plot an SVG image represented by its str representation into provided Axes.

Used to plot SVG graphics into a set of axes instead of a pixelated PNG.

Parameters:
  • ax (Axes) – The Axes object into which to plot

  • svg_string (str) – The bytestream data of the image to plot

  • chord_length (float) – Length of cords of bezier curves to be drawn. Defaults to 1e-2.

  • optional (float) – Length of cords of bezier curves to be drawn. Defaults to 1e-2.

Return type:

Axes, after the plotting of