public static void Box(string title, string[] colNames, string option = "", params int[][] InputArrays) { string FilePath = PathToPlot + string.Format(@"\{0}.dat", title); CreateDAT <int>(FilePath, colNames, InputArrays); int minVal = InputArrays[0][0]; int maxVal = InputArrays[0][0]; foreach (int[] arr in InputArrays) { for (int i = 0; i < arr.Length; i++) { if (arr[i] < minVal) { minVal = arr[i]; } else if (arr[i] > maxVal) { maxVal = arr[i]; } } } string colString = ""; for (int i = 0; i < colNames.Length; i++) { colString += string.Format("\"{0}\" {1}", colNames[i], i + 1); if (i < colNames.Length - 1) { colString += ", "; } } GnuPlot.Set("style fill solid 0.5 border -1", "style boxplot outliers pointtype 7"); GnuPlot.Set("style data boxplot"); GnuPlot.Set("boxwidth 0.5", "pointsize 0.5"); GnuPlot.Unset("key"); GnuPlot.Set(string.Format("yrange [{0}:{1}]", minVal - 1, maxVal + 1)); GnuPlot.Set(string.Format("xtics ({0})", colString)); if (option.Length > 1) { GnuPlot.Plot(FilePath, option); } else { GnuPlot.Plot(FilePath, options: "using (i):i", preoption: string.Format("for [i=1:{0}] ", colNames.Length)); } }
public static void Bar <T>(string title, string option = "", params T[][] InputArrays) { string FilePath = PathToPlot + string.Format(@"\{0}.dat", title); int[] Colors = new int[InputArrays.Length]; int itter = 0; int Color = 0; Dictionary <T, int> ValuePairs = new Dictionary <T, int>(); foreach (T[] arr in InputArrays) { Colors[itter] = Color; foreach (T item in arr) { if (ValuePairs.ContainsKey(item)) { ValuePairs[item]++; } else { ValuePairs.Add(item, 1); Color++; } } itter++; } CreateDAT <T>(FilePath, ValuePairs, Colors); if (option.Length > 1) { GnuPlot.Plot(FilePath, option); } else { GnuPlot.Plot(FilePath, string.Format("using 0:2:3:xtic(1) with boxes lc variable title '{0}'", title)); } }