public void AxisAuto( double horizontalMargin = .1, double verticalMargin = .1, bool xExpandOnly = false, bool yExpandOnly = false, bool autoX = true, bool autoY = true ) { var oldLimits = new AxisLimits2D(axes.ToArray()); var newLimits = new AxisLimits2D(); foreach (var plottable in plottables) { AxisLimits2D plottableLimits = plottable.GetLimits(); if (autoX && !yExpandOnly) { newLimits.ExpandX(plottableLimits); } if (autoY && !xExpandOnly) { newLimits.ExpandY(plottableLimits); } } newLimits.MakeRational(); if (axes.equalAxes) { var xUnitsPerPixel = newLimits.xSpan / (dataSize.Width * (1 - horizontalMargin)); var yUnitsPerPixel = newLimits.ySpan / (dataSize.Height * (1 - verticalMargin)); axes.Set(newLimits); if (yUnitsPerPixel > xUnitsPerPixel) { axes.Zoom((1 - horizontalMargin) * xUnitsPerPixel / yUnitsPerPixel, 1 - verticalMargin); } else { axes.Zoom(1 - horizontalMargin, (1 - verticalMargin) * yUnitsPerPixel / xUnitsPerPixel); } return; } if (xExpandOnly) { oldLimits.ExpandX(newLimits); axes.Set(oldLimits.x1, oldLimits.x2, null, null); axes.Zoom(1 - horizontalMargin, 1); } if (yExpandOnly) { oldLimits.ExpandY(newLimits); axes.Set(null, null, oldLimits.y1, oldLimits.y2); axes.Zoom(1, 1 - verticalMargin); } if ((!xExpandOnly) && (!yExpandOnly)) { axes.Set(newLimits); axes.Zoom(1 - horizontalMargin, 1 - verticalMargin); } if (plottables.Count == 0) { axes.x.hasBeenSet = false; axes.y.hasBeenSet = false; } layout.tighteningOccurred = false; }
public void Set(AxisLimits2D limits) { limits.MakeRational(); Set(limits.x1, limits.x2, limits.y1, limits.y2); }