// Install the ScottPlot NuGet package
#r "nuget:ScottPlot"
// Setup a custom formatter to display plots as images
using Microsoft.DotNet.Interactive.Formatting;
Formatter.Register(typeof(ScottPlot.Plot), (p, w) =>
w.Write(((ScottPlot.Plot)p).GetImageHTML()), HtmlFormatter.MimeType);
// create sample data
double[] xs = { 1, 2, 3, 4, 5 };
double[] ys = { 1, 4, 9, 16, 25 };
// plot the data
ScottPlot.Plot plt = new(400, 300);
plt.AddScatter(xs, ys);
// show the plot
plt
// create sample data
double[] xs = ScottPlot.DataGen.RandomNormal(Random.Shared, 500);
double[] ys = ScottPlot.DataGen.RandomNormal(Random.Shared, 500);
// plot the data
ScottPlot.Plot plt = new(400, 300);
plt.AddScatterPoints(xs, ys);
plt.XLabel("Horizontal Axis");
plt.YLabel("Vertical Axis");
plt.Title("Scatter Plot");
// display the plot
plt
// create sample data
double[] xs = ScottPlot.DataGen.Consecutive(500);
double[] ys = ScottPlot.DataGen.RandomWalk(Random.Shared, 500);
// plot the data
ScottPlot.Plot plt = new(400, 300);
plt.AddScatterLines(xs, ys);
plt.XLabel("Horizontal Axis");
plt.YLabel("Vertical Axis");
plt.Title("Scatter Plot");
// display the plot
plt
// create sample data
double[] values = { 26, 20, 23, 7, 16 };
double[] positions = { 0, 1, 2, 3, 4 };
string[] labels = { "PHP", "JS", "C++", "GO", "VB" };
// plot the data
ScottPlot.Plot plt = new(600, 400);
plt.AddBar(values, positions);
plt.XTicks(positions, labels);
plt.SetAxisLimits(yMin: 0);
// display the plot
plt
// create sample data
double[] values = { 778, 43, 283, 76, 184 };
string[] labels = { "C#", "JAVA", "Python", "F#", "PHP" };
// plot the data
ScottPlot.Plot plt = new(600, 400);
var pie = plt.AddPie(values);
pie.SliceLabels = labels;
pie.ShowLabels = true;
// show the plot
plt