plotter

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package plotter provides SVG visualization for ODE solutions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PlotData

type PlotData struct {
	PlotID     string
	Margin     map[string]float64
	PlotWidth  float64
	PlotHeight float64
	Xmin       float64
	Xmax       float64
	Ymin       float64
	Ymax       float64
	Series     []Series
}

PlotData contains metadata about the last rendered plot. This can be used for interactive features like crosshairs and tooltips.

func PlotSolution

func PlotSolution(sol *solver.Solution, variables []string, width, height float64, title, xlabel, ylabel string) (string, *PlotData)

PlotSolution is a convenience function to plot an ODE solution. If variables is nil, all state variables will be plotted.

type SVGPlotter

type SVGPlotter struct {
	Width      float64
	Height     float64
	Margin     map[string]float64
	PlotWidth  float64
	PlotHeight float64
	Title      string
	XLabel     string
	YLabel     string
	Series     []Series
	LastPlot   *PlotData
}

SVGPlotter creates SVG plots with customizable styling.

func NewSVGPlotter

func NewSVGPlotter(width, height float64) *SVGPlotter

NewSVGPlotter creates a new SVG plotter with the given dimensions.

func (*SVGPlotter) AddSeries

func (p *SVGPlotter) AddSeries(x, y []float64, label, color string) *SVGPlotter

AddSeries adds a data series to the plot. If color is empty, a default color from a palette will be used.

func (*SVGPlotter) Render

func (p *SVGPlotter) Render() string

Render generates the SVG string and stores metadata in LastPlot.

func (*SVGPlotter) SetTitle

func (p *SVGPlotter) SetTitle(t string) *SVGPlotter

SetTitle sets the plot title.

func (*SVGPlotter) SetXLabel

func (p *SVGPlotter) SetXLabel(s string) *SVGPlotter

SetXLabel sets the X-axis label.

func (*SVGPlotter) SetYLabel

func (p *SVGPlotter) SetYLabel(s string) *SVGPlotter

SetYLabel sets the Y-axis label.

type Series

type Series struct {
	X     []float64
	Y     []float64
	Label string
	Color string
}

Series represents a single data series to plot.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL