figure_t Derived Type

type, public :: figure_t

Main figure class - coordinates plotting operations Now uses composition of focused modules for better organization


Components

Type Visibility Attributes Name Initial
type(figure_state_t), public :: state
type(plot_data_t), public, allocatable :: plots(:)
type(plot_data_t), public, allocatable :: streamlines(:)
type(arrow_data_t), public, allocatable :: arrow_data(:)
type(text_annotation_t), public, allocatable :: annotations(:)
integer, public :: annotation_count = 0
integer, public :: max_annotations = 1000
integer, public :: subplot_rows = 0
integer, public :: subplot_cols = 0
integer, public :: current_subplot = 1
type(subplot_data_t), public, allocatable :: subplots_array(:,:)
character(len=:), public, allocatable :: title
character(len=:), public, allocatable :: xlabel
character(len=:), public, allocatable :: ylabel
integer, public :: plot_count = 0

Finalization Procedures

final :: destroy

  • private subroutine destroy(self)

    Finalize and clean up figure

    Arguments

    Type IntentOptional Attributes Name
    type(figure_t), intent(inout) :: self

Type-Bound Procedures

procedure, public :: initialize

  • private subroutine initialize(self, width, height, backend)

    Initialize the figure with specified dimensions and backend

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    integer, intent(in), optional :: width
    integer, intent(in), optional :: height
    character(len=*), intent(in), optional :: backend

procedure, public :: add_plot

  • private subroutine add_plot(self, x, y, label, linestyle, color)

    Add a line plot to the figure

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x(:)
    real(kind=wp), intent(in) :: y(:)
    character(len=*), intent(in), optional :: label
    character(len=*), intent(in), optional :: linestyle
    real(kind=wp), intent(in), optional :: color(3)

procedure, public :: add_contour

  • private subroutine add_contour(self, x_grid, y_grid, z_grid, levels, label)

    Add a contour plot to the figure

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x_grid(:)
    real(kind=wp), intent(in) :: y_grid(:)
    real(kind=wp), intent(in) :: z_grid(:,:)
    real(kind=wp), intent(in), optional :: levels(:)
    character(len=*), intent(in), optional :: label

procedure, public :: add_contour_filled

  • private subroutine add_contour_filled(self, x_grid, y_grid, z_grid, levels, colormap, show_colorbar, label)

    Add a filled contour plot with color mapping

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x_grid(:)
    real(kind=wp), intent(in) :: y_grid(:)
    real(kind=wp), intent(in) :: z_grid(:,:)
    real(kind=wp), intent(in), optional :: levels(:)
    character(len=*), intent(in), optional :: colormap
    logical, intent(in), optional :: show_colorbar
    character(len=*), intent(in), optional :: label

procedure, public :: add_pcolormesh

  • private subroutine add_pcolormesh(self, x, y, c, colormap, vmin, vmax, edgecolors, linewidths)

    Add a pcolormesh plot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x(:)
    real(kind=wp), intent(in) :: y(:)
    real(kind=wp), intent(in) :: c(:,:)
    character(len=*), intent(in), optional :: colormap
    real(kind=wp), intent(in), optional :: vmin
    real(kind=wp), intent(in), optional :: vmax
    real(kind=wp), intent(in), optional :: edgecolors(3)
    real(kind=wp), intent(in), optional :: linewidths

procedure, public :: streamplot

  • private subroutine streamplot(self, x, y, u, v, density, color, linewidth, rtol, atol, max_time)

    Add streamline plot to figure using basic algorithm

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x(:)
    real(kind=wp), intent(in) :: y(:)
    real(kind=wp), intent(in) :: u(:,:)
    real(kind=wp), intent(in) :: v(:,:)
    real(kind=wp), intent(in), optional :: density
    real(kind=wp), intent(in), optional :: color(3)
    real(kind=wp), intent(in), optional :: linewidth
    real(kind=wp), intent(in), optional :: rtol
    real(kind=wp), intent(in), optional :: atol
    real(kind=wp), intent(in), optional :: max_time

procedure, public :: savefig

  • private subroutine savefig(self, filename, blocking)

    Save figure to file (backward compatibility version)

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    character(len=*), intent(in) :: filename
    logical, intent(in), optional :: blocking

procedure, public :: savefig_with_status

  • private subroutine savefig_with_status(self, filename, status, blocking)

    Save figure to file with error status reporting

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    character(len=*), intent(in) :: filename
    integer, intent(out) :: status
    logical, intent(in), optional :: blocking

