static public void RunJolka(List <Solver <string> > backtracks, List <Solver <string> > backtrackfws, string heuristicB = "", string heuristicBF = "", string type = "") { var plt = new ScottPlot.Plot(1280, 720); List <double> xlist = new List <double>(); List <double> yfwlist = new List <double>(); List <double> ylist = new List <double>(); foreach (var el in backtrackfws) { xlist.Add(el.solvedPuzzle.Puzzle.id); if (type == "time") { yfwlist.Add(el.solvedPuzzle.elapsed.TotalMilliseconds); } else { yfwlist.Add(el.solvedPuzzle.Puzzle.steps); } } foreach (var el in backtracks) { if (type == "time") { ylist.Add(el.solvedPuzzle.elapsed.TotalMilliseconds); } else { ylist.Add(el.solvedPuzzle.Puzzle.steps); } } double[] xs = xlist.ToArray(); ylist.Insert(2, (double)1); double[] dataB = Tools.Log10(ylist.ToArray()); double[] dataBF = Tools.Log10(yfwlist.ToArray()); plt.PlotBar(xs, dataB, label: "Backtrack w/ " + heuristicB, barWidth: .3, xOffset: -0.2, showValues: true); plt.PlotBar(xs, dataBF, label: "Backtrack with forward w/ " + heuristicBF, barWidth: .3, xOffset: 0.2, showValues: true); plt.Title(type + " over Jolka id"); plt.Ticks(useExponentialNotation: false, useMultiplierNotation: false, logScaleY: true); plt.Axis(y1: 0); plt.XTicks(new string[] { "0", "1", "2", "3", "4" }); if (type == "time") { plt.YLabel("Execution time [10 ^ y ms]"); } else { plt.YLabel("Steps [10 ^ y]"); } plt.XLabel("Jolka ID"); plt.Legend(location: legendLocation.upperRight); plt.SaveFig(heuristicB + heuristicBF + type + "JolkaBvsBF" + ".png"); }
public static void PlotMonthlyChange(List <MonthlyClosedDifference> series, string propertyName, string folderName, string fileName) { // get and convert specific property of a list of objects to array of doubles PropertyInfo prop = typeof(MonthlyClosedDifference).GetProperty(propertyName); double[] valSeries = series.Select(x => Convert.ToDouble(prop.GetValue(x))).ToArray(); // months to x values and labels double[] x = DataGen.Consecutive(series.Count()); string[] labels = series.Select(x => x.Month).ToArray(); var plt = new ScottPlot.Plot(1000, 700); plt.Title(propertyName, fontName: "Segoe UI Light", color: Color.Black); plt.Ticks(dateTimeX: false, fontName: "Cascadia Mono"); plt.Grid(xSpacing: 1); // apply custom axis tick labels plt.XTicks(x, labels); // create folder if not exists System.IO.Directory.CreateDirectory(folderName); plt.PlotBar(x, valSeries, fillColor: Color.Orange); plt.SaveFig($"./{folderName}/{fileName}.png"); }
static public void RunSudoku(double[] difficulty, double[] dataB, double[] dataBF, string heuristicB = "", string heuristicBF = "", string type = "") { var plt = new ScottPlot.Plot(1280, 720); int pointCount = dataB.Length; plt.PlotBar(difficulty, dataB, label: "Backtrack w/ " + heuristicB, barWidth: .3, xOffset: -0.2); plt.PlotBar(difficulty, dataBF, label: "Backtrack with forward w/ " + heuristicBF, barWidth: .3, xOffset: 0.2); plt.Title("Average " + type + " over sudoku difficulty"); plt.Axis(y1: 0); if (type == "time") { plt.YLabel("Execution time [ms]"); } else { plt.YLabel("Steps"); } plt.XLabel("Difficulty"); plt.Legend(location: legendLocation.upperRight); plt.Ticks(useExponentialNotation: false, useMultiplierNotation: false); plt.SaveFig(heuristicB + heuristicBF + type + "BvsBF" + ".png"); }
private string MakeGraph(string[] labels, double[] values) { double[] xs = DataGen.Consecutive(labels.Count()); var plt = new ScottPlot.Plot(1920, 1080); plt.PlotBar(xs, values); // customize the plot to make it look nicer plt.Grid(enableVertical: false, lineStyle: LineStyle.Dot); plt.XTicks(xs, labels); plt.Ticks(fontSize: 25, xTickRotation: 45); plt.Layout(yScaleWidth: 80, titleHeight: 50, xLabelHeight: 200, y2LabelWidth: 20); string path = "graph.png"; plt.SaveFig(path); return path; }