To draw a graph in my winform application, i decided to use the ScottPlot library (version 5.0.36). I don’t understand how to set the bounds of the X-axis. I would like to always display values from 0 to N in the X axis.
I am using a FormsPlot and DataLoggers to store and update data. All the DataLoggers share the X axis. I set the FormsPlot limits and DataLoggers in the following way:
//Set the Plot x-axis limits as follows
formsPlot.Plot.Axes.SetLimitsX(0, 1000, formsPlot.Plot.Axes.Bottom);
...
DataLogger logger = formPlot.Plot.Add.DataLogger();
logger.ManageAxisLimits = true;
logger.AxisManager = new Slide
{
Width = 1000,
PaddingFractionX = .2,
PaddingFractionY = .2,
};
LeftAxis Yaxis = formPlot.Plot.Axes.AddLeftAxis();
logger.Axes.YAxis = Yaxis;
...
//coordinates are read from a json file
logger.Add(coordX, coordY);
By setting the limits as just described, I don’t understand why my x-axis limits go from about -600 to 400.
example of the graph with the wrong limits
2
If you want a fixed Axis all the time that doesn’t change you can use LockedVertical/Horizontal Rules or if you want it to expand with your data logger you can simply set the Plot.Axes.ContinuouslyAutoscale = true;
or even call the AutoScale every time you insert new data.