public PlottableScatter PlotScatter( double[] xs, double[] ys, Color?color = null, double lineWidth = 1, double markerSize = 5, string label = null, double[] errorX = null, double[] errorY = null, double errorLineWidth = 1, double errorCapSize = 3, MarkerShape markerShape = MarkerShape.filledCircle, LineStyle lineStyle = LineStyle.Solid ) { var scatterPlot = new PlottableScatter(xs, ys, errorX, errorY) { color = color ?? settings.GetNextColor(), lineWidth = lineWidth, markerSize = (float)markerSize, label = label, errorLineWidth = (float)errorLineWidth, errorCapSize = (float)errorCapSize, stepDisplay = false, markerShape = markerShape, lineStyle = lineStyle }; Add(scatterPlot); return(scatterPlot); }
public PlottableScatter PlotStep( double[] xs, double[] ys, Color? color = null, double lineWidth = 1, string label = null ) { if (color == null) color = settings.GetNextColor(); PlottableScatter stepPlot = new PlottableScatter( xs: xs, ys: ys, color: (Color)color, lineWidth: lineWidth, markerSize: 0, label: label, errorX: null, errorY: null, errorLineWidth: 0, errorCapSize: 0, stepDisplay: true, markerShape: MarkerShape.none, lineStyle: LineStyle.Solid ); settings.plottables.Add(stepPlot); return stepPlot; }
/// <summary> /// Plot a scatter plot from X and Y points /// </summary> public void PlotScatter(double[] xs, double[] ys, Color?color = null, double lineWidth = 1, double markerSize = 5, string label = null, double[] errorX = null, double[] errorY = null, double errorLineWidth = 1, double errorCapSize = 3) { if (color == null) { color = settings.GetNextColor(); } PlottableScatter scat = new PlottableScatter(xs, ys, color: (Color)color, lineWidth: lineWidth, markerSize: markerSize, label: label, errorX: errorX, errorY: errorY, errorLineWidth: errorLineWidth, errorCapSize: errorCapSize, stepDisplay: false); settings.plottables.Add(scat); }
/// <summary> /// Create a step plot from X and Y points /// </summary> public void PlotStep(double[] xs, double[] ys, Color?color = null, double lineWidth = 1, string label = null) { if (color == null) { color = settings.GetNextColor(); } PlottableScatter step = new PlottableScatter(xs, ys, color: (Color)color, lineWidth: lineWidth, markerSize: 0, label: label, errorX: null, errorY: null, errorLineWidth: 0, errorCapSize: 0, stepDisplay: true); settings.plottables.Add(step); }
/// <summary> /// Plot a scatter plot from X and Y points /// </summary> public void PlotScatter(double[] xs, double[] ys, Color?color = null, double lineWidth = 1, double markerSize = 5, string label = null) { if (color == null) { color = settings.GetNextColor(); } PlottableScatter scat = new PlottableScatter(xs, ys, color: (Color)color, lineWidth: lineWidth, markerSize: markerSize, label: label); settings.plottables.Add(scat); }
/// <summary> /// Plot a single point at a specific location /// </summary> public void PlotPoint(double x, double y, Color?color = null, double markerSize = 5, string label = null) { if (color == null) { color = settings.GetNextColor(); } PlottableScatter mark = new PlottableScatter(new double[] { x }, new double[] { y }, color: (Color)color, lineWidth: 0, markerSize: markerSize, label: label); settings.plottables.Add(mark); }
/// <summary> /// Plot a single point at a specific location /// </summary> public void PlotPoint(double x, double y, Color?color = null, double markerSize = 5, string label = null, double?errorX = null, double?errorY = null, double errorLineWidth = 1, double errorCapSize = 3) { if (color == null) { color = settings.GetNextColor(); } double[] errorXarray = (errorX != null) ? new double[] { (double)errorX } : null; double[] errorYarray = (errorY != null) ? new double[] { (double)errorY } : null; PlottableScatter mark = new PlottableScatter(new double[] { x }, new double[] { y }, color: (Color)color, lineWidth: 0, markerSize: markerSize, label: label, errorX: errorXarray, errorY: errorYarray, errorLineWidth: errorLineWidth, errorCapSize: errorCapSize, stepDisplay: false); settings.plottables.Add(mark); }
public void Render(PlotDimensions dims, Bitmap bmp, bool lowQuality = false) { List <double> xList = new List <double>(); List <double> yList = new List <double>(); PointCount = (int)dims.DataWidth; for (int columnIndex = 0; columnIndex < dims.DataWidth; columnIndex++) { double x = columnIndex * dims.UnitsPerPxX + dims.XMin; try { double?y = function(x); if (y is null) { throw new NoNullAllowedException(); } if (double.IsNaN(y.Value) || double.IsInfinity(y.Value)) { throw new ArithmeticException("not a real number"); } xList.Add(x); yList.Add(y.Value); } catch (Exception e) //Domain error, such log(-1) or 1/0 { Debug.WriteLine($"Y({x}) failed because {e}"); continue; } } // create a temporary scatter plot and use it for rendering double[] xs = xList.ToArray(); double[] ys = yList.ToArray(); var scatter = new PlottableScatter(xs, ys) { color = color, lineWidth = lineWidth, markerSize = 0, label = label, markerShape = MarkerShape.none, lineStyle = lineStyle }; scatter.Render(dims, bmp, lowQuality); }
public PlottableScatter PlotPoint( double x, double y, Color?color = null, double markerSize = 5, string label = null, double?errorX = null, double?errorY = null, double errorLineWidth = 1, double errorCapSize = 3, MarkerShape markerShape = MarkerShape.filledCircle, LineStyle lineStyle = LineStyle.Solid ) { if (color == null) { color = settings.GetNextColor(); } double[] errorXarray = (errorX != null) ? new double[] { (double)errorX } : null; double[] errorYarray = (errorY != null) ? new double[] { (double)errorY } : null; PlottableScatter scatterPlot = new PlottableScatter( xs: new double[] { x }, ys: new double[] { y }, color: (Color)color, lineWidth: 0, markerSize: markerSize, label: label, errorX: errorXarray, errorY: errorYarray, errorLineWidth: errorLineWidth, errorCapSize: errorCapSize, stepDisplay: false, markerShape: markerShape, lineStyle: lineStyle ); settings.plottables.Add(scatterPlot); return(scatterPlot); }
public override void Render(Settings settings) { double step = settings.xAxisUnitsPerPixel; double minRenderedX = settings.axes.limits[0]; double maxRenderedX = settings.axes.limits[1]; int maxSeriesLength = (int)Math.Ceiling((maxRenderedX - minRenderedX) / step); lastNumberOfPointsDisplayed = maxSeriesLength; List <double> xList = new List <double>(); List <double> yList = new List <double>(); for (int i = 0; i < maxSeriesLength; i++) { double x = i * step + minRenderedX; double?y; try { y = function(x); } catch (Exception e) //Domain error, such log(-1) or 1/0 { Debug.WriteLine(e); continue; } if (y.HasValue) { if (double.IsNaN(y.Value) || double.IsInfinity(y.Value)) {// double.IsInfinity checks for positive or negative infinity continue; } xList.Add(x); yList.Add(y.Value); } } PlottableScatter scatter = new PlottableScatter(xList.ToArray(), yList.ToArray(), color, lineWidth, markerSize, label, null, null, 0, 0, false, markerShape, lineStyle); scatter.Render(settings); }
public PlottableScatter PlotScatter( double[] xs, double[] ys, Color?color = null, double lineWidth = 1, double markerSize = 5, string label = null, double[] errorX = null, double[] errorY = null, double errorLineWidth = 1, double errorCapSize = 3, MarkerShape markerShape = MarkerShape.filledCircle, LineStyle lineStyle = LineStyle.Solid ) { if (color == null) { color = settings.GetNextColor(); } PlottableScatter scatterPlot = new PlottableScatter( xs: xs, ys: ys, color: (Color)color, lineWidth: lineWidth, markerSize: markerSize, label: label, errorX: errorX, errorY: errorY, errorLineWidth: errorLineWidth, errorCapSize: errorCapSize, stepDisplay: false, markerShape: markerShape, lineStyle: lineStyle ); settings.plottables.Add(scatterPlot); return(scatterPlot); }
public override void Render(Settings settings) { double step = 1 / (settings.xAxisUnitsPerPixel * 250); // 250 may not be ideal, bigger number is more smooth, but less performant int maxSeriesLength = (int)Math.Ceiling((maxX - minX) / step); List <double> xList = new List <double>(); List <double> yList = new List <double>(); for (int i = 0; i < maxSeriesLength; i++) { double x = i * step + minX; double?y; try { y = function(x); } catch (Exception e) //Domain error, such log(-1) or 1/0 { Debug.WriteLine(e); continue; } if (y.HasValue) { xList.Add(x); yList.Add(y.Value); } //Console.WriteLine($"({xs[i]},{ys[i]})"); } PlottableScatter scatter = new PlottableScatter(xList.ToArray(), yList.ToArray(), color, lineWidth, markerSize, label, null, null, 0, 0, false, markerShape, lineStyle); scatter.Render(settings); }