ScottPlot.NET
How to create a plot and save it as an image from a C# console application

Step 1: Install the ScottPlot NuGet package. Linux & MacOS users must take these additional steps.

Step 2: Plot some data and save the figure as an image file

double[] dataX = new double[] { 1, 2, 3, 4, 5 };
double[] dataY = new double[] { 1, 4, 9, 16, 25 };
var plt = new ScottPlot.Plot(400, 300);
plt.AddScatter(dataX, dataY);
plt.SaveFig("quickstart.png");

Launch an Interactive Window

Plots created in console applications can be launched in a pop-up window allowing interactive pan and zoom:

  • Install ScottPlot.WinForms (or one of the other ScottPlot control libraries)
  • Create a Plot as described above
  • Instantiate a PlotViewer with that Plot and Show() it
double[] dataX = new double[] { 1, 2, 3, 4, 5 };
double[] dataY = new double[] { 1, 4, 9, 16, 25 };
var plt = new ScottPlot.Plot(400, 300);
plt.AddScatter(dataX, dataY);
new ScottPlot.FormsPlotViewer(plt).ShowDialog();

💡 Interactive plots using the WinForms and WPF controls require the console application to target Windows, but a strategy for launching interactive plots from console applications running on Linux using Avalonia is described in #1769