Skip to content

Figure.legend: Fix incorrect docstrings#4753

Merged
seisman merged 2 commits into
mainfrom
legend/doc
Jul 23, 2026
Merged

Figure.legend: Fix incorrect docstrings#4753
seisman merged 2 commits into
mainfrom
legend/doc

Conversation

@seisman

@seisman seisman commented Jul 23, 2026

Copy link
Copy Markdown
Member

No description provided.

@seisman seisman added this to the 0.20.0 milestone Jul 23, 2026
@seisman seisman added documentation Improvements or additions to documentation skip-changelog Skip adding Pull Request to changelog final review call This PR requires final review and approval from a second reviewer labels Jul 23, 2026
Comment thread pygmt/src/legend.py
width. If height is given as percentage then height is recomputed as that
fraction of the legend width (not plot height).
**Note:** Currently, the automatic height calculation only works when legend

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is what the GMT documentation says (https://docs.generic-mapping-tools.org/dev/legend.html):

If +w is not given then we compute the width within the Postscript code. Currently, this is only possible if just legend codes D, H, L, S, or V are used and that the number of symbol columns (N) is 1. If height is zero or not given then we estimate height based the expected vertical extent of the items to be placed.

# :meth:`pygmt.Figure.vlines` as well as :meth:`pygmt.Figure.histogram`. Therefore the
# ``label`` parameter has to be specified to state the desired text for the legend entry
# (white spaces are supported). Here, we use :meth:`pygmt.Figure.plot`, exemplary. By
# default, the legend is placed in the Upper Right corner with an offset of 0.1

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default offset is 0.2 c not 0.1 cm. I feel it's better not to mention such details in a tutorial.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as the defaults may change over time, and we often miss to update all occurrences, especially in the examples.

Comment thread pygmt/src/legend.py Outdated
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
@seisman
seisman merged commit 2817e2e into main Jul 23, 2026
22 checks passed
@seisman
seisman deleted the legend/doc branch July 23, 2026 09:31
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants