ScottPlot.NET
GitHub Repo stars

Function

Function Quickstart

Create a function plot from a formula.

This code sample is specific to ScottPlot 5 (details)
ScottPlot.Plot myPlot = new();

// Functions are defined as delegates with an input and output
var func1 = new Func<double, double>((x) => Math.Sin(x) * Math.Sin(x / 2));
var func2 = new Func<double, double>((x) => Math.Sin(x) * Math.Sin(x / 3));
var func3 = new Func<double, double>((x) => Math.Cos(x) * Math.Sin(x / 5));

// Add functions to the plot
myPlot.Add.Function(func1);
myPlot.Add.Function(func2);
myPlot.Add.Function(func3);

// Manually set axis limits because functions do not have discrete data points
myPlot.Axes.SetLimits(-10, 10, -1.5, 1.5);

myPlot.SavePng("demo.png", 400, 300);