fortplot_tick_calculation Module

Core tick calculation algorithms for linear scales

Provides: - Nice tick location algorithms following matplotlib MaxNLocator - Axis limit calculation with nice boundaries - Linear scale tick generation



Functions

public function determine_decimal_places_from_step(step) result(decimal_places)

Determine decimal places based on step size for nice formatting

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: step

Return Value integer

public function determine_decimals_from_ticks(tick_positions, n) result(decimal_places)

Determine decimal places from an array of tick positions. Uses the smallest non-zero spacing as representative step.

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: tick_positions(:)
integer, intent(in) :: n

Return Value integer

public function format_tick_value_consistent(value, decimal_places) result(formatted)

Format tick value with consistent decimal places for uniform appearance

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: value
integer, intent(in) :: decimal_places

Return Value character(len=20)


Subroutines

public subroutine calculate_tick_labels(data_min, data_max, num_ticks, labels)

Calculate appropriate tick labels at nice locations like matplotlib Ensures all labels have consistent formatting and nice round numbers

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: data_min
real(kind=wp), intent(in) :: data_max
integer, intent(in) :: num_ticks
character(len=20), intent(out) :: labels(:)

public subroutine calculate_nice_axis_limits(data_min, data_max, target_num_ticks, nice_min, nice_max)

Calculate nice axis limits that encompass the data like matplotlib The axis limits are set to nice round numbers based on tick locations

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: data_min
real(kind=wp), intent(in) :: data_max
integer, intent(in) :: target_num_ticks
real(kind=wp), intent(out) :: nice_min
real(kind=wp), intent(out) :: nice_max

public subroutine find_nice_tick_locations(data_min, data_max, target_num_ticks, nice_min, nice_max, nice_step, tick_locations, actual_num_ticks)

Find nice tick locations following matplotlib's MaxNLocator algorithm exactly

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: data_min
real(kind=wp), intent(in) :: data_max
integer, intent(in) :: target_num_ticks
real(kind=wp), intent(out) :: nice_min
real(kind=wp), intent(out) :: nice_max
real(kind=wp), intent(out) :: nice_step
real(kind=wp), intent(out) :: tick_locations(:)
integer, intent(out) :: actual_num_ticks