Skip to content

fix: PNG backend: markers at data range boundary clipped by plot border (fixes #1683)#1818

Merged
krystophny merged 2 commits intomainfrom
fix/issue-1683-marker-boundary-clipping
Apr 25, 2026
Merged

fix: PNG backend: markers at data range boundary clipped by plot border (fixes #1683)#1818
krystophny merged 2 commits intomainfrom
fix/issue-1683-marker-boundary-clipping

Conversation

@krystophny
Copy link
Copy Markdown
Collaborator

Summary

Increase the data-range margin expansion from 2% to 5% so markers placed at the exact data-range boundary are pushed far enough inside the plot area to avoid visual overlap with the axes frame.

Changes

  • src/figures/fortplot_figure_rendering_pipeline.f90: bump PDF_DATA_RANGE_MARGIN from 0.02_wp to 0.05_wp
  • test/test_marker_boundary_clipping.f90: new regression test placing markers at all four data-range corners and verifying each has sufficient visible pixel coverage

Root Cause

The expand_data_range subroutine inflates the coordinate system so boundary data points map inside the plot area rather than onto the axes frame. A 2 % inflation on a typical ~400 px plot height gives only ~8 px of clearance, which is barely enough for a 5–7 px marker radius. At that distance the 1 px axes frame line overlaps the outer edge of the marker, making it look "half-clipped".

A 5 % inflation gives ~20 px clearance, which comfortably accommodates all built-in marker sizes.

Verification

Test passes after fix

$ fpm test --target test_marker_boundary_clipping
 PASS: all four corner markers fully visible
   corner pixel counts:         699         521         463         408

Full test suite green

$ fpm test 2>&1 | grep -c "STOP 1\|<ERROR>"
0

Affected examples regenerate cleanly

  • make example ARGS="scatter_demo" → scatter_basic.png, scatter_multi.png, scatter_gaussian.png
  • make example ARGS="disconnected_lines" → disconnected_lines.png, disconnected_lines.pdf

Artifact file sizes are consistent with pre-change renders (no regression in output volume).

fixes #1683)

Increase PDF_DATA_RANGE_MARGIN from 2% to 5% so that markers placed
at the exact data-range boundary are pushed far enough inside the
plot area to avoid visual overlap with the 1-pixel axes frame line.

Add regression test that verifies corner markers render with sufficient
pixel coverage.
@krystophny krystophny merged commit 5d9f46c into main Apr 25, 2026
@krystophny krystophny deleted the fix/issue-1683-marker-boundary-clipping branch April 25, 2026 22:27
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.

1 participant