Figure initialization and configuration module
Single Responsibility: Initialize figures and manage basic configuration Extracted from fortplot_figure_core to reduce file size and improve modularity
Figure state and configuration data Encapsulates all configuration and state management
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| class(plot_context), | public, | allocatable | :: | backend | |||
| character(len=10), | public | :: | backend_name | = | 'png' | ||
| integer, | public | :: | plot_count | = | 0 | ||
| logical, | public | :: | rendered | = | .false. | ||
| integer, | public | :: | width | = | 640 | ||
| integer, | public | :: | height | = | 480 | ||
| real(kind=wp), | public | :: | margin_left | = | 0.15_wp | ||
| real(kind=wp), | public | :: | margin_right | = | 0.05_wp | ||
| real(kind=wp), | public | :: | margin_bottom | = | 0.15_wp | ||
| real(kind=wp), | public | :: | margin_top | = | 0.05_wp | ||
| character(len=10), | public | :: | xscale | = | 'linear' | ||
| character(len=10), | public | :: | yscale | = | 'linear' | ||
| real(kind=wp), | public | :: | symlog_threshold | = | 1.0_wp | ||
| real(kind=wp), | public | :: | x_min | ||||
| real(kind=wp), | public | :: | x_max | ||||
| real(kind=wp), | public | :: | y_min | ||||
| real(kind=wp), | public | :: | y_max | ||||
| real(kind=wp), | public | :: | x_min_transformed | ||||
| real(kind=wp), | public | :: | x_max_transformed | ||||
| real(kind=wp), | public | :: | y_min_transformed | ||||
| real(kind=wp), | public | :: | y_max_transformed | ||||
| logical, | public | :: | xlim_set | = | .false. | ||
| logical, | public | :: | ylim_set | = | .false. | ||
| integer, | public | :: | active_axis | = | AXIS_PRIMARY | ||
| logical, | public | :: | has_twinx | = | .false. | ||
| logical, | public | :: | has_twiny | = | .false. | ||
| character(len=:), | public, | allocatable | :: | twinx_ylabel | |||
| character(len=:), | public, | allocatable | :: | twiny_xlabel | |||
| character(len=10), | public | :: | twinx_yscale | = | 'linear' | ||
| character(len=10), | public | :: | twiny_xscale | = | 'linear' | ||
| logical, | public | :: | twinx_ylim_set | = | .false. | ||
| logical, | public | :: | twiny_xlim_set | = | .false. | ||
| real(kind=wp), | public | :: | twinx_y_min | = | 0.0_wp | ||
| real(kind=wp), | public | :: | twinx_y_max | = | 1.0_wp | ||
| real(kind=wp), | public | :: | twiny_x_min | = | 0.0_wp | ||
| real(kind=wp), | public | :: | twiny_x_max | = | 1.0_wp | ||
| real(kind=wp), | public | :: | twinx_y_min_transformed | = | 0.0_wp | ||
| real(kind=wp), | public | :: | twinx_y_max_transformed | = | 1.0_wp | ||
| real(kind=wp), | public | :: | twiny_x_min_transformed | = | 0.0_wp | ||
| real(kind=wp), | public | :: | twiny_x_max_transformed | = | 1.0_wp | ||
| character(len=:), | public, | allocatable | :: | title | |||
| character(len=:), | public, | allocatable | :: | xlabel | |||
| character(len=:), | public, | allocatable | :: | ylabel | |||
| real(kind=wp), | public, | dimension(3,6) | :: | colors | = | reshape([0.0_wp, 0.447_wp, 0.698_wp, 0.0_wp, 0.619_wp, 0.451_wp, 0.835_wp, 0.369_wp, 0.0_wp, 0.8_wp, 0.475_wp, 0.655_wp, 0.941_wp, 0.894_wp, 0.259_wp, 0.337_wp, 0.702_wp, 0.914_wp], [3, 6]) | |
| type(legend_t), | public | :: | legend_data | ||||
| logical, | public | :: | show_legend | = | .false. | ||
| integer, | public | :: | max_plots | = | 500 | ||
| real(kind=wp), | public | :: | current_line_width | = | 1.0_wp | ||
| logical, | public | :: | has_error | = | .false. | ||
| logical, | public | :: | grid_enabled | = | .false. | ||
| character(len=10), | public | :: | grid_which | = | 'both' | ||
| character(len=1), | public | :: | grid_axis | = | 'b' | ||
| real(kind=wp), | public | :: | grid_alpha | = | 0.3_wp | ||
| character(len=10), | public | :: | grid_linestyle | = | '-' | ||
| type(arrow_data_t), | public, | allocatable | :: | stream_arrows(:) | 
Initialize figure state with specified parameters Added Issue #854: Parameter validation for user input safety
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| integer, | intent(in), | optional | :: | width | ||
| integer, | intent(in), | optional | :: | height | ||
| character(len=*), | intent(in), | optional | :: | backend | 
Reset figure state to initial values
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | 
Setup or change the figure backend
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| character(len=*), | intent(in) | :: | backend_name | 
Configure figure dimensions
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| integer, | intent(in), | optional | :: | width | ||
| integer, | intent(in), | optional | :: | height | 
Set figure labels
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| character(len=*), | intent(in), | optional | :: | title | ||
| character(len=*), | intent(in), | optional | :: | xlabel | ||
| character(len=*), | intent(in), | optional | :: | ylabel | 
Set axis scale types
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| character(len=*), | intent(in), | optional | :: | xscale | ||
| character(len=*), | intent(in), | optional | :: | yscale | ||
| real(kind=wp), | intent(in), | optional | :: | threshold | 
Set axis limits
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(figure_state_t), | intent(inout) | :: | state | |||
| real(kind=wp), | intent(in), | optional | :: | x_min | ||
| real(kind=wp), | intent(in), | optional | :: | x_max | ||
| real(kind=wp), | intent(in), | optional | :: | y_min | ||
| real(kind=wp), | intent(in), | optional | :: | y_max |