Step 1: Install the ScottPlot
NuGet package
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 thatPlot
andShow()
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
MacOS & Linux
ScottPlot relies on System.Drawing.Common
which requires libgdiplus on non-Windows systems:
-
MacOS:
brew install mono-libgdiplus
-
Linux:
apt-get install -y libgdiplus
You may also need to specifically add the System.Drawing.Common
package to your project:
dotnet add package System.Drawing.Common