Commit df861d5
fix: restore PDF plot scaling to fill available plot area (fixes #985)
## Root Cause Analysis
PDF scale regression introduced in commit 1c2fdea when aspect ratio
preservation was added to coordinate transformation functions. This caused
plots to appear smaller with centering instead of filling the plot area.
**Before**: Coordinates used independent X/Y scales, filling plot area completely
**After**: Used common scale (min of X/Y scales) for aspect ratio preservation
## Technical Fix
Restored independent axis scaling in coordinate transformation:
1. **normalize_to_pdf_coords()**: Removed common_scale, centering offsets
2. **safe_coordinate_transform()**: Removed aspect ratio preservation logic
3. **Result**: PDF plots now fill available plot area like other backends
## Changes Made
- Modified `src/backends/vector/fortplot_pdf_coordinate.f90`:
- Removed aspect ratio preservation logic
- Use independent x_scale and y_scale for each axis
- Transform coordinates directly to fill plot area
- Maintain epsilon protection for degenerate cases
## Validation
- Created regression test demonstrating issue and fix
- All tests pass with new coordinate transformation
- PDF examples generate correctly scaled output
- No impact on other backends (PNG/ASCII unaffected)
## Test Plan
- [x] Run regression test to verify fix
- [x] Run full test suite (all pass)
- [x] Generate PDF examples to verify scaling
- [x] Compare PDF output scale with PNG output (now consistent)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 70ac0a0 commit df861d5
File tree
2 files changed
+43
-40
lines changed- example
- src/backends/vector
2 files changed
+43
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
| 42 | + | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
| |||
60 | 58 | | |
61 | 59 | | |
62 | 60 | | |
63 | | - | |
| 61 | + | |
| 62 | + | |
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 66 | + | |
| 67 | + | |
81 | 68 | | |
82 | 69 | | |
83 | | - | |
84 | | - | |
| 70 | + | |
85 | 71 | | |
86 | 72 | | |
87 | 73 | | |
| |||
247 | 233 | | |
248 | 234 | | |
249 | 235 | | |
250 | | - | |
251 | | - | |
| 236 | + | |
| 237 | + | |
252 | 238 | | |
253 | 239 | | |
254 | 240 | | |
255 | 241 | | |
256 | 242 | | |
257 | 243 | | |
258 | | - | |
259 | | - | |
260 | | - | |
| 244 | + | |
261 | 245 | | |
262 | 246 | | |
263 | 247 | | |
| |||
274 | 258 | | |
275 | 259 | | |
276 | 260 | | |
277 | | - | |
| 261 | + | |
278 | 262 | | |
279 | 263 | | |
280 | 264 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
295 | 268 | | |
296 | 269 | | |
297 | 270 | | |
| |||
0 commit comments