fortplot_matplotlib_session Module

Global figure session helpers shared across matplotlib-compatible wrappers

Provides lifecycle management for the singleton figure used by the matplotlib facade. Responsibilities include creating and reusing the global figure, grid/subplot helpers, and viewer integration utilities.



Functions

public function get_global_figure() result(global_fig)

Return the global figure pointer, initializing on demand

Arguments

None

Return Value class(figure_t), pointer

public function subplots_grid(nrows, ncols) result(axes)

Create subplot grid and return axis indices in row-major order

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nrows
integer, intent(in) :: ncols

Return Value integer, allocatable, (:,:)


Subroutines

public subroutine ion()

Enable interactive mode for live terminal visualization

Read more…

Arguments

None

public subroutine ioff()

Disable interactive mode

Arguments

None

public subroutine draw()

Redraw the current figure to terminal (ASCII output)

Read more…

Arguments

None

public subroutine pause(seconds)

Draw the current figure and pause for specified duration

Read more…

Arguments

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

public subroutine ensure_fig_init()

Ensure the global figure exists and is initialized

Arguments

None

public subroutine ensure_global_figure_initialized()

Public wrapper to guarantee the singleton is ready for use

Arguments

None

public subroutine figure(num, figsize, dpi)

Create a matplotlib-style figure using the shared singleton

Arguments

Type IntentOptional Attributes Name
integer, intent(in), optional :: num
real(kind=wp), intent(in), optional, dimension(2) :: figsize
integer, intent(in), optional :: dpi

public subroutine subplot(nrows, ncols, index)

Select a subplot in an nrows-by-ncols grid (matplotlib-compatible)

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nrows
integer, intent(in) :: ncols
integer, intent(in) :: index

public subroutine subplots(nrows, ncols)

Initialize a subplot grid using the global figure

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nrows
integer, intent(in) :: ncols

public subroutine savefig(filename, dpi, transparent, bbox_inches)

Save current figure using matplotlib-compatible API

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(in), optional :: dpi
logical, intent(in), optional :: transparent
character(len=*), intent(in), optional :: bbox_inches

public subroutine savefig_with_status(filename, status, dpi, transparent, bbox_inches)

Save figure and return status code for testing scenarios

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: filename
integer, intent(out) :: status
integer, intent(in), optional :: dpi
logical, intent(in), optional :: transparent
character(len=*), intent(in), optional :: bbox_inches

public subroutine show_data(x, y, label, title_text, xlabel_text, ylabel_text, blocking)

Convenience routine mirroring matplotlib.pyplot.show signature with data

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x(:)
real(kind=wp), intent(in) :: y(:)
character(len=*), intent(in), optional :: label
character(len=*), intent(in), optional :: title_text
character(len=*), intent(in), optional :: xlabel_text
character(len=*), intent(in), optional :: ylabel_text
logical, intent(in), optional :: blocking

public subroutine show_figure(blocking)

Show the global figure via backend implementation

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: blocking

public subroutine show_viewer(blocking)

Launch external viewer with saved figure artifact when available

Arguments

Type IntentOptional Attributes Name
logical, intent(in), optional :: blocking