procedure, public :: set_xlabel

  • private subroutine set_xlabel(self, label)

    Set x-axis label

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    character(len=*), intent(in) :: label

procedure, public :: set_ylabel

  • private subroutine set_ylabel(self, label)

    Set y-axis label

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    character(len=*), intent(in) :: label

procedure, public :: set_title

  • private subroutine set_title(self, title)

    Set figure title

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    character(len=*), intent(in) :: title

procedure, public :: set_xscale

  • private subroutine set_xscale(self, scale, threshold)

    Set x-axis scale type

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    character(len=*), intent(in) :: scale
    real(kind=wp), intent(in), optional :: threshold

procedure, public :: set_yscale

  • private subroutine set_yscale(self, scale, threshold)

    Set y-axis scale type

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    character(len=*), intent(in) :: scale
    real(kind=wp), intent(in), optional :: threshold

procedure, public :: set_xlim

  • private subroutine set_xlim(self, x_min, x_max)

    Set x-axis limits

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x_min
    real(kind=wp), intent(in) :: x_max

procedure, public :: set_ylim

  • private subroutine set_ylim(self, y_min, y_max)

    Set y-axis limits

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: y_min
    real(kind=wp), intent(in) :: y_max

procedure, public :: set_line_width

  • private subroutine set_line_width(self, width)

    Set line width for subsequent plots

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: width

procedure, public :: set_ydata

  • private subroutine set_ydata(self, plot_index, y_new)

    Update y data for an existing plot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    integer, intent(in) :: plot_index
    real(kind=wp), intent(in) :: y_new(:)

procedure, public :: legend => figure_legend

  • private subroutine figure_legend(self, location)

    Add legend to figure

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    character(len=*), intent(in), optional :: location

procedure, public :: show

  • private subroutine show(self, blocking)

    Display the figure

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    logical, intent(in), optional :: blocking

procedure, public :: clear_streamlines

  • private subroutine clear_streamlines(self)

    Clear streamline data

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self

procedure, public :: grid

  • private subroutine grid(self, enabled, which, axis, alpha, linestyle)

    Enable/disable and configure grid lines

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    logical, intent(in), optional :: enabled
    character(len=*), intent(in), optional :: which
    character(len=*), intent(in), optional :: axis
    real(kind=wp), intent(in), optional :: alpha
    character(len=*), intent(in), optional :: linestyle

procedure, public :: hist

  • private subroutine hist(self, data, bins, density, label, color)

    Create a histogram plot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: data(:)
    integer, intent(in), optional :: bins
    logical, intent(in), optional :: density
    character(len=*), intent(in), optional :: label
    real(kind=wp), intent(in), optional :: color(3)

procedure, public :: boxplot

  • private subroutine boxplot(self, data, position, width, label, show_outliers, horizontal, color)

    Create a box plot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: data(:)
    real(kind=wp), intent(in), optional :: position
    real(kind=wp), intent(in), optional :: width
    character(len=*), intent(in), optional :: label
    logical, intent(in), optional :: show_outliers
    logical, intent(in), optional :: horizontal
    character(len=*), intent(in), optional :: color

procedure, public :: scatter

  • private subroutine scatter(self, x, y, s, c, marker, markersize, color, colormap, alpha, edgecolor, facecolor, linewidth, vmin, vmax, label, show_colorbar)

    Add an efficient scatter plot using a single plot object Properly handles thousands of points without O(n) overhead

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x(:)
    real(kind=wp), intent(in) :: y(:)
    real(kind=wp), intent(in), optional :: s(:)
    real(kind=wp), intent(in), optional :: c(:)
    character(len=*), intent(in), optional :: marker
    real(kind=wp), intent(in), optional :: markersize
    real(kind=wp), intent(in), optional :: color(3)
    character(len=*), intent(in), optional :: colormap
    real(kind=wp), intent(in), optional :: alpha
    real(kind=wp), intent(in), optional :: edgecolor(3)
    real(kind=wp), intent(in), optional :: facecolor(3)
    real(kind=wp), intent(in), optional :: linewidth
    real(kind=wp), intent(in), optional :: vmin
    real(kind=wp), intent(in), optional :: vmax
    character(len=*), intent(in), optional :: label
    logical, intent(in), optional :: show_colorbar

