In Shared Axes while zooming Y Axis, only Y1 scale is updating for all the graphs but Y2 scale is not updating
kareem469 opened this issue · 9 comments
Y2 Scale not updating while zooming Y axis using Shared Axes
ScottPlot Version:5.0.34
While using Shared Axes when zooming Y Axis, only Y1 scale is updating for all the graphs but Y2 scale is not updating.
Hi @kareem469, I think you are referring to https://scottplot.net/demo/#shared-axes
Sharing the X but not Y limits was intentional. You can modify this line to achieve the behavior you are looking for.
Here, the Y1 axis (left side) is updating for all the graphs. But the Y2 axis (right side) is not updating.
Following is the code sample i have used
foreach (var plot in plots)
{
if (plot != sourcePlot)
{
AxisLimits axesBefore = destPlot.Plot.Axes.GetLimits();
if(GraphZoomAxisTypes.XY.ToString() == cmbAxisType.Text)
plot.Plot.Axes.SetLimits(sourcePlot.Plot.Axes.GetLimits());
else if(GraphZoomAxisTypes.Y.ToString() == cmbAxisType.Text)
plot.Plot.Axes.SetLimitsY(sourcePlot.Plot.Axes.GetLimits());
else if(GraphZoomAxisTypes.X.ToString() == cmbAxisType.Text)
plot.Plot.Axes.SetLimitsX(sourcePlot.Plot.Axes.GetLimits());
AxisLimits axesAfter = plot.Plot.Axes.GetLimits();
if (axesBefore != axesAfter)
plot .Refresh();
}
}
Thanks in advance.
But the Y2 axis (right side) is not updating.
SetLimits() works on the bottom and left axes by default, but there are overloads which let you pass in the right axis and it will adjust that axis.
Hi @swharden
Can you provide the information about the overloads which let me pass in the right axis and it will adjust that axis.
Can you provide the information about the overloads
I'm on a cell phone at the moment, but if you're using Visual Studio and start typing the method, a tooltip will pop up displaying the different overloads that are available. Ones that accept an IYAxis
will allow you to pass in plot.Plot.Axes.Right