figure_t Derived Type

type, public :: figure_t

Main figure class implementing Facade Pattern for plotting operations

This type provides a unified interface for all figure operations while delegating implementation details to specialized modules. The design follows object-oriented principles with clear separation of concerns.


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(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)

    Arguments

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

Type-Bound Procedures

procedure, public :: initialize

  • private subroutine initialize(self, width, height, 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)

    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 :: plot => add_plot

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

    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)

    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)

    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_surface

  • private subroutine add_surface(self, x_grid, y_grid, z_grid, label, colormap, show_colorbar, alpha, edgecolor, linewidth)

    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(:,:)
    character(len=*), intent(in), optional :: label
    character(len=*), intent(in), optional :: colormap
    logical, intent(in), optional :: show_colorbar
    real(kind=wp), intent(in), optional :: alpha
    real(kind=wp), intent(in), optional :: edgecolor(3)
    real(kind=wp), intent(in), optional :: linewidth

procedure, public :: add_pcolormesh

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

    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)

    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 :: save => 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)

    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)

    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)

    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)

    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)

    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)

    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)

    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)

    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)

    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)

    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

  • private subroutine clear(self)

    Clear the figure for reuse, preserving backend settings

    Arguments

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

procedure, public :: clear_streamlines

  • private subroutine clear_streamlines(self)

    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 :: add_hist

  • private subroutine add_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 :: hist => add_hist

  • private subroutine add_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 :: add_imshow

  • interface

    private module subroutine add_imshow(self, z, xlim, ylim, cmap, alpha, vmin, vmax, origin, extent, interpolation, aspect)

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: z(:,:)
    real(kind=wp), intent(in), optional :: xlim(2)
    real(kind=wp), intent(in), optional :: ylim(2)
    character(len=*), intent(in), optional :: cmap
    real(kind=wp), intent(in), optional :: alpha
    real(kind=wp), intent(in), optional :: vmin
    real(kind=wp), intent(in), optional :: vmax
    character(len=*), intent(in), optional :: origin
    real(kind=wp), intent(in), optional :: extent(4)
    character(len=*), intent(in), optional :: interpolation
    character(len=*), intent(in), optional :: aspect

procedure, public :: add_pie

  • interface

    private module subroutine add_pie(self, values, labels, autopct, startangle, colors, explode)

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: values(:)
    character(len=*), intent(in), optional :: labels(:)
    character(len=*), intent(in), optional :: autopct
    real(kind=wp), intent(in), optional :: startangle
    character(len=*), intent(in), optional :: colors(:)
    real(kind=wp), intent(in), optional :: explode(:)

procedure, public :: add_polar

  • interface

    private module subroutine add_polar(self, theta, r, label, fmt, linestyle, marker, color)

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: theta(:)
    real(kind=wp), intent(in) :: r(:)
    character(len=*), intent(in), optional :: label
    character(len=*), intent(in), optional :: fmt
    character(len=*), intent(in), optional :: linestyle
    character(len=*), intent(in), optional :: marker
    character(len=*), intent(in), optional :: color

procedure, public :: add_step

  • interface

    private module subroutine add_step(self, x, y, label, where, linestyle, color, linewidth)

    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 :: where
    character(len=*), intent(in), optional :: linestyle
    character(len=*), intent(in), optional :: color
    real(kind=wp), intent(in), optional :: linewidth

procedure, public :: add_stem

  • interface

    private module subroutine add_stem(self, x, y, label, linefmt, markerfmt, basefmt, bottom)

    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 :: linefmt
    character(len=*), intent(in), optional :: markerfmt
    character(len=*), intent(in), optional :: basefmt
    real(kind=wp), intent(in), optional :: bottom

procedure, public :: add_fill

  • interface

    private module subroutine add_fill(self, x, y, color, alpha)

    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 :: color
    real(kind=wp), intent(in), optional :: alpha

procedure, public :: add_fill_between

  • interface

    private module subroutine add_fill_between(self, x, y1, y2, where, color, alpha, interpolate)

    Arguments

    Type IntentOptional Attributes Name
    class(figure_t), intent(inout) :: self
    real(kind=wp), intent(in) :: x(:)
    real(kind=wp), intent(in), optional :: y1(:)
    real(kind=wp), intent(in), optional :: y2(:)
    logical, intent(in), optional :: where(:)
    character(len=*), intent(in), optional :: color
    real(kind=wp), intent(in), optional :: alpha
    logical, intent(in), optional :: interpolate

procedure, public :: twinx

  • private subroutine twinx(self)

    Arguments

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

procedure, public :: twiny

  • private subroutine twiny(self)

    Arguments

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

procedure, public :: use_axis

  • private subroutine use_axis(self, axis_name)

    Arguments

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

procedure, public :: get_active_axis

  • private function get_active_axis(self) result(axis_name)

    Arguments

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

    Return Value character(len=10)

procedure, public :: subplots

  • private subroutine subplots(self, nrows, ncols)

    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)

    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)

    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)

    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)

    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)

    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)

    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)

    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)

    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)

    Arguments

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

    Return Value logical

procedure, public :: set_rendered

  • private subroutine set_rendered(self, rendered)

    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)

    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)

    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)

    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)

    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)

    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)

    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)

    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_arrow

  • private subroutine backend_arrow(self, x, y, dx, dy, size, style)

    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) :: dx
    real(kind=wp), intent(in) :: dy
    real(kind=wp), intent(in) :: size
    character(len=*), intent(in) :: style

procedure, public :: clear_backend_arrows

  • private subroutine clear_backend_arrows(self)

    Arguments

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

procedure, public :: backend_associated

  • private function backend_associated(self) result(is_associated)

    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)

    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)

    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)

    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)

    Arguments

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

    Return Value real(kind=wp)