pygmt.Figure.paragraph

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

Typeset one or multiple paragraphs.

This method typesets one or multiple paragraphs of text at a given position. The text is flowed within a given paragraph width and with a specified line spacing, and 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.

The text string is typeset following the What You Type Is What You Get principle, meaning that the text is rendered exactly as it appears in the input string. This allows for precise control over the formatting of the text, including the use of multiple spaces and tabs. By default, a tab is replaced with four spaces, but this can be changed by setting the tab_width.

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.

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

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

  • pen (str | None, default: None) – Set the pen for the paragraph box [Default is "0.25p,black,solid"].

  • tab_width (int, default: 4) – Number of spaces used to expand tab characters in text when typesetting. Must be a non-negative integer. Use 0 to remove tab characters instead of replacing them with spaces.

  • blank_line (bool, default: False) – If True, use a blank line between paragraphs. [Default is False, i.e., no blank line between paragraphs.]

  • 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()