Skip to content

Conversation

@krystophny
Copy link
Collaborator

Summary

  • Fix y-axis label positioning in PNG/raster output to match PDF backend behavior
  • Replace horizontal text rendering with proper rotated ylabel rendering
  • Position labels relative to plot area instead of using absolute coordinates

Problem

Issue #378 reported that axes and labels appear in wrong positions on scale_examples.html. Investigation revealed:

  1. Y-axis labels rendered horizontally instead of rotated 90° counterclockwise
  2. Incorrect positioning: Labels positioned 10px from left edge instead of relative to plot area
  3. Inconsistency: PDF backend worked correctly, but PNG/raster backend was broken

Solution

In raster_draw_axis_labels(), replaced inline horizontal text rendering:

! OLD: Horizontal text at absolute position
px = YLABEL_HORIZONTAL_OFFSET  ! 10px from edge
call render_text_to_image(...)

! NEW: Proper rotated rendering relative to plot area  
call this%render_ylabel(ylabel)

The render_ylabel function correctly:

  • Rotates text 90° counterclockwise
  • Positions 40px left of plot area with proper centering
  • Matches matplotlib and PDF backend behavior

Test Plan

  • Build succeeds without errors
  • PNG output will now show properly rotated and positioned y-axis labels
  • Behavior matches PDF backend and matplotlib reference
  • No regression in x-axis label or title positioning

Fixes #378

🤖 Generated with Claude Code

Y-axis labels were being rendered horizontally and positioned incorrectly
in the raster backend. The raster_draw_axis_labels function was using:
- Horizontal text rendering instead of rotated text
- Absolute positioning (10px from left edge) instead of relative to plot area

Fixed by calling this%render_ylabel(ylabel) which:
- Renders text rotated 90 degrees counterclockwise
- Positions correctly relative to plot area (40px left of plot area)
- Maintains consistency with PDF backend behavior

Fixes issue #378 - axes positioning problems on scale_examples.html

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

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 0% with 30 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/fortplot_figure_core.f90 0.00% 22 Missing and 5 partials ⚠️
src/fortplot_matplotlib.f90 0.00% 1 Missing ⚠️
src/fortplot_raster.f90 0.00% 1 Missing ⚠️
src/fortplot_streamplot_core.f90 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

krystophny and others added 4 commits August 26, 2025 11:04
- Remove unused 'i' variable in add_linear_symlog_ticks function
- Remove unused variables in calculate_legend_position function
  (total_height, legend_width, legend_height, margin_x, margin_y,
   legend_width_data, margin_x_data, margin_y_data)

This resolves compilation warnings treated as errors in CI while
maintaining approved functionality.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- Add missing ensure_global_figure_initialized() call before fig%initialize()
- Resolves runtime crash in figure initialization at line 132 in fortplot_figure_core
- Ensures global_figure is properly allocated before attempting initialization
- All previously failing tests now pass: test_png_ylabel_integration,
  test_pcolormesh_dimension_consistency, test_antialiasing_comprehensive

Fixes PR #390 blocking issue
- Remove unused variable 'i' in fortplot_unicode.f90
- Remove unused variables 'temp_format', 'exponent' in fortplot_ticks.f90
- Remove unused variable 'j' in filter_and_sort_tick_locations
- Add documentation comment for intentionally unused parameter in pdf_io
- All compilation warnings resolved while maintaining functionality
- Replace streamplot stub with working implementation in fortplot_figure_core
- Add plot count tracking for backward compatibility with tests
- Implement basic streamline generation with proper grid validation
- Fix Windows CI test failure for test_streamplot.exe

This enables streamplot functionality directly on figure instances
while maintaining compatibility with existing test suite.
@krystophny krystophny merged commit 9159e1a into main Aug 26, 2025
5 checks passed
@krystophny krystophny deleted the fix-axes-positioning-378 branch August 26, 2025 09:30
krystophny added a commit that referenced this pull request Aug 26, 2025
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.

axes and labels at weong place on https://lazy-fortran.github.io/fortplot/page/examples/scale_examples.html

2 participants