Skip to content

Conversation

@krystophny
Copy link
Collaborator

@krystophny krystophny commented Aug 31, 2025

Fixes #985: CRITICAL REGRESSION: PDF output plots wrong scale.

Summary

  • Restore independent X/Y scaling for PDF coordinate transforms.
  • Remove aspect-ratio preservation that shrank/centered content and misaligned data vs. axes.
  • Aligns plot coordinate mapping with axes/tick generation which already assume full plot-area mapping.

Root Cause

  • Recent refactor introduced a common-scale (min(x_scale, y_scale)) transform in fortplot_pdf_coordinate.f90.
  • Axes/ticks in fortplot_pdf_axes.f90 compute positions using plot-area width/height (independent per axis).
  • The mismatch caused data to be padded/centered while axes spanned the full area → perceived wrong scale.

Changes

  • normalize_to_pdf_coords: use independent x_scale/y_scale; map directly to plot_area%left/bottom.
  • safe_coordinate_transform: same fix; keep degenerate-range centering behavior.
  • No public API changes.

Validation

  • Ran make test-ci (all CI-essential tests passed).
  • Manually verified PDF generation in example/pdf_coordinate_validation.f90.
  • Checked backend switching tests: PDF <-> PNG switching remains OK.

Risk / Compatibility

  • Restores pre-regression behavior (2+ weeks ago), matching PNG and expectations.
  • Vector output fills the full plot area; no more central padding.

Follow-ups

  • Consider adding a dedicated regression test that renders a small set of points and asserts PDF coordinates match expected mapping for a known plot area.

@krystophny krystophny changed the title fix(pdf): restore independent x/y scaling in PDF coordinates to match axes/ticks mapping (fixes #985) fix: restore PDF coordinate scaling to match axes/ticks (fixes #985) Aug 31, 2025
@krystophny krystophny merged commit 4c04ad5 into main Aug 31, 2025
3 checks passed
@krystophny krystophny deleted the fix/985-pdf-scaling branch August 31, 2025 20:36
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.

CRITICAL REGRESSION: PDF output plots wrong scale (was working 2 weeks ago)

2 participants