Skip to content

Figure.histogram: Add parameters to annote bars and deprecate parameter 'annotate' - #4895

Open
seisman wants to merge 2 commits into
mainfrom
histogram/annot
Open

seisman wants to merge 2 commits into
mainfrom
histogram/annot

Conversation

@seisman

@seisman seisman commented Sep 16, 2026

Copy link
Copy Markdown
Member

This PR provides a Pythonic implementation for the -D option. The GMT CLI syntax is:

-D[+b][+f<font>][+o<offset>][+r]

This PR maps it to multiple parameters

  • annot
  • +b: annot_position
  • +f: annot_font
  • +o: annot_offset
  • +r: annot_orientation

The prefix annot is preferred so that it's more consistent with Figure.colorbar and Frame. This PR also deprecates the annotate parameter to annot.

Example:

import numpy as np
import pygmt
from pygmt.params import Axis, Frame

rng = np.random.default_rng(seed=100)
mean = 100  # mean of distribution
stddev = 25  # standard deviation of distribution
data = rng.normal(loc=mean, scale=stddev, size=521)


fig = pygmt.Figure()
fig.histogram(
    data=data,
    frame=True,
    series=10,
    fill="red3",
    pen="1p",
    annot=True,
    annot_position="top",
    annot_font="8p,blue",
    annot_orientation="vertical",
    # horizontal=True, 
)
fig.show()

@seisman seisman added this to the 0.20.0 milestone Sep 16, 2026
@seisman seisman added enhancement Improving an existing feature deprecation Deprecating a feature needs review This PR has higher priority and needs review. labels Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deprecation Deprecating a feature enhancement Improving an existing feature needs review This PR has higher priority and needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant