diff --git a/doc/media/examples/colored_contours/gaussian_default.pdf b/doc/media/examples/colored_contours/gaussian_default.pdf deleted file mode 100644 index 771273b5..00000000 Binary files a/doc/media/examples/colored_contours/gaussian_default.pdf and /dev/null differ diff --git a/doc/media/examples/colored_contours/gaussian_default.png b/doc/media/examples/colored_contours/gaussian_default.png deleted file mode 100644 index 3a2a0129..00000000 Binary files a/doc/media/examples/colored_contours/gaussian_default.png and /dev/null differ diff --git a/doc/media/examples/colored_contours/ripple_coolwarm.pdf b/doc/media/examples/colored_contours/ripple_coolwarm.pdf deleted file mode 100644 index 20398bf7..00000000 Binary files a/doc/media/examples/colored_contours/ripple_coolwarm.pdf and /dev/null differ diff --git a/doc/media/examples/colored_contours/ripple_coolwarm.png b/doc/media/examples/colored_contours/ripple_coolwarm.png deleted file mode 100644 index df957c6b..00000000 Binary files a/doc/media/examples/colored_contours/ripple_coolwarm.png and /dev/null differ diff --git a/doc/media/examples/colored_contours/ripple_inferno.pdf b/doc/media/examples/colored_contours/ripple_inferno.pdf deleted file mode 100644 index 20398bf7..00000000 Binary files a/doc/media/examples/colored_contours/ripple_inferno.pdf and /dev/null differ diff --git a/doc/media/examples/colored_contours/ripple_inferno.png b/doc/media/examples/colored_contours/ripple_inferno.png deleted file mode 100644 index 1c5e2b28..00000000 Binary files a/doc/media/examples/colored_contours/ripple_inferno.png and /dev/null differ diff --git a/doc/media/examples/colored_contours/ripple_jet.pdf b/doc/media/examples/colored_contours/ripple_jet.pdf deleted file mode 100644 index 20398bf7..00000000 Binary files a/doc/media/examples/colored_contours/ripple_jet.pdf and /dev/null differ diff --git a/doc/media/examples/colored_contours/ripple_jet.png b/doc/media/examples/colored_contours/ripple_jet.png deleted file mode 100644 index 23aee428..00000000 Binary files a/doc/media/examples/colored_contours/ripple_jet.png and /dev/null differ diff --git a/doc/media/examples/colored_contours/saddle_plasma.pdf b/doc/media/examples/colored_contours/saddle_plasma.pdf deleted file mode 100644 index e32cdcc9..00000000 Binary files a/doc/media/examples/colored_contours/saddle_plasma.pdf and /dev/null differ diff --git a/doc/media/examples/colored_contours/saddle_plasma.png b/doc/media/examples/colored_contours/saddle_plasma.png deleted file mode 100644 index 7af7c071..00000000 Binary files a/doc/media/examples/colored_contours/saddle_plasma.png and /dev/null differ diff --git a/src/fortplot.f90 b/src/fortplot.f90 index 92a8cb98..315a4820 100644 --- a/src/fortplot.f90 +++ b/src/fortplot.f90 @@ -55,7 +55,9 @@ module fortplot ! Core types and constants use fortplot_figure_core, only: figure_t - use fortplot_constants, only: EPSILON_COMPARE, EPSILON_GEOMETRY + use fortplot_constants, only: EPSILON_COMPARE, EPSILON_GEOMETRY, & + XLABEL_VERTICAL_OFFSET, YLABEL_HORIZONTAL_OFFSET, & + TICK_MARK_LENGTH, TITLE_VERTICAL_OFFSET ! Animation functionality use fortplot_animation, only: animation_t, FuncAnimation @@ -104,7 +106,9 @@ module fortplot public :: figure_t, wp ! Numerical constants - public :: EPSILON_COMPARE, EPSILON_GEOMETRY + public :: EPSILON_COMPARE, EPSILON_GEOMETRY, & + XLABEL_VERTICAL_OFFSET, YLABEL_HORIZONTAL_OFFSET, TICK_MARK_LENGTH, & + TITLE_VERTICAL_OFFSET ! Coordinate system constants for annotations public :: COORD_DATA, COORD_FIGURE, COORD_AXIS diff --git a/src/fortplot_constants.f90 b/src/fortplot_constants.f90 index 954ce8e5..c64c1871 100644 --- a/src/fortplot_constants.f90 +++ b/src/fortplot_constants.f90 @@ -43,4 +43,44 @@ module fortplot_constants !! Smaller value provides better precision for critical geometric operations. real(wp), parameter, public :: EPSILON_GEOMETRY = 1e-12_wp + ! ======================================================================== + ! LABEL POSITIONING CONSTANTS + ! ======================================================================== + + !! X-axis label vertical offset below plot area (pixels) + !! + !! This constant defines the vertical distance between the bottom of the + !! plot area and the baseline of the x-axis label text. + !! + !! Used by raster backend for xlabel positioning to ensure consistent + !! spacing below tick labels while avoiding overlap. + integer, parameter, public :: XLABEL_VERTICAL_OFFSET = 30 + + !! Y-axis label horizontal offset from left edge (pixels) + !! + !! This constant defines the horizontal distance from the left edge of + !! the figure to the left edge of the y-axis label text. + !! + !! Used by raster backend for ylabel positioning to ensure consistent + !! left margin spacing and readability. + integer, parameter, public :: YLABEL_HORIZONTAL_OFFSET = 10 + + !! Tick mark length extending from axis line (pixels) + !! + !! This constant defines the length of tick marks extending from the + !! axis lines into the plot area or margin. + !! + !! Used by raster backend for drawing consistent tick marks across + !! all axes while maintaining visual hierarchy. + integer, parameter, public :: TICK_MARK_LENGTH = 5 + + !! Title vertical offset above plot area (pixels) + !! + !! This constant defines the vertical distance between the bottom of the + !! plot area and the baseline of the title text. + !! + !! Used by raster backend for title positioning to ensure consistent + !! spacing above the plot area while maintaining readability. + integer, parameter, public :: TITLE_VERTICAL_OFFSET = 30 + end module fortplot_constants \ No newline at end of file diff --git a/src/fortplot_raster.f90 b/src/fortplot_raster.f90 index 813414a7..08083f7b 100644 --- a/src/fortplot_raster.f90 +++ b/src/fortplot_raster.f90 @@ -1,7 +1,9 @@ module fortplot_raster use iso_c_binding use fortplot_context, only: plot_context, setup_canvas - use fortplot_constants, only: EPSILON_COMPARE, EPSILON_GEOMETRY + use fortplot_constants, only: EPSILON_COMPARE, EPSILON_GEOMETRY, & + XLABEL_VERTICAL_OFFSET, YLABEL_HORIZONTAL_OFFSET, & + TICK_MARK_LENGTH, TITLE_VERTICAL_OFFSET use fortplot_text, only: render_text_to_image, calculate_text_width, calculate_text_height use fortplot_latex_parser, only: process_latex_in_text ! use fortplot_unicode, only: unicode_to_ascii @@ -983,7 +985,7 @@ subroutine raster_draw_axes_and_labels(this, xscale, yscale, symlog_threshold, & call this%line(x_min, y_min, x_min, y_max) ! Generate and draw tick marks and labels - tick_length = 5 ! Tick length in pixels + tick_length = TICK_MARK_LENGTH ! Tick length in pixels ! X-axis ticks call compute_scale_ticks(xscale, x_min, x_max, symlog_threshold, x_tick_positions, num_x_ticks) @@ -1055,7 +1057,7 @@ subroutine raster_draw_axes_and_labels(this, xscale, yscale, symlog_threshold, & text_width = calculate_text_width(trim(escaped_text)) ! Center horizontally in plot area, position below tick labels px = this%plot_area%left + this%plot_area%width / 2 - text_width / 2 - py = this%plot_area%bottom + this%plot_area%height + 30 ! 30 pixels below plot area + py = this%plot_area%bottom + this%plot_area%height + XLABEL_VERTICAL_OFFSET ! Pixels below plot area call render_text_to_image(this%raster%image_data, this%width, this%height, & px, py, trim(escaped_text), text_r, text_g, text_b) end if @@ -1069,7 +1071,7 @@ subroutine raster_draw_axes_and_labels(this, xscale, yscale, symlog_threshold, & text_width = calculate_text_width(trim(escaped_text)) text_height = calculate_text_height(trim(escaped_text)) ! Position to the left of plot area, centered vertically - px = 10 ! 10 pixels from left edge + px = YLABEL_HORIZONTAL_OFFSET ! Pixels from left edge py = this%plot_area%bottom + this%plot_area%height / 2 - text_height / 2 call render_text_to_image(this%raster%image_data, this%width, this%height, & px, py, trim(escaped_text), text_r, text_g, text_b) @@ -1128,7 +1130,7 @@ subroutine render_title_centered(this, title_text) ! Y position: above plot area (like matplotlib) ! Place title approximately 30 pixels above the plot area - title_py = real(this%plot_area%bottom - 30, wp) + title_py = real(this%plot_area%bottom - TITLE_VERTICAL_OFFSET, wp) ! Get current color and render title directly in pixel coordinates call this%raster%get_color_bytes(r, g, b)