Skip to content

Conversation

@krystophny
Copy link
Collaborator

Summary

Fixes missing markers in PDF output caused by coordinate transformation regression. Markers were being positioned outside the visible plot area due to aspect ratio preservation logic introduced ~2 weeks ago.

Root Cause

Same underlying issue as PDF scale regression #985:

  • Coordinate transformation regression in normalize_to_pdf_coords()
  • Aspect ratio preservation logic using common_scale = min(x_scale, y_scale)
  • Result: Markers positioned incorrectly, often outside visible area

Technical Fix

Applied same coordinate transformation fix as scale regression:

Modified Functions

  • normalize_to_pdf_coords(): Restored independent X/Y scaling
  • safe_coordinate_transform(): Removed aspect ratio preservation

Key Changes

! OLD (with aspect ratio preservation - caused missing markers)
common_scale = min(x_scale, y_scale)
pdf_x = (x - ctx%x_min) * common_scale + plot_left + x_offset

! NEW (independent scaling - markers visible)
x_scale = plot_width / x_range  
y_scale = plot_height / y_range
pdf_x = (x - ctx%x_min) * x_scale + plot_left

Validation

  • Regression Test: test_missing_markers_986.f90 demonstrates issue/fix
  • Marker Types: Tested circles, squares, triangles, crosses
  • Existing Examples: marker_demo works correctly after fix
  • Visual Verification: Markers now appear in correct positions in PDF

Files Changed

  • src/backends/vector/fortplot_pdf_coordinate.f90: Coordinate transformation fix
  • example/test_missing_markers_986.f90: Regression test for verification

Relationship to Other Issues

This fix resolves the same coordinate transformation bug as #985 (PDF scale regression):

Test Plan

  • Run regression test showing markers now visible
  • Test marker_demo example (all marker types work)
  • Verify PDF markers match PNG marker positions
  • Confirm no regressions in other functionality

🤖 Generated with Claude Code

fixes #986)

## Root Cause Analysis

PDF markers were missing due to coordinate transformation regression where
aspect ratio preservation placed markers at incorrect positions, often
outside the visible plot area.

**Issue**: Same coordinate transformation bug that caused scale regression (#985)
also affected marker positioning in `normalize_to_pdf_coords()`.

## Technical Fix

Restored independent axis scaling in PDF coordinate transformation:

1. **normalize_to_pdf_coords()**: Use separate x_scale/y_scale instead of common_scale
2. **safe_coordinate_transform()**: Remove aspect ratio preservation logic
3. **Result**: Markers positioned correctly within visible plot area

## Changes Made

- Modified `src/backends/vector/fortplot_pdf_coordinate.f90`:
  - Remove `common_scale = min(x_scale, y_scale)` logic
  - Use independent scaling: `x_scale` and `y_scale`
  - Transform markers directly to correct plot coordinates
  - Maintain epsilon protection for edge cases

## Validation

- Created regression test demonstrating missing markers issue and fix
- Tested multiple marker types: circles, squares, triangles, crosses
- Verified markers appear correctly in PDF output after fix
- Confirmed marker_demo example works properly
- All existing tests continue to pass

## Test Plan

- [x] Run marker regression test to verify fix
- [x] Test marker_demo example (all marker types)
- [x] Verify markers visible in PDF output
- [x] Confirm no regressions in existing functionality

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@krystophny krystophny merged commit aef6fcc into main Aug 31, 2025
3 checks passed
@krystophny krystophny deleted the fix/missing-markers-986 branch August 31, 2025 23:20
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