ScottPlot.NET
Plot data values on a DataTime axes

This page is part of the ScottPlot 5.0 Cookbook

DateTime Axis Quickstart

.

ScottPlot.Plot myPlot = new();

// begin with an array of DateTime values
DateTime[] dates = Generate.DateTime.Days(100);

// convert DateTime to OLE Automation (OADate) format
double[] xs = dates.Select(x => x.ToOADate()).ToArray();
double[] ys = Generate.RandomWalk(xs.Length);
myPlot.Add.Scatter(xs, ys);

// tell the plot to display dates on the bottom axis
myPlot.AxisStyler.DateTimeTicks(Edge.Bottom);

myPlot.SavePng("datetime-axis-quickstart.png");