Language: EN


How to create charts in C# with the ScottPlot library

ScottPlot is a free and open-source library for data visualization and charting in .NET.

With ScottPlot we can create all kinds of high-quality charts with little effort and almost no code.

We can create line, bar, pie, scatter, bubble, and gauge charts, among many others.

Also, as expected, we can customize a large number of options, from axes, colors, font sizes, legends, data labels.

ScottPlot is compatible with NET6 so it works on Windows, Linux, and macOS, and can be used in WinForms, WPF, Console, Avalonia, PowerShell, among others.

How to use ScottPlot

We can add the library to a .NET project easily, through the corresponding Nuget package.

Install-Package ScottPlot

Now we can create our charts easily. For example, the following code creates a scatter plot, and saves the image in png.

double[] xs = new double[] {1, 2, 3, 4, 5};
double[] ys = new double[] {1, 4, 9, 16, 25};

var plt = new ScottPlot.Plot(400, 300);
plt.AddScatter(xs, ys);


While the following would generate a simple bar chart.

double[] values = { 26, 20, 23, 7, 16 };

var plt = new ScottPlot.Plot(600, 400);
plt.SetAxisLimits(yMin: 0);


There are many more types of examples and options that we can touch. Fortunately, the documentation and examples are one of the strongest points of ScottPlot.

You have a lot of examples of both types of charts and customization options in the ScottPlot 4.1 Cookbook.

ScottPlot is Open Source, and all of its code is available on GitHub - ScottPlot/ScottPlot: Interactive plotting library for .NET