public void Test_Scatter_Highlight() { var plt = new ScottPlot.Plot(); plt.AntiAlias(false, false, false); // start with default settings double[] xs = { 1, 2, 3, 4 }; double[] ys = { 1, 4, 9, 16 }; var splt = new PlottableScatterHighlight(xs, ys) { }; plt.Add(splt); var bmp1 = new System.Drawing.Bitmap(plt.GetBitmap(renderFirst: true)); // change the plottable splt.HighlightPointNearest(2.1, 4.1); var bmp2 = new System.Drawing.Bitmap(plt.GetBitmap(renderFirst: true)); // measure what changed //TestTools.SaveFig(bmp1, "1"); //TestTools.SaveFig(bmp2, "2"); var before = new MeanPixel(bmp1); var after = new MeanPixel(bmp2); Console.WriteLine($"Before: {before}"); Console.WriteLine($"After: {after}"); Assert.That(after.IsDarkerThan(before)); }
public static void VisibleCtrl(PlottableScatter scatterPlot, PlottableScatterHighlight fittingHL, bool isChecked, FormsPlot plot) { if (scatterPlot != null && fittingHL != null) { scatterPlot.visible = isChecked; fittingHL.visible = isChecked; plot.Render(); } }
/// <summary> /// Creates a <see cref="Tracks.Classes.DriverlessTrack"/>-s plot. /// </summary> /// <param name="xAxisValues">Values on <b>horizontal</b> axis.</param> /// <param name="yAxisValues">Values on <b>vertical</b> axis.</param> /// <param name="color">Color of the line.</param> /// <param name="xValue">Value on the horizontal axis.</param> /// <param name="yValue">Value on the vertical axis.</param> /// <param name="yAxisLabel">Label on <b>vertical</b> axis. Default is an empty string.</param> /// <param name="xAxisLabel">Label on <b>horizontal</b> axis. Default is an empty string.</param> /// <param name="lineWidth">Width of the line. Default is <c>3</c>.</param> /// <param name="lineStyle">Style of the line. Default is <see cref="LineStyle.Solid"/>.</param> /// <param name="enableLabel">If true, the label is enabled on the line.</param> public void AddPlot(double[] xAxisValues, double[] yAxisValues, Color color, double xValue = 0, double yValue = 0, string yAxisLabel = "", string xAxisLabel = "x", double lineWidth = 3, LineStyle lineStyle = LineStyle.Solid, bool enableLabel = false) { // Flips the value, because Gergő said // that the horizontal axis must be positive // to the left side and negativ to the right side. for (int i = 0; i < xAxisValues.Length; i++) { xAxisValues[i] *= -1; } if (enableLabel) { plottableScatterHighlight = ScottPlotChart.plt.PlotScatterHighlight(xAxisValues, yAxisValues, markerShape: MarkerShape.none, color: color, lineWidth: lineWidth, lineStyle: lineStyle, label: $"{xAxisLabel}: {xValue:f3}\n{yAxisLabel}: {yValue:f3}"); } else { plottableScatterHighlight = ScottPlotChart.plt.PlotScatterHighlight(xAxisValues, yAxisValues, markerShape: MarkerShape.none, color: color, lineWidth: lineWidth, lineStyle: lineStyle); } ScottPlotChart.Render(); }