public string Figure_66_CPH() { string name = System.Reflection.MethodBase.GetCurrentMethod().Name.Replace("Figure_", ""); string fileName = System.IO.Path.GetFullPath($"{outputFolderName}/{name}.png"); Random rand = new Random(0); double[] values1 = ScottPlot.DataGen.RandomNormal(rand, pointCount: 1000, mean: 50, stdDev: 20); double[] values2 = ScottPlot.DataGen.RandomNormal(rand, pointCount: 1000, mean: 45, stdDev: 25); var hist1 = new ScottPlot.Histogram(values1, min: 0, max: 100); var hist2 = new ScottPlot.Histogram(values2, min: 0, max: 100); var plt = new ScottPlot.Plot(width, height); plt.Title("Cumulative Probability Histogram"); plt.YLabel("Probability (fraction)"); plt.XLabel("Value (units)"); plt.PlotStep(hist1.bins, hist1.cumulativeFrac, lineWidth: 1.5, label: "sample A"); plt.PlotStep(hist2.bins, hist2.cumulativeFrac, lineWidth: 1.5, label: "sample B"); plt.Legend(); plt.Axis(null, null, 0, 1); plt.SaveFig(fileName); Console.WriteLine($"Saved: {System.IO.Path.GetFileName(fileName)}"); return(name + ":" + ScottPlot.Tools.BitmapHash(plt.GetBitmap())); }
public static void CreateHistogram(string methodName, double[] redrawTimes) { var hist = new ScottPlot.Histogram(redrawTimes); var pltHist = new ScottPlot.Plot(); pltHist.Title(methodName.Replace("_", " ") + $" ({redrawTimes.Length} runs)"); pltHist.YLabel("count"); pltHist.XLabel("render time (ms)"); pltHist.PlotBar(hist.bins, hist.counts); pltHist.SaveFig(methodName + "_benchmark.png"); }
private void PlotResults(double[] timesMsec) { double mean = timesMsec.Sum() / timesMsec.Length; Array.Sort(timesMsec); double median = timesMsec[(int)(timesMsec.Length / 2)]; var hist = new ScottPlot.Histogram(timesMsec); scottPlotUC2.plt.Clear(); scottPlotUC2.plt.PlotBar(hist.bins, hist.counts); scottPlotUC2.plt.PlotVLine(mean, lineWidth: 3, label: "mean"); scottPlotUC2.plt.PlotVLine(median, lineWidth: 3, label: "median", lineStyle: ScottPlot.LineStyle.Dot); scottPlotUC2.plt.Legend(); scottPlotUC2.plt.AxisAuto(); scottPlotUC2.plt.Axis(y1: 0); scottPlotUC2.plt.YLabel("Count"); scottPlotUC2.plt.XLabel("Render Time (ms)"); scottPlotUC2.plt.Title($"Median: {median} ms"); scottPlotUC2.Render(); }
public string Figure_65_Histogram() { string name = System.Reflection.MethodBase.GetCurrentMethod().Name.Replace("Figure_", ""); string fileName = System.IO.Path.GetFullPath($"{outputFolderName}/{name}.png"); Random rand = new Random(0); double[] values1 = ScottPlot.DataGen.RandomNormal(rand, pointCount: 1000, mean: 50, stdDev: 20); var hist1 = new ScottPlot.Histogram(values1, min: 0, max: 100); var plt = new ScottPlot.Plot(width, height); plt.Title("Histogram"); plt.YLabel("Count (#)"); plt.XLabel("Value (units)"); plt.PlotBar(hist1.bins, hist1.counts, barWidth: 1); plt.Axis(null, null, 0, null); plt.SaveFig(fileName); Console.WriteLine($"Saved: {System.IO.Path.GetFileName(fileName)}"); return(name + ":" + ScottPlot.Tools.BitmapHash(plt.GetBitmap())); }
private void PlotHistogram() { double?min = (double)nudMin.Value; double?max = (double)nudMax.Value; if (cbMinAuto.Checked) { min = null; } if (cbMaxAuto.Checked) { max = null; } double?binSize = (double)nudBinSize.Value; double?binCount = (double)nudBinCount.Value; if (cbBinSizeAuto.Checked) { binSize = null; } if (cbBinCountAuto.Checked) { binCount = null; } // ignore binCount if both binSize and binCount are given if ((binSize != null) && (binCount != null)) { binCount = null; } bool ignoreOutOfBounds = cbIgnoreOutOfBounds.Checked; var hist = new ScottPlot.Histogram(values, min, max, binSize, binCount, ignoreOutOfBounds); binSize = hist.bins[1] - hist.bins[0]; if (nudMin.Enabled == false) { nudMin.Value = (decimal)hist.bins[0]; } if (nudMax.Enabled == false) { nudMax.Value = (decimal)(hist.bins[hist.bins.Length - 1] + binSize); } if (nudBinSize.Enabled == false) { nudBinSize.Value = (decimal)binSize; } if (nudBinCount.Enabled == false) { nudBinCount.Value = (decimal)hist.bins.Length; } lbBins.Items.Clear(); foreach (double bin in hist.bins) { lbBins.Items.Add(bin.ToString()); } if (cbCount.Checked) { PlotHistogramCount(hist.bins, hist.counts); } else if (cbNorm.Checked) { PlotHistogramFrac(hist.bins, hist.countsFrac); } else if (cbCph.Checked) { PlotHistogramCumulative(hist.bins, hist.cumulativeFrac); } }