Log Scale with Custom Tick Marks
Placement of minor tick marks in plots with logarithmic axes may my customized using a custom minor tick generator. Some may be bundled with ScottPlot as shown here, but users may create their own and apply them as seen here.
ScottPlot.Plot myPlot = new();
double[] xs = Generate.Consecutive(100);
double[] logYs = Generate.NoisyExponential(100).Select(Math.Log10).ToArray();
var sp = myPlot.Add.ScatterPoints(xs, logYs);
// this tick generator places 10 ticks (decimal distribution) between major log ticks
IMinorTickGenerator minorTickGen = new ScottPlot.TickGenerators.LogDecadeMinorTickGenerator();
// create a numeric tick generator that uses our custom minor tick generator
ScottPlot.TickGenerators.NumericAutomatic tickGen = new()
{
MinorTickGenerator = minorTickGen,
IntegerTicksOnly = true,
LabelFormatter = (double y) => $"{Math.Pow(10, y):N0}",
};
// tell the left axis to use our custom tick generator and configure the grid to show ticks
myPlot.Axes.Left.TickGenerator = tickGen;
myPlot.Grid.MajorLineColor = Colors.Black.WithOpacity(.15);
myPlot.Grid.MinorLineColor = Colors.Black.WithOpacity(.05);
myPlot.Grid.MinorLineWidth = 1;
myPlot.SavePng("demo.png", 400, 300);
This recipe is one of many in the Customizing Ticks category
