From 85e411c48a4260978345d867b6fb1590eab6611d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 16 Apr 2026 18:47:15 +0200 Subject: [PATCH 01/11] Add code example for formating text as paragraph --- examples/gallery/embellishments/paragraph.py | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 examples/gallery/embellishments/paragraph.py diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py new file mode 100755 index 00000000000..1c1074bf44a --- /dev/null +++ b/examples/gallery/embellishments/paragraph.py @@ -0,0 +1,37 @@ +""" +Paragraph +========= + +To plot longer text as one or several paragraphs the `pygmt.Figure.paragraph` +method can be used. The ``parwidth`` and ``linespacing`` parameters allow to +set the line length and line spacing of the paragraph, respectively.` Two +paragraphs are automatically seperated by a blank line. + +For specificy text formating see the gallery example +https://www.pygmt.org/latest/gallery/embellishments/text_formatting.html + +""" + +import pygmt + +fig = pygmt.Figure() +fig.basemap(region=[-5, 5, -5, 5], projection="X10c/10c", frame=True) + +fig.paragraph( + x=0, + y=0, + text=[ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ", + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + ], + parwidth="4.5c", + linespacing="12p", + font="10p,Helvetica-Bold,steelblue", + angle=45, + justify="MC", + alignment="center", + fill="lightgray", # font color ignored + pen="1p,gray10", # font color ignored +) + +fig.show() From 9839b8b8387cfcd82bbc1b1490866270ea944d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 16 Apr 2026 19:07:25 +0200 Subject: [PATCH 02/11] Remove execution permission --- examples/gallery/embellishments/paragraph.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 examples/gallery/embellishments/paragraph.py diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py old mode 100755 new mode 100644 From a9efead6b623f189be2b638c0b96d8314bb667fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Thu, 16 Apr 2026 23:56:31 +0200 Subject: [PATCH 03/11] Fix typos --- examples/gallery/embellishments/paragraph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index 1c1074bf44a..3894cd5b609 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -5,9 +5,9 @@ To plot longer text as one or several paragraphs the `pygmt.Figure.paragraph` method can be used. The ``parwidth`` and ``linespacing`` parameters allow to set the line length and line spacing of the paragraph, respectively.` Two -paragraphs are automatically seperated by a blank line. +paragraphs are automatically separated by a blank line. -For specificy text formating see the gallery example +For detailed text formatting see the gallery example https://www.pygmt.org/latest/gallery/embellishments/text_formatting.html """ From 8f7d1f57136d1aa6014bb6828c91421616450f59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 21:52:42 +0200 Subject: [PATCH 04/11] Add link to gallery example --- examples/gallery/embellishments/paragraph.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index 3894cd5b609..d9f7daece0f 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -3,13 +3,12 @@ ========= To plot longer text as one or several paragraphs the `pygmt.Figure.paragraph` -method can be used. The ``parwidth`` and ``linespacing`` parameters allow to -set the line length and line spacing of the paragraph, respectively.` Two -paragraphs are automatically separated by a blank line. - -For detailed text formatting see the gallery example -https://www.pygmt.org/latest/gallery/embellishments/text_formatting.html +method can be used. The ``parwidth`` and ``linespacing`` parameters allow to set +the line length and spacing of the paragraph, respectively.` Two paragraphs are +automatically separated by a blank line. +For details on text formatting see the gallery example +:doc:`Text formatting `. """ import pygmt From e0081b00243e10dfd96243d2901f614db9ba3c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Mon, 20 Apr 2026 22:00:13 +0200 Subject: [PATCH 05/11] Add seperator at code beginning --- examples/gallery/embellishments/paragraph.py | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index d9f7daece0f..5f104272ecd 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -11,6 +11,7 @@ :doc:`Text formatting `. """ +# %% import pygmt fig = pygmt.Figure() From e71117c333db1069f6bfa2973ac10fb4bcebe2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Tue, 21 Apr 2026 23:03:31 +0200 Subject: [PATCH 06/11] Fix method highlighting Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/paragraph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index 5f104272ecd..469e06844f3 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -2,7 +2,7 @@ Paragraph ========= -To plot longer text as one or several paragraphs the `pygmt.Figure.paragraph` +To plot longer text as one or several paragraphs the :meth:`pygmt.Figure.paragraph` method can be used. The ``parwidth`` and ``linespacing`` parameters allow to set the line length and spacing of the paragraph, respectively.` Two paragraphs are automatically separated by a blank line. From ecc9232e0443c6bb68e037c8dcb543c10fcd1604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Tue, 21 Apr 2026 23:12:00 +0200 Subject: [PATCH 07/11] Improve and extend intro text --- examples/gallery/embellishments/paragraph.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index 469e06844f3..24b37d97ce9 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -4,8 +4,13 @@ To plot longer text as one or several paragraphs the :meth:`pygmt.Figure.paragraph` method can be used. The ``parwidth`` and ``linespacing`` parameters allow to set -the line length and spacing of the paragraph, respectively.` Two paragraphs are -automatically separated by a blank line. +the line length and spacing of the paragraph, respectively.` The desired text can +be provided using two ways to indicate a new paragraph: + +(1) a single string separated by a blank line +(2) a list of strings + +During plotting the paragraphs are automatically separated by a blank line. For details on text formatting see the gallery example :doc:`Text formatting `. From ecdba41a076883e3e8bf008d12cf6de6ed5f0fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 23 Apr 2026 12:56:18 +0200 Subject: [PATCH 08/11] Improve title Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/paragraph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index 24b37d97ce9..74ac37d2ed1 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -1,6 +1,6 @@ """ -Paragraph -========= +Paragraphs of long text +======================= To plot longer text as one or several paragraphs the :meth:`pygmt.Figure.paragraph` method can be used. The ``parwidth`` and ``linespacing`` parameters allow to set From 9e179276efe39e838017c72c0357a7ecf4f773be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Thu, 23 Apr 2026 12:56:49 +0200 Subject: [PATCH 09/11] Improve formulations Co-authored-by: Dongdong Tian --- examples/gallery/embellishments/paragraph.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index 74ac37d2ed1..f81ef0ecfb6 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -2,9 +2,9 @@ Paragraphs of long text ======================= -To plot longer text as one or several paragraphs the :meth:`pygmt.Figure.paragraph` +To typeset long text as one or several paragraphs the :meth:`pygmt.Figure.paragraph` method can be used. The ``parwidth`` and ``linespacing`` parameters allow to set -the line length and spacing of the paragraph, respectively.` The desired text can +the width of the paragraph and line spacing, respectively. The desired text can be provided using two ways to indicate a new paragraph: (1) a single string separated by a blank line From 025baeb850e22a71882396baf4d6ca778d3859d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 26 Apr 2026 22:04:18 +0200 Subject: [PATCH 10/11] Add draft of PyGMT version of GMT example --- examples/gallery/embellishments/paragraph.py | 43 ++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index f81ef0ecfb6..ccba96f5839 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -19,24 +19,53 @@ # %% import pygmt +text = [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ", + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", +] + fig = pygmt.Figure() fig.basemap(region=[-5, 5, -5, 5], projection="X10c/10c", frame=True) fig.paragraph( + text=text, x=0, y=0, - text=[ - "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ", - "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", - ], parwidth="4.5c", linespacing="12p", - font="10p,Helvetica-Bold,steelblue", - angle=45, - justify="MC", alignment="center", + justify="MC", + angle=45, + font="10p,Helvetica-Bold,steelblue", fill="lightgray", # font color ignored pen="1p,gray10", # font color ignored ) fig.show() + + +# %% +text = [ + "@_It was the best of times, it was the worst of times@_, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- ", + "in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only", +] + +fig = pygmt.Figure() +fig.basemap(region=[-5, 5, -5, 5], projection="X15c/15c", frame=True) + +fig.paragraph( + text=text, + x=0, + y=0, + parwidth="12c", + linespacing="18p", + alignment="center", + justify="MC", + font="16p,Times-Roman,red", # should now work with fill + fill="lightblue", + pen="2p", + # S="8p/-8p/darkblue", # not supported yet + # C="8p+tc", # not supported yet +) + +fig.show() From fd044df115bf15e4f0743d6b800034aabdb636cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= Date: Sun, 26 Apr 2026 22:18:47 +0200 Subject: [PATCH 11/11] Add note regarding white space at end of strings for paragraph recognizion --- examples/gallery/embellishments/paragraph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/gallery/embellishments/paragraph.py b/examples/gallery/embellishments/paragraph.py index ccba96f5839..e29d2ec8345 100644 --- a/examples/gallery/embellishments/paragraph.py +++ b/examples/gallery/embellishments/paragraph.py @@ -8,7 +8,7 @@ be provided using two ways to indicate a new paragraph: (1) a single string separated by a blank line -(2) a list of strings +(2) a list of strings, whereby each string needs to end with a white space During plotting the paragraphs are automatically separated by a blank line.