pygmt.Figure.paragraph

Figure.paragraph(x, y, text, parwidth, linespacing, font=None, angle=None, justify=None, fill=None, pen=None, alignment='left', verbose=False, panel=False, transparency=None)

Typeset one or multiple paragraphs.

This method typesets one or multiple paragraphs of text at a given position on the figure. The text is flowed within a given paragraph width and with a specified line spacing. The text can be aligned left, center, right, or justified.

Multiple paragraphs can be provided as a sequence of strings, where each string represents a separate paragraph, or as a single string with a blank line (\n\n) separating the paragraphs.

Full GMT docs at https://docs.generic-mapping-tools.org/6.6/text.html.

Parameters:
  • x/y – The x, y coordinates of the paragraph.

  • text (str | Sequence[str]) – The paragraph text to typeset. If a sequence of strings is provided, each string is treated as a separate paragraph.

  • parwidth (float | str) – The width of the paragraph.

  • linespacing (float | str) – The spacing between lines.

  • font (str | None, default: None) – The font of the text.

  • angle (float | None, default: None) – The angle of the text.

  • justify (Literal['TL', 'TC', 'TR', 'ML', 'MC', 'MR', 'BL', 'BC', 'BR'] | None, default: None) – Set the alignment of the block of text, relative to the given x, y position. Choose a 2-character justification code.

  • fill (str | None, default: None) – Set color for filling the paragraph box [Default is no fill].

  • pen (str | None, default: None) – Set the pen used to draw a rectangle around the paragraph [Default is "0.25p,black,solid"].

  • alignment (Literal['left', 'center', 'right', 'justified'], default: 'left') – Set the alignment of the text. Valid values are "left", "center", "right", and "justified".

  • verbose (bool or str) – Select verbosity level [Full usage].

  • panel (int | Sequence[int] | bool, default: False) –

    Select a specific subplot panel. Only allowed when used in Figure.subplot mode.

    • True to advance to the next panel in the selected order.

    • index to specify the index of the desired panel.

    • (row, col) to specify the row and column of the desired panel.

    The panel order is determined by the Figure.subplot method. row, col and index all start at 0.

  • transparency (float) – Set transparency level, in [0-100] percent range [Default is 0, i.e., opaque]. Only visible when PDF or raster format output is selected. Only the PNG format selection adds a transparency layer in the image (for further processing).

Examples

>>> import pygmt
>>>
>>> fig = pygmt.Figure()
>>> fig.basemap(region=[0, 10, 0, 10], projection="X10c/10c", frame=True)
>>> fig.paragraph(
...     x=4,
...     y=4,
...     text="This is a long paragraph. " * 10,
...     parwidth="5c",
...     linespacing="12p",
...     font="12p",
... )
>>> fig.show()