Skip to content

Figure.colorbar: Add parameters label/unit/annot/tick/grid and more to set colorbar annotations/labels#4407

Open
seisman wants to merge 30 commits intomainfrom
colorbar/frame
Open

Figure.colorbar: Add parameters label/unit/annot/tick/grid and more to set colorbar annotations/labels#4407
seisman wants to merge 30 commits intomainfrom
colorbar/frame

Conversation

@seisman
Copy link
Member

@seisman seisman commented Feb 10, 2026

@seisman seisman added this to the 0.19.0 milestone Feb 10, 2026
@seisman seisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. high-priority labels Feb 10, 2026
@seisman seisman changed the base branch from main to class/frame-part1 February 10, 2026 15:54
@seisman seisman changed the title POC: Add the Frame/Axis class for setting frame and axes POC: Figure.colorbar: Pythonic way to set labels and annotations Feb 10, 2026
@seisman seisman changed the title POC: Figure.colorbar: Pythonic way to set labels and annotations Figure.colorbar: Add parameters label/unit/annot/tick/grid and more to set colorbar annotations/labels Feb 12, 2026
@seisman seisman marked this pull request as ready for review February 12, 2026 10:34
Base automatically changed from class/frame-part1 to main March 9, 2026 02:30
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Mar 9, 2026
@seisman
Copy link
Member Author

seisman commented Mar 9, 2026

Ping @GenericMappingTools/pygmt-maintainers for final reviews.

Comment on lines +321 to +334
unit
Set the label and unit for the colorbar. The label is placed along the colorbar
and the unit is placed at the end of the colorbar.
annot
tick
grid
Intervals for annotations, ticks, and gridlines. Refer to
:class:`pygmt.params.Axis` for more details on how these parameters work.
annot_prefix
annot_unit
annot_angle
The prefix, unit and angle for the annotations. The prefix is placed before the
annotation text; the unit is placed after the annotation text; and the angle is
the angle of the annotation text.
Copy link
Member

Choose a reason for hiding this comment

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

I think this is coming from to be consistent with GMT.
I personally find it confusing to call the y-label "unit" in case the frame is related to a colorbar. Thus we have here "annot_unit" for the unit opitionally added after the annotations, but "unit" in case the frame is related to a basemap.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm also debating which one to choose:

  • If we follow the convention used for the frame parameter, the names should be xlabel/ylabel/annot_prefix/annot_unit/annot_angle (x- and y-label mean labels of long and short dimensions of the colorbar)
  • If we follow the convention used by the GMT colorbar docs, the names should be label/unit/annot_prefix/annot_unit/annot_angle (label and unit are text strings displayed along the long and short dimensions of a colorbar; unit doesn't have to be a "unit"; unit and annnot_unit may be more confusing)

Or maybe we should call them xlabel/ylabel/annot_prefix/annot_suffix/annot_angle?

Copy link
Member

Choose a reason for hiding this comment

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

I'm also debating which one to choose:

  • If we follow the convention used for the frame parameter, the names should be xlabel/ylabel/annot_prefix/annot_unit/annot_angle (x- and y-label mean labels of long and short dimensions of the colorbar)

Hm. Maybe I am already confused by myself 🙃. But do you maybe mean xlabel/ylabel/prefix/unit/angle here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, I meant annot_prefix/annot_unit/annot_angle.

While prefix/unit/angle work well in the Axis class for the frame parameter, they're too ambiguous for colorbar annotations. In a colorbar context, it's unclear what prefix mean? I think adding the annot_ prefix can make the parameter's purpose clear to understand.

Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the changes in https://github.com/GenericMappingTools/pygmt-paper-figures/pull/39/changes, only label/unit/annot/tick/grid are used in the examples, and annot_prefix/annot_unit/annot_angle are not used.

So we just need to decide if we want xlabel/ylable or label/unit. We can discuss/implement annot_prefix/annot_unit/annot_angle in a separate PR instead.

Copy link
Member

Choose a reason for hiding this comment

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

I prefer xlabel / ylabel. @weiji14, @michaelgrund what do you think / prefer?

Copy link
Member Author

Choose a reason for hiding this comment

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

I also prefer xlabel/ylabel, so we have at least two votes in favor. We'll proceed with xlabel/ylabel unless any of @weiji14, @michaelgrund, @willschlitzer has strong objections.

Copy link
Member

@weiji14 weiji14 Mar 11, 2026

Choose a reason for hiding this comment

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

I somewhat prefer label/unit because it'll get confusing when you have a vertical colorbar (see elevation example in https://www.pygmt.org/v0.18.0/gallery/embellishments/colorbar.html), in which case xlabel (label) is on the 'y-axis' and ylabel (unit) is on the x-axis. But no strong opinions if we decide to go with xlabel/ylabel.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature final review call This PR requires final review and approval from a second reviewer high-priority

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants