fortplot_spec_types Module

Vega-Lite-shaped specification types for fortplot

Defines Fortran derived types that map 1:1 to Vega-Lite schema fields. These types serve as the single source of truth for plot specifications, decoupling frontend API from backend rendering.

The Fortran API builds spec_t directly (no JSON overhead). JSON is a serialization layer for interop with Vega ecosystem.



Derived Types

type, public ::  axis_t

Axis configuration (maps to Vega-Lite axis object)

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: title
logical, public :: grid = .false.
real(kind=wp), public :: grid_opacity = -1.0_wp
real(kind=wp), public :: label_angle = 0.0_wp
logical, public :: title_set = .false.
real(kind=wp), public, allocatable :: tick_values(:)
character(len=:), public, allocatable :: format

type, public ::  scale_t

Scale configuration (maps to Vega-Lite scale object) Supported types: linear, log, pow, sqrt, symlog, ordinal, band, point

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: type
real(kind=wp), public :: domain_min = 0.0_wp
real(kind=wp), public :: domain_max = 0.0_wp
logical, public :: domain_set = .false.
logical, public :: zero = .false.
real(kind=wp), public :: exponent = 1.0_wp

type, public ::  channel_t

Encoding channel (maps to Vega-Lite channel object) Connects a data field to a visual property.

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: field
character(len=:), public, allocatable :: type
type(scale_t), public :: scale
type(axis_t), public :: axis
character(len=:), public, allocatable :: value
logical, public :: defined = .false.

type, public ::  encoding_t

Encoding specification (maps to Vega-Lite encoding object) Maps data fields to visual channels.

Components

Type Visibility Attributes Name Initial
type(channel_t), public :: x
type(channel_t), public :: y
type(channel_t), public :: x2
type(channel_t), public :: y2
type(channel_t), public :: color
type(channel_t), public :: size
type(channel_t), public :: shape
type(channel_t), public :: opacity
type(channel_t), public :: text

type, public ::  mark_t

Mark specification (maps to Vega-Lite mark object) Defines the visual representation type and properties.

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: type
real(kind=wp), public :: size = -1.0_wp
real(kind=wp), public :: opacity = 1.0_wp
real(kind=wp), public :: stroke_width = -1.0_wp
real(kind=wp), public, allocatable :: stroke_dash(:)
character(len=:), public, allocatable :: stroke
character(len=:), public, allocatable :: fill
logical, public :: filled = .true.
character(len=:), public, allocatable :: interpolate
character(len=:), public, allocatable :: point

type, public ::  data_column_t

Single named column of data values

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: field
real(kind=wp), public, allocatable :: values(:)
character(len=:), public, allocatable :: string_values(:)
logical, public :: is_string = .false.

type, public ::  data_t

Data specification (maps to Vega-Lite data object) Stores inline values as named columns (Fortran-native layout). Serialized to row-oriented JSON for Vega-Lite compatibility.

Components

Type Visibility Attributes Name Initial
type(data_column_t), public, allocatable :: columns(:)
integer, public :: nrows = 0

type, public ::  field_plot_t

fortplot-specific field-plot metadata carried alongside the Vega-Lite-shaped spec for contour, pcolormesh, and streamplot data.

Components

Type Visibility Attributes Name Initial
real(kind=wp), public, allocatable :: x(:)
real(kind=wp), public, allocatable :: y(:)
real(kind=wp), public, allocatable :: z(:)
real(kind=wp), public, allocatable :: u(:)
real(kind=wp), public, allocatable :: v(:)
real(kind=wp), public, allocatable :: levels(:)
integer, public :: nrows = 0
integer, public :: ncols = 0
logical, public :: defined = .false.
character(len=:), public, allocatable :: colormap
logical, public :: show_colorbar = .false.
logical, public :: show_colorbar_set = .false.
real(kind=wp), public :: density = -1.0_wp
real(kind=wp), public :: vmin = 0.0_wp
real(kind=wp), public :: vmax = 0.0_wp
logical, public :: vmin_set = .false.
logical, public :: vmax_set = .false.
real(kind=wp), public :: linewidths = -1.0_wp

type, public ::  layer_t

Single layer within a layered spec

Components

Type Visibility Attributes Name Initial
type(mark_t), public :: mark
type(encoding_t), public :: encoding
type(data_t), public :: data
type(field_plot_t), public :: field
logical, public :: has_data = .false.

type, public ::  spec_t

Top-level Vega-Lite specification Single source of truth for a plot. The Fortran plot() API is syntactic sugar that builds a spec_t.

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: schema
type(mark_t), public :: mark
type(encoding_t), public :: encoding
type(data_t), public :: data
type(field_plot_t), public :: field
character(len=:), public, allocatable :: title
integer, public :: width = 400
integer, public :: height = 300
type(layer_t), public, allocatable :: layers(:)
integer, public :: layer_count = 0
logical, public :: is_layered = .false.
type(config_t), public :: config
type(padding_t), public :: padding
character(len=:), public, allocatable :: autosize_type