Skip to content

Figure.colorbar: Add position/length/width and more parameters to specify colorbar position and properties - #4048

Merged
seisman merged 30 commits into
mainfrom
refactor/colorbar
Jan 10, 2026
Merged

Figure.colorbar: Add position/length/width and more parameters to specify colorbar position and properties#4048
seisman merged 30 commits into
mainfrom
refactor/colorbar

Conversation

@seisman

@seismanseisman commented Aug 10, 2025

Copy link
Copy Markdown
Member
ModifiersPyGMTGMTGMT.jl
[g|j|J|n|x]<refpoint>[+j<justify>][+o<dx>[/<dy>]]position--
+w<length>[/<width>]]length/widthsizesize
[+e[b|f][<length>]]fg_triangle/bg_triangle/triangle_heighttrianglestriangles
[+h|v]oriention="horizontal" or "vertical"horizontal,verticalhorizontal
[+n|N[<txt>]]nan/nan_positionnannan
[+r]reversereverseGive a negative length to reverse the scale bar

References

Preview: https://pygmt-dev--4048.org.readthedocs.build/en/4048/api/generated/pygmt.Figure.colorbar.html#pygmt.Figure.colorbar

@yvonnefroehlichyvonnefroehlich left a comment

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.

I feel it would be good to add an alias for -S,

-S[+aangle][+c|n][+r][+s][+xlabel][+yunit]

as I realized that this flags allows to set x and y labels in case frame (-B) cannot be used, e.g., if equalsize (-L) is used.
I am wondering if adding an alias, e.g., appearance, using the old alias system still makes sense or if we should do this directly using the new alias system to introduce aliases for the single modifieres.

@seismanseisman added the enhancement Improving an existing feature label Sep 18, 2025
@seismanseisman added this to the 0.18.0 milestone Sep 18, 2025
@seisman
seisman changed the base branch from main to params/positionDecember 7, 2025 15:57
Base automatically changed from params/position to mainDecember 11, 2025 01:54
@seismanseisman changed the title WIP: Figure.colorbar: Refactor using the new alias systemFigure.colorbar: Refactor using the new alias systemDec 15, 2025
@seismanseisman added the needs review This PR has higher priority and needs review. label Dec 16, 2025
Comment threadpygmt/src/colorbar.py Outdated
@seisman
seismanforce-pushed the refactor/colorbar branch 2 times, most recently from 0607414 to c892202CompareDecember 19, 2025 12:23
@seismanseisman changed the title Figure.colorbar: Refactor using the new alias systemFigure.colorbar: Add position/length/width and more parameters to specify colorbar positiona and propertiesDec 19, 2025
@seismanseisman mentioned this pull request Dec 29, 2025
30 tasks
@seisman
seisman marked this pull request as ready for review December 31, 2025 00:28
Comment threadpygmt/src/colorbar.py Outdated
Comment on lines +101 to +102
nan_rectangle: bool | str = False,
nan_rectangle_position: Literal["start", "end"] | None = None,

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Perhaps shorter names nan and nan_position are better?

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.

I think nan_position (or nan_side) is fine.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I've renamed them to nan/nan_position in 57f8c39.

Comment threadpygmt/src/colorbar.py Outdated
Comment on lines +103 to +104
sidebar_triangles: bool | Literal["foreground", "background"] = False,
sidebar_triangles_height: float | None = None,

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

The names are also a little too long. It's also unclear what sidebar means. What about fg_triangle/bg_triangle and triangle_height?

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.

Agree that these names are a bit long. fg_trinagle and bg_triangle would mean we have two parameters, correct? Maybe cb_triangles; "cb" for "colorbar", which is clearer as "sidebar"?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I feel cb_triangles is a bad name for two reasons:

  • It's unclear what cb stands for
  • This is a parameter for Figure.colorbar, so the prefix cb (short for colorbar) is a little duplicate

@seismanseismanJan 7, 2026

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

What about fgcolor/bgcolor, which fgcolor=True/bgcolor=True means draw a triangle for foreground/background color.

fgcolor/bgcolor are also used in the Pattern class, but it takes a color, not a boolean value.

Edit: fgcolor/bgcolor may be good names, but it would be unclear what triangle_height means.

So, I still prefer fg_triangle/bg_triangle/triangle_height.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

I've renamed them to fg_triangle/bg_triangle/triangle_height in 405383c.

Comment threadpygmt/src/colorbar.py Outdated
Comment threadpygmt/src/colorbar.py Outdated
Comment threadpygmt/src/colorbar.py Outdated
Comment threadpygmt/src/colorbar.py Outdated
@seismanseisman 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 Jan 8, 2026
Comment threadpygmt/src/colorbar.py Outdated
Comment threadpygmt/src/colorbar.py Outdated
Comment threadpygmt/src/colorbar.py Outdated
Comment threadpygmt/src/colorbar.py Outdated
Comment threadpygmt/src/colorbar.py Outdated
Comment threadpygmt/tests/test_colorbar.py Outdated
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
@seisman

Copy link
Copy Markdown
MemberAuthor

/format

@seismanseisman removed the final review call This PR requires final review and approval from a second reviewer label Jan 10, 2026
@seisman
seisman merged commit 076de50 into mainJan 10, 2026
23 checks passed
@seisman
seisman deleted the refactor/colorbar branch January 10, 2026 06:49
seisman added a commit that referenced this pull request Jan 10, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementImproving an existing feature

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants

@seisman@michaelgrund@yvonnefroehlich