procedure, public :: subplots

  • private subroutine subplots(self, nrows, ncols)

    Create a grid of subplots

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    integer, intent(in) :: nrows
    integer, intent(in) :: ncols

procedure, public :: subplot_plot

  • private subroutine subplot_plot(self, row, col, x, y, label, linestyle, color)

    Add a plot to a specific subplot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    integer, intent(in) :: row
    integer, intent(in) :: col
    real(kind=wp), intent(in) :: x(:)
    real(kind=wp), intent(in) :: y(:)
    character(len=*), intent(in), optional :: label
    character(len=*), intent(in), optional :: linestyle
    real(kind=wp), intent(in), optional :: color(3)

procedure, public :: subplot_plot_count

  • private function subplot_plot_count(self, row, col) result(count)

    Get the number of plots in a specific subplot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self
    integer, intent(in) :: row
    integer, intent(in) :: col

    Return Value integer

procedure, public :: subplot_set_title

  • private subroutine subplot_set_title(self, row, col, title)

    Set the title for a specific subplot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    integer, intent(in) :: row
    integer, intent(in) :: col
    character(len=*), intent(in) :: title

procedure, public :: subplot_set_xlabel

  • private subroutine subplot_set_xlabel(self, row, col, xlabel)

    Set the x-axis label for a specific subplot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    integer, intent(in) :: row
    integer, intent(in) :: col
    character(len=*), intent(in) :: xlabel

procedure, public :: subplot_set_ylabel

  • private subroutine subplot_set_ylabel(self, row, col, ylabel)

    Set the y-axis label for a specific subplot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    integer, intent(in) :: row
    integer, intent(in) :: col
    character(len=*), intent(in) :: ylabel

procedure, public :: subplot_title

  • private function subplot_title(self, row, col) result(title)

    Get the title for a specific subplot

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self
    integer, intent(in) :: row
    integer, intent(in) :: col

    Return Value character(len=:), allocatable

procedure, public :: get_width

  • private function get_width(self) result(width)

    Get figure width

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value integer

procedure, public :: get_height

  • private function get_height(self) result(height)

    Get figure height

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value integer

procedure, public :: get_rendered

  • private function get_rendered(self) result(rendered)

    Get rendered state

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value logical

procedure, public :: set_rendered

  • private subroutine set_rendered(self, rendered)

    Set rendered state

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    logical, intent(in) :: rendered

procedure, public :: get_plot_count

  • private function get_plot_count(self) result(plot_count)

    Get number of plots

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value integer

procedure, public :: get_plots

  • private function get_plots(self) result(plots_ptr)

    Get pointer to plots array

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in), target :: self

    Return Value type(plot_data_t), pointer, (:)

procedure, public :: setup_png_backend_for_animation

  • private subroutine setup_png_backend_for_animation(self)

    Setup PNG backend for animation (temporary method)

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self

procedure, public :: extract_rgb_data_for_animation

  • private subroutine extract_rgb_data_for_animation(self, rgb_data)

    Extract RGB data for animation

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(out) :: rgb_data(:,:,:)

procedure, public :: extract_png_data_for_animation

  • private subroutine extract_png_data_for_animation(self, png_data, status)

    Extract PNG data for animation

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    integer(kind=1), intent(out), allocatable :: png_data(:)
    integer, intent(out) :: status

procedure, public :: backend_color

  • private subroutine backend_color(self, r, g, b)

    Set backend color

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: r
    real(kind=wp), intent(in) :: g
    real(kind=wp), intent(in) :: b

procedure, public :: backend_line

  • private subroutine backend_line(self, x1, y1, x2, y2)

    Draw line using backend

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x1
    real(kind=wp), intent(in) :: y1
    real(kind=wp), intent(in) :: x2
    real(kind=wp), intent(in) :: y2

procedure, public :: backend_associated

  • private function backend_associated(self) result(is_associated)

    Check if backend is allocated

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value logical

procedure, public :: get_x_min

  • private function get_x_min(self) result(x_min)

    Get x minimum value

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value real(kind=wp)

procedure, public :: get_x_max

  • private function get_x_max(self) result(x_max)

    Get x maximum value

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value real(kind=wp)

procedure, public :: get_y_min

  • private function get_y_min(self) result(y_min)

    Get y minimum value

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value real(kind=wp)

procedure, public :: get_y_max

  • private function get_y_max(self) result(y_max)

    Get y maximum value

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(in) :: self

    Return Value real(kind=wp)