fortplot_figure_operations Module

Figure core operations module for fortplot_figure_core

This module handles core plotting operations, rendering pipeline, and plot data management. Extracted from fortplot_figure_core.f90 for better organization following Single Responsibility Principle.

Responsibilities: - Plot operations (add_plot, add_contour, add_pcolormesh, etc.) - Axis configuration (set_xlim, set_ylim, set_xlabel, etc.) - Grid configuration - Legend management - Rendering pipeline coordination



Subroutines

public subroutine figure_add_plot_operation(plots, state, x, y, label, linestyle, color)

Add a line plot to the figure

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
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)

public subroutine figure_add_contour_operation(plots, state, x_grid, y_grid, z_grid, levels, label)

Add a contour plot to the figure

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
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

public subroutine figure_add_contour_filled_operation(plots, state, x_grid, y_grid, z_grid, levels, colormap, show_colorbar, label)

Add a filled contour plot with color mapping

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
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

public subroutine figure_add_surface_operation(plots, state, x_grid, y_grid, z_grid, label, colormap, show_colorbar, alpha, edgecolor, linewidth)

Add a 3D surface plot to the figure

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
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

public subroutine figure_add_pcolormesh_operation(plots, state, x, y, c, colormap, vmin, vmax, edgecolors, linewidths)

Add a pcolormesh plot

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
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

public subroutine figure_add_fill_between_operation(plots, state, x, upper, lower, mask, color_string, alpha)

Add an area fill between two curves

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
real(kind=wp), intent(in) :: x(:)
real(kind=wp), intent(in) :: upper(:)
real(kind=wp), intent(in) :: lower(:)
logical, intent(in), optional :: mask(:)
character(len=*), intent(in), optional :: color_string
real(kind=wp), intent(in), optional :: alpha

public subroutine figure_add_pie_operation(plots, state, values, labels, startangle, color_strings, explode, autopct)

Add a pie chart to the figure

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
real(kind=wp), intent(in) :: values(:)
character(len=*), intent(in), optional :: labels(:)
real(kind=wp), intent(in), optional :: startangle
character(len=*), intent(in), optional :: color_strings(:)
real(kind=wp), intent(in), optional :: explode(:)
character(len=*), intent(in), optional :: autopct

public subroutine figure_streamplot_operation(plots, state, plot_count, x, y, u, v, density, color)

Add streamline plot to figure using basic algorithm

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
integer, intent(inout) :: plot_count
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)

public subroutine figure_hist_operation(plots, state, plot_count, data, bins, density, label, color)

Create a histogram plot

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
type(figure_state_t), intent(inout) :: state
integer, intent(inout) :: plot_count
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)

public subroutine figure_boxplot_operation(state, plots, plot_count, data, position, width, label, show_outliers, horizontal, color, max_plots)

Create a box plot

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(in) :: state
type(plot_data_t), intent(inout), allocatable :: plots(:)
integer, intent(inout) :: plot_count
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
integer, intent(in) :: max_plots

public subroutine figure_scatter_operation(state, plots, plot_count, x, y, s, c, marker, markersize, color, colormap, vmin, vmax, label, show_colorbar, default_color)

Add an efficient scatter plot using a single plot object

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(in) :: state
type(plot_data_t), intent(inout), allocatable :: plots(:)
integer, intent(inout) :: plot_count
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 :: vmin
real(kind=wp), intent(in), optional :: vmax
character(len=*), intent(in), optional :: label
logical, intent(in), optional :: show_colorbar
real(kind=wp), intent(in) :: default_color(3)

public subroutine figure_set_xlabel_operation(state, xlabel_target, label)

Set x-axis label

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
character(len=:), intent(inout), allocatable :: xlabel_target
character(len=*), intent(in) :: label

public subroutine figure_set_ylabel_operation(state, ylabel_target, label)

Set y-axis label

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
character(len=:), intent(inout), allocatable :: ylabel_target
character(len=*), intent(in) :: label

public subroutine figure_set_title_operation(state, title_target, title)

Set figure title

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
character(len=:), intent(inout), allocatable :: title_target
character(len=*), intent(in) :: title

public subroutine figure_set_xscale_operation(state, scale, threshold)

Set x-axis scale type

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
character(len=*), intent(in) :: scale
real(kind=wp), intent(in), optional :: threshold

public subroutine figure_set_yscale_operation(state, scale, threshold)

Set y-axis scale type

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
character(len=*), intent(in) :: scale
real(kind=wp), intent(in), optional :: threshold

public subroutine figure_set_xlim_operation(state, x_min, x_max)

Set x-axis limits

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
real(kind=wp), intent(in) :: x_min
real(kind=wp), intent(in) :: x_max

public subroutine figure_set_ylim_operation(state, y_min, y_max)

Set y-axis limits

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
real(kind=wp), intent(in) :: y_min
real(kind=wp), intent(in) :: y_max

public subroutine figure_set_line_width_operation(state, width)

Set line width for subsequent plots

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
real(kind=wp), intent(in) :: width

public subroutine figure_set_ydata_operation(plots, plot_count, plot_index, y_new)

Update y data for an existing plot

Arguments

Type IntentOptional Attributes Name
type(plot_data_t), intent(inout) :: plots(:)
integer, intent(in) :: plot_count
integer, intent(in) :: plot_index
real(kind=wp), intent(in) :: y_new(:)

public subroutine figure_legend_operation(legend_data, show_legend, plots, plot_count, location, backend_name)

Add legend to figure

Arguments

Type IntentOptional Attributes Name
type(legend_t), intent(inout) :: legend_data
logical, intent(inout) :: show_legend
type(plot_data_t), intent(in) :: plots(:)
integer, intent(in) :: plot_count
character(len=*), intent(in), optional :: location
character(len=*), intent(in) :: backend_name

public subroutine figure_grid_operation(state, enabled, which, axis, alpha, linestyle)

Enable/disable and configure grid lines

Arguments

Type IntentOptional Attributes Name
type(figure_state_t), intent(inout) :: state
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