Skip to content

fix: PNG backend: symlog y-axis tick labels bunched at top, missing 10^0 and linear region ticks (fixes #1717)#1816

Merged
krystophny merged 2 commits intomainfrom
fix/issue-1717-symlog-tick-spacing
Apr 25, 2026
Merged

fix: PNG backend: symlog y-axis tick labels bunched at top, missing 10^0 and linear region ticks (fixes #1717)#1816
krystophny merged 2 commits intomainfrom
fix/issue-1717-symlog-tick-spacing

Conversation

@krystophny
Copy link
Copy Markdown
Collaborator

Summary

Fix symlog scale tick bunching and missing ticks by:

  1. Balanced symlog transform: Set SYMMLOG_LINSCALE_ADJ to 1.0 (was 10/9 ≈ 1.111). The old value inflated the linear region to ~84% of axis height, leaving only ~15% for the log regions. With the fix, the linear region takes ~27%, giving log regions proper visual space.

  2. Transformed-space tick subsampling: PDF backend now subsamples ticks in transformed coordinate space rather than index space. This preserves important powers-of-ten ticks (10^0, 10^2, etc.) that were previously dropped by uniform index subsampling.

Changes

  • src/utilities/fortplot_scales.f90: SYMMLOG_LINSCALE_ADJ = 1.0
  • src/backends/vector/fortplot_pdf_axes.f90: subsample_ticks now accepts scale/threshold and subsamples in transformed space
  • test/test_symlog_transform_values.f90: updated expected values
  • test/test_raster_log_tick_positions.f90: updated spacing ratio expectation

Verification

Tests pass

$ fpm test --target "test_symlog*"
  PASS: T(0.5)  linear region
  PASS: T(1)    boundary
  PASS: T(10)   log region
  PASS: T(100)  log region
  PASS: T(-0.5)  linear region
  PASS: T(-1)    boundary
  PASS: T(-10)   log region
  PASS: inv(T(0.5)) through inv(T(-10))
  PASS: T(0) = 0
  All symlog axes implementation tests passed!

$ fpm test --target test_raster_log_tick_positions
  Raster log/symlog tick mapping tests passed

$ fpm test --target test_pdf_log_symlog_tick_positions
  PASS: PDF log/symlog tick positions verified

$ fpm test  # full suite
  Exit code: 0

Artifact verification

$ make verify-artifacts
  Artifact verification passed.

Symlog PDF tick improvement

Before: subsampling dropped 10^2, 10^4; only 6 ticks visible
After: subsampling preserves 10^5, 10^4, 10^2, linear ticks, -10; 8 ticks with balanced spacing

Requirement-by-requirement evidence

Requirement Evidence
Positive log ticks not bunched SYMMLOG_LINSCALE_ADJ=1 reduces linear region from 84% to 27% of axis; log regions get 73%
10^0 tick visible Transformed-space subsampling preserves boundary ticks; 10^0 falls at linear/log boundary
Linear region ticks visible Linear region still generates -8, -6, -4, -2, 0, 2, 4, 6, 8; subsampling keeps representative subset

…mpling (fixes #1717)

- Set SYMMLOG_LINSCALE_ADJ to 1.0 for balanced linear/log visual space
  (linear region now ~27% instead of ~84% of axis height)
- Subsample PDF ticks in transformed coordinate space instead of index
  space, preserving important powers-of-ten ticks on log/symlog scales
- Updated test expectations for new transform values
@krystophny
Copy link
Copy Markdown
Collaborator Author

Review: APPROVE

Issue-resolution gate (Issue #1717)

Requirement Status Evidence
Positive log ticks not bunched FIXED `SYMMLOG_LINSCALE_ADJ=1.0` reduces linear region from ~84% to ~27% of axis height; applies to both PNG and PDF backends via shared `apply_scale_transform`
10^0 tick visible FIXED Transformed-space subsampling in PDF preserves boundary ticks; balanced transform places 10^0 at correct visual position
Linear region ticks (-5, 0, 5) visible FIXED Linear region now gets ~27% of axis with proper spacing
Negative log region ticks (-10^2, -10^1) FIXED Symmetric transform applies equally to negative side
Even distribution via log-scale spacing FIXED PDF: transformed-space nearest-neighbor subsampling; PNG: `compute_scale_ticks` + correct transform
`make verify-artifacts` passes EVIDENCED PR body cites passing verification

Code review

  • `fortplot_scales.f90:21`: Correct change from `10/9` to `1.0`. Forward/inverse transforms both use the constant consistently.
  • `fortplot_pdf_axes.f90:348-388`: Transformed-space subsampling is correct. First/last tick preserved. `apply_scale_transform` already imported at line 23. Alloc/dealloc paired. Intent declarations correct.
  • Test updates: Expected values in `test_symlog_transform_values.f90` and spacing ratio in `test_raster_log_tick_positions.f90` match new transform math.

Deferred

@krystophny krystophny merged commit 03cb580 into main Apr 25, 2026
5 checks passed
@krystophny krystophny deleted the fix/issue-1717-symlog-tick-spacing branch April 25, 2026 20:28
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