Skip to content

Conversation

@krystophny
Copy link
Collaborator

Summary

  • Extract hardcoded pixel values for label positioning into named constants in fortplot_constants.f90
  • Replace magic numbers (30, 10, 5 pixels) with descriptive constant names in fortplot_raster.f90
  • Export new positioning constants through main fortplot.f90 module for public API access

Changes Made

New Constants Added to fortplot_constants.f90:

  • XLABEL_VERTICAL_OFFSET = 30 - X-axis label vertical offset below plot area
  • YLABEL_HORIZONTAL_OFFSET = 10 - Y-axis label horizontal offset from left edge
  • TICK_MARK_LENGTH = 5 - Tick mark length extending from axis lines

Files Modified:

  • /src/fortplot_constants.f90 - Added label positioning constants with documentation
  • /src/fortplot_raster.f90 - Replaced hardcoded values with named constants
  • /src/fortplot.f90 - Export new constants for public API access

Testing

  • Build compiles successfully with no errors
  • Targeted tests (test_label_positioning, test_raster_ylabel) pass
  • Basic plots example runs and generates expected output
  • Label positioning remains functionally identical

Benefits

  • Maintainability: Centralized positioning configuration
  • Readability: Self-documenting constant names replace magic numbers
  • Consistency: Single source of truth for positioning values
  • Flexibility: Easy to adjust positioning across entire codebase

This refactoring addresses the technical debt identified in issue #343 during code review of PR #341.

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

- Add XLABEL_VERTICAL_OFFSET, YLABEL_HORIZONTAL_OFFSET, TICK_MARK_LENGTH to fortplot_constants.f90
- Replace hardcoded values (30, 10, 5 pixels) in fortplot_raster.f90 with named constants
- Export new constants through main fortplot.f90 module for public API access
- Improves maintainability by centralizing positioning configuration
- All targeted tests pass, examples compile and run successfully

fixes #343
@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/fortplot_raster.f90 0.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@krystophny krystophny merged commit fc68915 into main Aug 26, 2025
3 of 4 checks passed
@krystophny krystophny deleted the refactor-extract-label-positioning-constants-343 branch August 26, 2025 05:10
krystophny added a commit that referenced this pull request Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants