Skip to content

Package fnplot provides a way to plot input/output values for arbitrary functions on a 2D cartesian coordinate plot.

License

Notifications You must be signed in to change notification settings

matthewdale/fnplot

Folders and files

NameName
Last commit message
Last commit date
Jun 30, 2019
Sep 10, 2018
Sep 10, 2018
Jun 30, 2019
Nov 23, 2018
Sep 10, 2018
Jul 1, 2019
Jul 1, 2019
Jul 1, 2019
Nov 23, 2018
Nov 23, 2018
Nov 23, 2018

Repository files navigation

fnplot Build Status codecov Go Report Card GoDoc

Package fnplot provides a way to plot input/output values for arbitrary functions on a 2D cartesian coordinate plot. The input/output values are converted to scalar values (arbitrary precision floating point) in a way that attempts to preserve the relative scale of the original values.

Examples

Numeric Functions

Plot the math.Sin function between 0 and 100 on the X axis.

import (
    "math"
    "github.com/matthewdale/fnplot"
)

func main() {
    err := fnplot.FnPlot{
		Fn: fnplot.NewFn(
			math.Sin,
			2000,
			fnplot.Float64Range(0, 100),
		),
		Title: "math.Sin",
		X:     &fnplot.StdAxix{},
		Y:     &fnplot.StdAxix{},
	}.Save("sin.png")

    if err != nil {
        panic(err)
    }
}

Byte Functions

Plot the md5.Sum function using a natural log X axis and scaled Y axis.

import (
    "crypto/md5"
    "github.com/matthewdale/fnplot"
)

func main() {
    err := fnplot.FnPlot{
		Fn: fnplot.NewFn(
			func(s string) [md5.Size]byte {
				return md5.Sum([]byte(s))
			},
			2000,
			fnplot.AnyString()),
		Title: "md5.Sum",
		X:     &fnplot.LnAxis{},
		Y:     &fnplot.ScaledAxis{Max: 1000},
	}.Save("md5.png")

    if err != nil {
        panic(err)
    }
}

About

Package fnplot provides a way to plot input/output values for arbitrary functions on a 2D cartesian coordinate plot.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages