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 | :: | dpi | = | 100.0_wp | ||
| 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 | ||
| character(len=:), | public, | allocatable | :: | xaxis_date_format | |||
| character(len=:), | public, | allocatable | :: | yaxis_date_format | |||
| 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' | ||
| character(len=:), | public, | allocatable | :: | twinx_yaxis_date_format | |||
| character(len=:), | public, | allocatable | :: | twiny_xaxis_date_format | |||
| 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 | |||
| character(len=:), | public, | allocatable | :: | suptitle | |||
| real(kind=wp), | public | :: | suptitle_fontsize | = | 14.0_wp | ||
| 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 | = | '-' | ||
| logical, | public | :: | colorbar_enabled | = | .false. | ||
| integer, | public | :: | colorbar_plot_index | = | 0 | ||
| character(len=10), | public | :: | colorbar_location | = | 'right' | ||
| real(kind=wp), | public | :: | colorbar_fraction | = | 0.15_wp | ||
| real(kind=wp), | public | :: | colorbar_pad | = | 0.05_wp | ||
| real(kind=wp), | public | :: | colorbar_shrink | = | 1.0_wp | ||
| logical, | public | :: | colorbar_label_set | = | .false. | ||
| character(len=:), | public, | allocatable | :: | colorbar_label | |||
| logical, | public | :: | colorbar_ticks_set | = | .false. | ||
| logical, | public | :: | colorbar_ticklabels_set | = | .false. | ||
| real(kind=wp), | public, | allocatable | :: | colorbar_ticks(:) | |||
| character(len=50), | public, | allocatable | :: | colorbar_ticklabels(:) | |||
| real(kind=wp), | public | :: | colorbar_label_fontsize | = | 10.0_wp | ||
| type(arrow_data_t), | public, | allocatable | :: | stream_arrows(:) | |||
| logical, | public | :: | minor_ticks_x | = | .false. | ||
| logical, | public | :: | minor_ticks_y | = | .false. | ||
| integer, | public | :: | minor_tick_count | = | 5 | ||
| logical, | public | :: | custom_xticks_set | = | .false. | ||
| logical, | public | :: | custom_yticks_set | = | .false. | ||
| real(kind=wp), | public, | allocatable | :: | custom_xtick_positions(:) | |||
| real(kind=wp), | public, | allocatable | :: | custom_ytick_positions(:) | |||
| character(len=50), | public, | allocatable | :: | custom_xtick_labels(:) | |||
| character(len=50), | public, | allocatable | :: | custom_ytick_labels(:) | |||
| character(len=10), | public | :: | aspect_mode | = | 'auto' | ||
| real(kind=wp), | public | :: | aspect_ratio | = | 1.0_wp | ||
| logical, | public | :: | tight_layout_enabled | = | .false. | ||
| real(kind=wp), | public | :: | tight_pad | = | 1.08_wp | ||
| real(kind=wp), | public | :: | tight_w_pad | = | 0.0_wp | ||
| real(kind=wp), | public | :: | tight_h_pad | = | 0.0_wp | ||
| logical, | public | :: | polar_projection | = | .false. | ||
| real(kind=wp), | public | :: | polar_theta_min | = | 0.0_wp | ||
| real(kind=wp), | public | :: | polar_theta_max | = | 6.283185307179586_wp | ||
| real(kind=wp), | public | :: | polar_r_min | = | 0.0_wp | ||
| real(kind=wp), | public | :: | polar_r_max | = | 1.0_wp | ||
| integer, | public | :: | polar_theta_gridlines | = | 12 | ||
| integer, | public | :: | polar_r_gridlines | = | 5 | ||
| logical, | public | :: | polar_theta_direction_cw | = | .false. | ||
| real(kind=wp), | public | :: | polar_theta_offset | = | 1.5707963267948966_wp |
Initialize figure state with specified parameters Added Issue #854: Parameter validation for user input safety Added DPI support for OO interface consistency with matplotlib interface
| 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 | ||
| real(kind=wp), | intent(in), | optional | :: | dpi |
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 |