fortplot_ascii_axis_policy Module

Text-backend axis rendering policy (issue #2069).

Defines the single source of truth for how the text/ASCII backend draws axis spines, tick marks, and how cells are resolved when several plot layers land on the same character cell.

Adopted policy (compared against gnuplot set terminal dumb, plotext, and UnicodePlots.jl):

  • Axis spines are SOLID: a continuous left | spine spans the data rows and a continuous bottom - spine spans the data columns. Spines are never drawn by sampling in data space, so they never degrade into a dashed data-like line.
  • Tick marks (+) are drawn only at labeled (major) tick positions on the spine. No minor/unlabeled tick marks and no grid lines are drawn by default in text output.
  • Cell priority is ordered by layer: grid < data < axis < tick < label. A higher layer overwrites a lower one; equal layers overwrite so the most recently drawn glyph wins. Tick/axis labels (highest layer) are rendered last and are therefore never overwritten by plot data.

Author: fortplot contributors



Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: LAYER_EMPTY = 0
integer, public, parameter :: LAYER_GRID = 10
integer, public, parameter :: LAYER_DATA = 20
integer, public, parameter :: LAYER_AXIS = 30
integer, public, parameter :: LAYER_TICK = 40
integer, public, parameter :: LAYER_LABEL = 50

Derived Types

type, public ::  text_cell_t

Components

Type Visibility Attributes Name Initial
integer, public :: layer = LAYER_EMPTY
character(len=1), public :: glyph = ' '

Functions

public pure function glyph_layer(glyph) result(layer)

Classify a character already present on the canvas into a layer so put_cell can resolve collisions without a parallel layer buffer.

Arguments

Type IntentOptional Attributes Name
character(len=1), intent(in) :: glyph

Return Value integer


Subroutines

public subroutine put_cell(canvas, row, col, glyph, layer)

Write glyph into the canvas only when its layer is at least the layer of the glyph already occupying the cell (higher or equal layer wins).

Arguments

Type IntentOptional Attributes Name
character(len=1), intent(inout) :: canvas(:,:)
integer, intent(in) :: row
integer, intent(in) :: col
character(len=1), intent(in) :: glyph
integer, intent(in) :: layer

public pure subroutine map_ticks_to_cells(tick_values, num_ticks, v_min, v_max, cell_lo, cell_hi, cells, in_range)

Map axis tick data values to integer screen cells along one axis. in_range flags the ticks that fall inside [cell_lo, cell_hi] and are therefore drawable; callers decide which are labeled.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: tick_values(:)
integer, intent(in) :: num_ticks
real(kind=wp), intent(in) :: v_min
real(kind=wp), intent(in) :: v_max
integer, intent(in) :: cell_lo
integer, intent(in) :: cell_hi
integer, intent(out) :: cells(:)
logical, intent(out) :: in_range(:)