This chapter documents the two classes Rayon uses to put text labels on visualizations. Labelers apply text labels to the drawing surface. Labeled markers marry labelers to markers, which can be used as labeled points, tickmarks, and other visual elements.

Specifying Text Properties

The following parameters may be used by the rendering backend to choose an appropriate font when drawing a label. The rendering backend may not honor these requests. At the time of this writing, only font size is honored in both backends. The wxPython backend honors font family, style and weight, while the Cairo backend does not.


Font size may be specified as a number (which is taken to be a point size), or one of the following strings specifying a relative size:

  • small
  • normal
  • large
  • x-large
  • xx-large.

These are identical to the absolute size specifications described in <http://www.w3.org/TR/CSS2/fonts.html#font-size-props>; however, they specify relative, not absolute, sizes.


Font family is the string default (leaving font choice exclusively to the backend) or one of the strings specified in http://www.w3.org/TR/CSS2/fonts.html#generic-font-families , specifically:

  • serif
  • sans-serif
  • cursive
  • fantasy
  • monospace


Font style is one of the strings specified in http://www.w3.org/TR/CSS2/fonts.html#font-styling, specifically:

  • normal
  • oblique
  • italic


Font weight is one of the strings or integer weights specified in http://www.w3.org/TR/CSS2/fonts.html#font-boldness, specifically:

  • normal
  • bold
  • 100
  • 200
  • 300
  • 400
  • 500
  • 600
  • 700
  • 800
  • 900

Integer weights may be specified as integers or strings. The bolder and lighter keywords are not implemented in Rayon.


The horizontal alignment of the label may be one of the words left, center, or right.


The vertical alignment of the label may be one of the words top, center, or bottom.


The color of the label text is specified as described in Specifying Colors.


The color of the label background is specified as described in Specifying Colors.


The angle of the text is measured counterclockwise in degrees from horizontal, left to right. Both horizontal and vertical alignment are computed relative to a bounding box rotated by the amount specified in angle.

border (border_left, border_right, border_top, border_bottom)

The border of the text label is a text line specification (see Specifying Line Styles) describing the line to use to draw border lines around the label text’s bounding box. border_left, border_right, border_top and border_bottom specify lines that will only be drawn on the left, right, top and bottom edges of the box, respectively. If border is specified, the other border_ arguments will be ignored.


A labeler is a Rayon object that draws text; that text is a label. Labelers are created using the new_labeler method.

Labeled Markers

A labeled marker draws both a text label and a mark at a point. A labeled marker contains both a marker and labeler, plus information on how to draw them relative to each other.

Labeled markers are created using the new_labeled_marker method.