public void AutoAxis(double marginX = .1, double marginY = .1) { // auto axis for primary XY var primaryPlottables = GetPlottableList(false); if (primaryPlottables.Count > 0) { axes.Set(primaryPlottables[0].GetDataArea()); for (int i = 1; i < primaryPlottables.Count; i++) { axes.Expand(primaryPlottables[i].GetDataArea()); } } axes.Zoom(1 - marginX, 1 - marginY); // auto axis for secondary XY var secondaryPlottables = GetPlottableList(true); if (secondaryPlottables.Count > 0) { axes2.Set(secondaryPlottables[0].GetDataArea()); for (int i = 1; i < secondaryPlottables.Count; i++) { axes2.Expand(secondaryPlottables[i].GetDataArea()); } } axes2.Zoom(1 - marginX, 1 - marginY); axes2.x = axes.x; }
/// <summary> /// Automatically set axis limits to fit the data (with a margin of padding) /// </summary> public void AutoAxis( double marginX = .05, double marginY = .1, bool primaryY = true, bool secondaryY = true ) { if (primaryY) { var primaryPlottables = GetPlottablesByAxis(false); if (primaryPlottables.Count > 0) { axes.Set(primaryPlottables[0].GetDataArea()); for (int i = 1; i < primaryPlottables.Count; i++) { axes.Expand(primaryPlottables[i].GetDataArea()); } } else { axes.Set(-1, 1, -1, 1); } axes.Zoom(1 - marginX, 1 - marginY); } if (secondaryY) { var secondaryPlottables = GetPlottablesByAxis(true); if (secondaryPlottables.Count > 0) { axes2.Set(secondaryPlottables[0].GetDataArea()); for (int i = 1; i < secondaryPlottables.Count; i++) { axes2.Expand(secondaryPlottables[i].GetDataArea()); } } else { axes2.Set(null, null, -1, 1); } axes2.Zoom(1 - marginX, 1 - marginY); axes2.x = axes.x; } }
public void AutoAxis(double marginX = .1, double marginY = .1) { if (axes == null) { axes = new PlotSettings.Axes(); } if (plottables.Count > 0) { axes.Set(plottables[0].GetDataArea()); for (int i = 1; i < plottables.Count; i++) { axes.Expand(plottables[i].GetDataArea()); } } axes.Zoom(1 - marginX, 1 - marginY); }