-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Description
Hi guys, is it possible to set a limit on the Y-axis when using a Datalogger?
I know I can set a rule to lock the Y-axis and manually give it tick values, but doing so means the y-axis cannot be expanded dynamically.
ScottPlot Version: WPF SP5 v5.0.45
Code Sample:
public partial class MainWindow : Window
{
readonly System.Windows.Forms.Timer AddNewDataTimer = new() { Interval = 50, Enabled = true };
ScottPlot.Plottables.DataLogger Logger1;
public MainWindow()
{
InitializeComponent();
InitializeGraph();
}
private void InitializeGraph()
{
myPlot.Plot.Axes.InvertY();
Logger1 = myPlot.Plot.Add.DataLogger();
Logger1.Axes.YAxis = myPlot.Plot.Axes.Left;
// Attempting to set some kind of limit ...
myPlot.Plot.Axes.MarginsY(0);
myPlot.Plot.Axes.SetLimitsY(0, 50);
Logger1.Axes.YAxis.Range.Set(0, 50);
DateTime startOfGraphTime = DateTime.Now;
Random numGenerator = new Random();
AddNewDataTimer.Tick += (s, e) =>
{
// Attemping to set some kind of limit ...
myPlot.Plot.Axes.Left.Min = 0;
Logger1.Axes.YAxis.Min = 0;
TimeSpan timeSinceStart = DateTime.Now - startOfGraphTime;
double seconds = timeSinceStart.TotalSeconds;
Logger1.Add(seconds, numGenerator.Next(0, 50));
myPlot.Refresh();
};
}
}-
In this example it is impossible to get a value under 0 or over 50, yet the y-axis shows values outside of this range which are not needed.
-
I inverted the y-axis with
myPlot.Plot.Axes.InvertY();. But as soon as a DataLogger is added to the plot, the Y-axis becomes uninverted. Is there a way to fix this?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
