Alphabetical list Categories
text Render text
Call signature:

text(s, dx=0, dy=0)

Help text:

text(text) renders text at the current anchor point.
text(text, dx, dy) renders text displaced by the given number of points. Normally, positive dx is to the right and positive dy down, but the x- and y-axes rotate along with the angle set by the at command.
Text between underscore (_) and next space is set as subscript.
Text between hat (^) and next space is set as superscript. Matched parentheses, brackets, and quotes protect spaces. Additionally, tilde (~) can be used as a protected space inside sub- or superscripts.
Words can be /italicized/ or *boldfaced* with slashes and asterisks. “Words” in this context means a sequence of letters and/or numbers. Slashes and asterisks that do not form pairs around a word are not interpreted specially. As in TeX math, \, inserts a thin space, and \! inserts a thin negative space.

Examples of valid strings:

  "Distance (μm)" - Note unicode support
  "Coefficient *A*_1^2"
  "Coefficient *A*_{1^2}" - Nested subscript. Braces are eaten.
  "Coefficient *A*_{{1}}" - Nested subscript. Extra braces are not eaten.
  "e^-½/x/²/σ²" - Note the use of unicode superscripts for nesting.
  "e^-½(/x/^2 / σ^2)" - The parentheses protect the outer superscript, but terminates the superscript after σ, because it is not paired within that superscript.
  "/x/^{2}/2" - Braces help interpret end of superscript
  "frown^:\( or smile^:\)" - The backslashes prevent unwanted space protection.
  "frown^{:(} or smile^{:)}" - No backslashes needed because of braces.

See also at and align.

Example:

import qplot as qp

import numpy as np

qp.figure('text', 3, 3)

qp.font('Helvetica', 15)

qp.align('base', 'left')

qp.at(0, 1.3)

qp.ylim(0, 1.5)

qp.xlim(-.1, 1)

qp.text('sin(/x/) = (e^/ix/ – e^–/ix/) / 2')

qp.text('l’Hôpital', dy=30)

qp.text('*F* = /m/ *a*', dy=60)

qp.text('/a/_x^2 + /y/_{/k/_1}^3/2 ~ 2^{3^5} /b/_[2]^{\,\,{1}}', dy=90)

qp.text('e^–½\,(/x/² + /y/²)', dy=120)

qp.text('frown^{:(} or smile^{:)}', dy=150)

QPlot Documentation — (C) Daniel Wagenaar, 2014–2023