Skip to content

docs: add section on Pint and Matplotlib axis labelling integration#116

Open
Forma-Damian wants to merge 3 commits into
habemus-python:mainfrom
Forma-Damian:feature/pint_matplotlib_integration
Open

docs: add section on Pint and Matplotlib axis labelling integration#116
Forma-Damian wants to merge 3 commits into
habemus-python:mainfrom
Forma-Damian:feature/pint_matplotlib_integration

Conversation

@Forma-Damian

Copy link
Copy Markdown

Closes #61

This PR introduces a new section to the handbook demonstrating how to use Pint with Matplotlib.

Features included in the single-page visualization:

  • Demonstration of shortening units using ureg.formatter.default_format = "~P".
  • Combining custom user labels with automatic unit extraction.
  • Adapting to journal guidelines (demonstrated using parentheses (m)).
  • Showing comparison between automatic Pint axis labelling and semi-manual approach.

@slayoo slayoo requested a review from orzel320 June 8, 2026 16:06
@slayoo

slayoo commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🚀 reviewers: @j-parszutowicz & @orzel320

@j-parszutowicz j-parszutowicz left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The section fits the assigned topic, clearly explaining the benefits of automating labels. The length is optimal and the core concept is easy to grasp for beginners. Here is the first half of a checklist:

  • Topic match: Perfect. It directly addresses the issue of automating Matplotlib labels with Pint.

  • Screenshot:

Image Image
  • Page limit: Looks good, fits nicely within the 1-page target.

  • Understandability: The text is accessible. But check the tag - it seems like it does not work for me (#link-to-pint-intro-section).

  • Code completeness: it might be worth adding standard imports (numpy, pyplot) to the snippet so it's fully copy-pasteable for students. Also, adding ax.legend() before showing the plot will make the labels you defined actually visible.

  • Plot fonts: The axis titles and tick numbers are noticeably larger than the main body text. Scaling them down would make the typography consistent.

  • Captions: The plot is missing a figure number and caption.

  • Vector graphics: The plotting cell is missing a format directive (like #| fig-format: pdf), meaning it likely defaults to a standard raster image (PNG) instead of a vector format.

  • Technology names: I noticed you used \techword{Pint} and \techword{Matplotlib} in the title, but standard bold text (Pint) in the markdown body. Consider keeping the \techword{} macro consistent throughout the text to match the small-caps guideline.

  • Typographic errors: The text looks clean and reads well.

It could be helpful for beginners to add a tiny inline comment explaining what the "~P" format string does.

To emphasize the automation aspect, you could add one sentence pointing out that if someone changes the input data unit later, the plot label will update automatically.

@orzel320 orzel320 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The pull request is on topic and of good quality. It seems that the few concerns that were present have already been addressed by Jan, but there are some thing on the checklist that were not mentioned, so I will look over them.

  1. The listing and plots fit in the page margins
  2. The sections placement in the PDF is appropriate
  3. Authors full name doesn't seem to be added to colophon
  4. The notes mentioned in issue were addressed
  5. The K.I.S.S principle doesn't seem to violated
  6. The code is independent of OS
  7. Git workflow seems to be sane

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using PINT with MATPLOTLIB for automatic axis labelling

4 participants