Custom DateTime Label Format
Users can provide their own logic for customizing DateTime tick labels
ScottPlot.Plot myPlot = new();
// plot sample DateTime data
DateTime[] dates = Generate.ConsecutiveDays(100);
double[] ys = Generate.RandomWalk(100);
myPlot.Add.Scatter(dates, ys);
myPlot.Axes.DateTimeTicksBottom();
// add logic into the RenderStarting event to customize tick labels
myPlot.RenderManager.RenderStarting += (s, e) =>
{
Tick[] ticks = myPlot.Axes.Bottom.TickGenerator.Ticks;
for (int i = 0; i < ticks.Length; i++)
{
DateTime dt = DateTime.FromOADate(ticks[i].Position);
string label = $"{dt:MMM} '{dt:yy}";
ticks[i] = new Tick(ticks[i].Position, label);
}
};
myPlot.SavePng("demo.png", 400, 300);
This recipe is one of many in the Axis and Ticks category
