public void Peaks_Azimuth0_Azimuth90() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radiuses = new List <double> { 4, 10, 20, 40 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth0 = "RadiusDistanceOutput_Azimuth0"; string dirAzimuth90 = "RadiusDistanceOutput_Azimuth90"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.Set("xtics 0.5"); gp.Set("grid xtics ytics"); gp.Set("size square"); gp.HoldOn(); radiuses.Reverse(); foreach (double radius in radiuses) { Dictionary <double, double> peaks0 = this.getPeaks0(distances, radius, dirAzimuth0); Dictionary <double, double> peaks90 = this.getPeaks90(distances, radius, dirAzimuth90); //gp.HoldOn(); // gp.Set(string.Format("terminal win {0}", radius)); gp.Plot(peaks0); gp.Plot(peaks90); // gp.HoldOff(); } gp.Wait(); }
private void button2_Click(object sender, EventArgs e) { GnuPlot gp = new GnuPlot(); gp.HoldOn(); gp.Set("title 'Phase-Locked Signals'"); gp.Set("samples 2000"); gp.Unset("key"); gp.Plot("sin(x)"); gp.Plot("cos(x)"); }
public void CalculateOpticalConstants_DrudeLorentz_Gnuplot() { // Arrange var optConst = ParameterHelper.ReadOpticalConstants("opt_const.txt"); var drudeLorentz = new DrudeLorentz(); var dict = new Dictionary <double, Complex>(); foreach (var waveLength in optConst.WaveLengthList) { var freq = new SpectrumUnit(waveLength / OpticalConstants.WaveLengthMultiplier, SpectrumUnitType.WaveLength); dict.Add(waveLength, drudeLorentz.GetPermittivity(freq)); } ParameterHelper.WriteOpticalConstants("opt_const_drudeLorentz.txt", dict); using (var gp = new GnuPlot()) { gp.HoldOn(); gp.Set("style data lines"); gp.Plot(getPermitivittyFunc(optConst)); gp.Plot(dict); gp.Wait(); } // Act // Assert }
private static void PlotFit(double min_x, double max_x, Vector <double> mu, Vector <double> sigma, Vector <double> theta, int p, double lambda) { // Plot training data and fit var x = Matrix <double> .Build.DenseOfColumnArrays(Generate.LinearRange(min_x - 15, .05, max_x + 25)); Matrix <double> X_poly = MapPolyFeatures(x, p); for (int i = 0; i < X_poly.ColumnCount; i++) { Vector <double> v = X_poly.Column(i); v = v - mu[i]; v = v / sigma[i]; X_poly.SetColumn(i, v); } X_poly = X_poly.InsertColumn(0, Vector <double> .Build.Dense(X_poly.RowCount, 1)); var hypothesis = X_poly * theta; GnuPlot.Set(string.Format("title \"Polynomial Regression Fit (lambda = {0:f6})\"", lambda)); GnuPlot.Set("xlabel \"Change in water level (x)\""); GnuPlot.Set("ylabel \"Water flowing out of the dam (y)\""); GnuPlot.Set("autoscale xy"); //GnuPlot.Set("xr[-100:100]"); //GnuPlot.Set("yr[-200:400]"); GnuPlot.Plot(x.Column(0).ToArray(), hypothesis.ToArray(), "with lines dashtype 2 lw 1 lc rgb \"blue\" notitle"); }
public void RadiusChangeOutput_InterparticleDistance_Spectrum() { // Arrange GnuPlot gp = null; var radius1 = 20; var radiuses = new List <double> { 4, 10, 15, 20 }; double distance = 70; string dirAzimuth45 = "RadiusChangeOutput_InterparticleDistance_Spectrum"; //foreach (var radius1 in radiuses) //{ gp = new GnuPlot(); setLineStyle(gp); gp.HoldOn(); setColorPalette(gp); gp.Set(String.Format("title \"{0}\"", radius1)); foreach (double radius in radiuses) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth45, distance, radius1, radius)) .ToDictionary(x => x.Key * 1e9, x => x.Value); gp.Plot(azim45, string.Format(@"title ""{0}""", radius)); //gp.Clear(); } //} gp.Wait(); }
public void RadiusChangeOutput_Azimuth_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radius1 = 4; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth45 = "RadiusChangeOutput_Azimuth45"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); foreach (double radius in radiuses) { Dictionary <decimal, List <double> > spectrum = this.zipToDictionaryDiffRadiuses(distances, dirAzimuth45, radius1, radius); string filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim45.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); foreach (double distance in distances.Take(5)) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth45, distance, radius1, radius)); gp.Plot(azim45, string.Format(@"title ""{0}""", radius)); } gp.Clear(); } gp.Wait(); }
public void AreClose_Azimuth45_AzimuthSum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuthSum = "RadiusDistanceOutput_AzimuthSum"; string dirAzimuth45 = "RadiusDistanceOutput_Azimuth45"; var gp = new GnuPlot(); gp.Set("style data lines"); foreach (double radius in radiuses) { foreach (double distance in distances) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormat(dirAzimuth45, distance, radius)); Dictionary <double, double> azimSum = SimpleFormatter.Read( this.getFileFormat(dirAzimuthSum, distance, radius)); gp.HoldOn(); gp.Plot(azim45); gp.Plot(azimSum); gp.HoldOff(); AssertHelper.DictionaryAreClose(azim45, azimSum, 0.5); } } }
public void AreCloseDistance3_OpticalConst_DrudeLorentz() { // Arrange var distance = 2.9; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; string dirOpticalConst = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirDrudeLorentz = "RadiusDistanceDrudeLorentz_Azimuth45_EffectiveCrossExt"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); foreach (double radius in radiuses) { Dictionary <double, double> optical = SimpleFormatter.Read( this.getFileFormat(dirOpticalConst, distance, radius)); Dictionary <double, double> drudeLorentz = SimpleFormatter.Read( this.getFileFormat(dirDrudeLorentz, distance, radius)); gp.Plot(optical, @"title ""optical"""); gp.Plot(drudeLorentz, @"title ""drude-lorentz"""); //AssertHelper.DictionaryAreClose(optical, drudeLorentz, 0.1); } gp.Wait(); }
public void AreClose_Radius40_OpticalConst_DrudeLorentz() { // Arrange const double DistanceMax = 0.5; const double DistanceStep = 0.1; List <double> distances = getDistances(DistanceStep, DistanceMax); var radius = 40; string dirOpticalConst = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirDrudeLorentz = "RadiusDistanceDrudeLorentz_Azimuth45_EffectiveCrossExt"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); foreach (double distance in distances) { Dictionary <double, double> optical = SimpleFormatter.Read( this.getFileFormat(dirOpticalConst, distance, radius)); Dictionary <double, double> drudeLorentz = SimpleFormatter.Read( this.getFileFormat(dirDrudeLorentz, distance, radius)); gp.Plot(optical, @"title ""optical"""); gp.Plot(drudeLorentz, @"title ""drude-lorentz"""); //AssertHelper.DictionaryAreClose(optical, drudeLorentz, 0.1); } gp.Wait(); }
public void Calculate_PerformanceMetrics() { var serialTicks = 192769194.79518071; List <double> all = new List <double>(); var gp = new GnuPlot(); gp.Set("style data linespoints"); gp.HoldOn(); for (int i = 256; i <= 1024; i = i * 2) { List <long> list = new List <long>(); for (int j = 0; j < 20; j++) { Stopwatch watch = Stopwatch.StartNew(); //ArrayExtensions.MaxDegreeOfParallelism = i; FDTDProgram.Calculate(); watch.Stop(); list.Add(watch.ElapsedTicks); } all.Add(list.Average()); } gp.Plot(all.Select(x => serialTicks / x)); gp.Wait(); }
public static void PlotData(Matrix <double> X, Vector <double> y) { List <(double x1, double x2)> pos = new List <(double x1, double x2)>(); List <(double x1, double x2)> neg = new List <(double x1, double x2)>(); for (int i = 0; i < y.Count; i++) { if (y[i] == 1) { pos.Add((X[i, 0], X[i, 1])); } else { neg.Add((X[i, 0], X[i, 1])); } } GnuPlot.HoldOn(); GnuPlot.Set("title \"\""); GnuPlot.Set("xlabel \"Microchip test 1\""); GnuPlot.Set("ylabel \"Microchip test 2\""); GnuPlot.Plot(pos.Select(p => p.x1).ToArray(), pos.Select(p => p.x2).ToArray(), "pt 1 ps 1 lc rgb \"black\" title \"y=1\""); GnuPlot.Plot(neg.Select(p => p.x1).ToArray(), neg.Select(p => p.x2).ToArray(), "pt 7 ps 1 lc rgb \"yellow\" title \"y=0\""); }
public static void PlotData(Matrix <double> X, Vector <double> y) { List <(double x1, double x2)> pos = new List <(double x1, double x2)>(); List <(double x1, double x2)> neg = new List <(double x1, double x2)>(); for (int i = 0; i < y.Count; i++) { if (y[i] == 1) { pos.Add((X[i, 0], X[i, 1])); } else { neg.Add((X[i, 0], X[i, 1])); } } GnuPlot.HoldOn(); GnuPlot.Set("title \"Data\""); //GnuPlot.Set("key bottom right"); GnuPlot.Set("key outside noautotitle"); //GnuPlot.Set("key title \"Legend\""); GnuPlot.Set("xlabel \"Exam 1 score\""); GnuPlot.Set("ylabel \"Exam 2 score\""); GnuPlot.Plot(pos.Select(p => p.x1).ToArray(), pos.Select(p => p.x2).ToArray(), "pt 1 ps 1 lc rgb \"black\" title \"Admitted\""); GnuPlot.Plot(neg.Select(p => p.x1).ToArray(), neg.Select(p => p.x2).ToArray(), "pt 7 ps 1 lc rgb \"yellow\" title \"Not admitted\""); }
static void Main(string[] args) { System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; ParseArgs(args); foreach (var shape in shapes) { Helper.SetShape(shape.shape, shape.args); } if (Helper.Plot) { GnuPlot.Set("", "xrange[-10:10]", "yrange[-10:10]", "size square" /*, "terminal gif animate delay 5"*/, $"output '{Helper.outputPath}{Helper.outputFilename.Replace(".txt", ".gif")}'"); Helper.PlotPoints(Helper.ShapePoints, "with points pt '+' lc rgb 'black'", Helper.outputPath + "shape.txt"); } Network network = new Network(Helper.ShapePoints, epochs, neurons, learningRate, sigma0, method); network.Learn(); }
public static void PlotData(double[] x, double[] y) { GnuPlot.Set("title \"Water flowing\""); GnuPlot.Set("key bottom right"); GnuPlot.Set("xlabel \"Change in water level (x)\""); GnuPlot.Set("ylabel \"Water flowing out of the dam (y)\""); GnuPlot.Plot(x, y, "pt 2 ps 1 lc rgb \"red\" notitle"); }
public void MakePlot(double[] xBound, double[] yBound) { string xr = "xr[" + xBound[0] + ":" + xBound[1] + "]"; string yr = "yr[" + yBound[0] + ":" + yBound[1] + "]"; GnuPlot.Set("cntrparam levels 30", "isosamples 40", xr, yr, "decimalsign locale"); GnuPlot.SPlot(filename, "with pm3d"); }
// plot the data public static void PlotData(double[] x, double[] y) { GnuPlot.Set("title \"Linear Regression\""); GnuPlot.Set("key bottom right"); //GnuPlot.Set("key title \"Legend\""); GnuPlot.Set("xlabel \"Population of City in 10,000s\""); GnuPlot.Set("ylabel \"Profit in $10,000s\""); GnuPlot.Plot(x, y, "pt 2 ps 1 lc rgb \"red\" title \"Training data\""); }
private static void PlotJ(Matrix <double> j_history, string title, string color) { double[] x = MathNet.Numerics.Generate.LinearRange(1, 1, j_history.RowCount); double[] y = j_history.Column(0).ToArray(); GnuPlot.Set("xlabel \"Number of iteration\""); GnuPlot.Set("ylabel \"Cost J\""); GnuPlot.Plot(x, y, "with lines linestyle 1 lc rgb \"" + color + "\" linewidth 2 title \"" + title + "\" "); }
public void RadiusChangeOutputPeaks_Azimuth0_Azimuth90() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; var radiuses = new List <double> { 4, 10, 20, 40, 70, 100, 200 }; var radius1 = 4; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth0 = "RadiusChangeOutput_Azimuth0"; string dirAzimuth90 = "RadiusChangeOutput_Azimuth90"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); radiuses.Reverse(); foreach (double radius in radiuses) { var peaks0 = new Dictionary <double, double>(); var peaks90 = new Dictionary <double, double>(); foreach (double distance in distances) { Dictionary <double, double> azim0 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth0, distance, radius1, radius)); Dictionary <double, double> azim90 = SimpleFormatter.Read( this.getFileFormatDiffRadiuses(dirAzimuth90, distance, radius1, radius)); peaks0.Add(distance, azim0.MaxPair().Key); peaks90.Add(distance, azim0.MaxPair().Key); } // gp.HoldOn(); // gp.Set(string.Format("terminal win {0}", radius)); gp.Plot(peaks0); gp.Plot(peaks90); // gp.HoldOff(); string basepath = Path.Combine(BasePath, this.TestContext.TestName); string filename0 = Path.Combine( basepath, string.Format("peaks_0deg_{0}.txt", radius)); SimpleFormatter.Write(filename0, peaks0); string filename90 = Path.Combine( basepath, string.Format("peaks_90deg_{0}.txt", radius)); SimpleFormatter.Write(filename90, peaks90); } gp.Wait(); }
// Plot J cost function private static void PlotJ(Matrix <double> X, Matrix <double> y, Matrix <double> theta) { // Grid over which we will calculate J double[] theta0_vals = MathNet.Numerics.Generate.LinearSpaced(100, -10, 10); double[] theta1_vals = MathNet.Numerics.Generate.LinearSpaced(100, -1, 4); // initialize J_vals to a matrix of 0's int size = theta0_vals.Length * theta1_vals.Length; double[] sx = new double[size]; double[] sy = new double[size]; double[] sz = new double[size]; // Fill out J_vals int idx = 0; for (int i = 0; i < theta0_vals.Length; i++) { for (int k = 0; k < theta1_vals.Length; k++) { Matrix <double> t = Matrix <double> .Build.Dense(2, 1); t[0, 0] = theta0_vals[i]; t[1, 0] = theta1_vals[k]; sx[idx] = theta0_vals[i]; sy[idx] = theta1_vals[k]; sz[idx] = ComputeCost(X, y, t); idx++; } } GnuPlot.HoldOn(); GnuPlot.Set("terminal wxt 1"); GnuPlot.Set("title \"Cost function J\""); GnuPlot.Set("key bottom right"); GnuPlot.Set("xlabel \"{/Symbol q}_0\""); GnuPlot.Set("ylabel \"{/Symbol q}_1\""); // surface plot GnuPlot.SPlot(sx, sy, sz, "palette title \"J({/Symbol q}_0,{/Symbol q}_1)\""); // Contour plot GnuPlot.Set("terminal wxt 2"); GnuPlot.Set("cntrparam levels auto 10", "logscale z", "xr[-10:10]", "yr[-1:4]"); GnuPlot.Unset("key", "label"); GnuPlot.Contour(sx, sy, sz); GnuPlot.Plot(new double[] { theta[0, 0] }, new double[] { theta[1, 0] }, "pt 2 ps 1 lc rgb \"red\""); }
private static void DisplayData(Vector <double>[] X) { int w = 20; int h = 20; int row = 0; int col = 0; int offsetRow = 0; int offsetCol = 0; int dim = (int)Math.Sqrt(X.Length); double[,] d = new double[h * dim, w *dim]; for (int i = 0; i < X.Length; i++) { for (int k = 0; k < (w * h); k++) { d[row + offsetRow, col + offsetCol] = X[i][k]; offsetCol++; if (offsetCol % w == 0) { offsetRow++; offsetCol = 0; } } col += w; if (col >= (w * dim)) { row += h; col = 0; } offsetRow = 0; offsetCol = 0; } //d = RotateRight(d); //GnuPlot.Unset("key"); GnuPlot.Unset("colorbox"); //GnuPlot.Unset("tics"); GnuPlot.Set("grid"); GnuPlot.Set("palette grey"); //GnuPlot.Set("xrange [0:200]"); //GnuPlot.Set("yrange [0:200]"); GnuPlot.Set("pm3d map"); GnuPlot.SPlot(d, "with image"); }
private static void PlotValidationCurve(double[] x, double[] jtrain, double[] jvc) { GnuPlot.HoldOn(); GnuPlot.Set("title \"Validation curve\""); GnuPlot.Set("xlabel \"Lamda\""); GnuPlot.Set("key top right box"); GnuPlot.Set("ylabel \"Error\""); GnuPlot.Set("autoscale xy"); GnuPlot.Plot(x, jtrain, "with lines ls 1 lw 2 lc rgb \"cyan\" title \"Train\" "); GnuPlot.Plot(x, jvc, "with lines ls 1 lw 2 lc rgb \"orange\" title \"Cross Validation\" "); GnuPlot.HoldOff(); }
private static void PlotLinearLearningCurve(double[] x, double[] jtrain, double[] jvc) { GnuPlot.HoldOn(); GnuPlot.Set("title \"Learning curve for linear regression\""); GnuPlot.Set("xlabel \"Number of training examples\""); GnuPlot.Set("key top right box"); GnuPlot.Set("ylabel \"Error\""); GnuPlot.Set("xr[0:13]"); GnuPlot.Set("yr[0:150]"); GnuPlot.Plot(x, jtrain, "with lines ls 1 lw 2 lc rgb \"cyan\" title \"Train\" "); GnuPlot.Plot(x, jvc, "with lines ls 1 lw 2 lc rgb \"orange\" title \"Cross Validation\" "); GnuPlot.HoldOff(); }
private static void Main(string[] args) { string fileTrain1 = "approximation_train_1.txt"; string fileTrain2 = "approximation_train_2.txt"; string fileTest = "approximation_test.txt"; string filePathTrain1 = Path.GetFullPath(fileTrain1); string filePathTrain2 = Path.GetFullPath(fileTrain2); string filePathTest = Path.GetFullPath(fileTest); List <double> outputValues = new List <double>(); DataGetter dataGetterTrain1 = new DataGetter(filePathTrain1); DataGetter dataGetterTrain2 = new DataGetter(filePathTrain2); DataGetter dataGetterTest = new DataGetter(filePathTest); double learnRate = 0.1; double momentum = 0.1; int numberOfRadialNeurons = 20; int numberOfEpochs = 300; //Console.WriteLine("SIEC NEURONOWA RBF WYKORZYSTYWANA DO APROKSYMACJI FUNKJI"); //Console.WriteLine("Prosze wprowadzic wartosc wspolczynnika nauki:"); //learnRate = Convert.ToDouble(Console.ReadLine(), System.Globalization.CultureInfo.InvariantCulture); //Console.WriteLine("Prosze wprowadzic wartosc wspolczynnika momentum:"); //momentum = Convert.ToDouble(Console.ReadLine(), System.Globalization.CultureInfo.InvariantCulture); NeuralNetwork neuralNetwork = new NeuralNetwork(dataGetterTrain1.getInputData(), learnRate, momentum, numberOfRadialNeurons); Console.WriteLine("ZBIOR TRENINGOWY 1: "); neuralNetwork.Train(numberOfEpochs, dataGetterTrain2); Console.WriteLine("ZBIOR TRENINGOWY 2: "); neuralNetwork.Train(numberOfEpochs, dataGetterTrain1); Console.WriteLine("ZBIOR TESTOWY: "); outputValues = neuralNetwork.Test(dataGetterTest); GnuPlot.Set("term wxt 0"); GnuPlot.HoldOn(); GnuPlot.Set("xlabel 'X Values'"); GnuPlot.Set("ylabel 'Y Values'"); GnuPlot.Plot(dataGetterTest.getInputData().ToArray(), dataGetterTest.getExpectedData().ToArray(), "title 'funkcja oryginalna'"); GnuPlot.Plot(dataGetterTest.getInputData().ToArray(), outputValues.ToArray(), "title 'funkcja po aproksymacji'"); GnuPlot.HoldOff(); GnuPlot.Set("term wxt 1"); GnuPlot.Set("xlabel 'Numer epoki'"); GnuPlot.Set("ylabel 'Wartosc bledu'"); GnuPlot.Plot(neuralNetwork.ErrorX.ToArray(), neuralNetwork.ErrorY.ToArray(), "with lines title 'Blad aproksymacji'"); Console.ReadKey(); }
private static void PlotLinearBoundary(Matrix <double> X, Vector <double> y, Vector <double> theta) { GnuPlot.Set("terminal wxt 1"); PlotData(X.RemoveColumn(0), y); // Only need 2 points to define a line, so choose two endpoints double x1 = X.Column(2).Minimum() - 2; double x2 = X.Column(2).Maximum() + 2; Vector <double> X_plot = Vector <double> .Build.DenseOfArray(new double [] { x1, x2 }); var y_plot = (-1 / theta[2]) * (theta[1] * X_plot + theta[0]); GnuPlot.Plot(X_plot.ToArray(), y_plot.ToArray(), "with lines linestyle 1 linewidth 1 title \"Decision Boundary\" "); // GnuPlot.Set("xrange [30:100]"); // GnuPlot.Set("yrange [30:100]"); }
private static void PlotProgresskMeans(Matrix <double> X, Matrix <double> centroids, Matrix <double> previous_centroids, Vector <double> idx, int K, int i) { GnuPlot.Set($"title \"Iteration number {i+1}"); PlotDataPoints(X, idx, K); // Plot the centroids as black x's double[] x1 = centroids.Column(0).ToArray(); double[] x2 = centroids.Column(1).ToArray(); GnuPlot.Plot(x1, x2, "pt 2 ps 1 lw 3 lc rgb \"black\" notitle"); // Plot the history of the centroids with lines for (int j = 0; j < centroids.RowCount; j++) { double[] x = new double[] { centroids[j, 0], previous_centroids[j, 0] }; double[] y = new double[] { centroids[j, 1], previous_centroids[j, 1] }; GnuPlot.Plot(x, y, "with lines linestyle 1 linewidth 2 notitle"); } }
private static void PlotBoundary(Matrix <double> x, C_SVC svc) { double min = x.Column(0).Min(); double max = x.Column(0).Max(); double[] x0 = MathNet.Numerics.Generate.LinearSpaced(100, min, max); min = x.Column(1).Min(); max = x.Column(1).Max(); double[] x1 = MathNet.Numerics.Generate.LinearSpaced(100, min, max); int size = x0.Length * x1.Length; double[] sx = new double[size]; double[] sy = new double[size]; double[] sz = new double[size]; int idx = 0; for (int i = 0; i < x0.Length; i++) { for (int j = 0; j < x1.Length; j++) { sx[idx] = x0[i]; sy[idx] = x1[j]; svm_node n1 = new svm_node(); n1.index = 1; n1.value = x0[i]; svm_node n2 = new svm_node(); n2.index = 2; n2.value = x1[j]; double z = svc.Predict(new [] { n1, n2 }); sz[idx] = z; idx++; } } GnuPlot.Set("cntrparam levels discrete 0.5"); GnuPlot.Contour(sx, sy, sz, "title \"Decision Boundary\""); }
void PlotAverageSpeedAndSize() { GnuPlot.Set("xlabel 'Time [Seconds]'"); GnuPlot.Set("ylabel 'Avg. speed'"); GnuPlot.Set("y2label 'Avg. size'"); GnuPlot.Set("ytics nomirror"); GnuPlot.Set("y2tics"); GnuPlot.Set("tics out"); GnuPlot.Set(String.Format("yrange [{0}:{1}]", JumpmanAttributes.MIN_SPEED, JumpmanAttributes.MAX_SPEED)); GnuPlot.Set(String.Format("y2range [{0}:{1}]", JumpmanAttributes.MIN_SIZE, JumpmanAttributes.MAX_SIZE)); //GnuPlot.Set("autoscale y"); //GnuPlot.Set("autoscale y2"); GnuPlot.Set("key left top Left box 3"); GnuPlot.HoldOn(); GnuPlot.Plot(tracker.averageJumpmanAttrTmpPath, "using 1:5 title 'Speed' w lp axes x1y1"); GnuPlot.Plot(tracker.averageJumpmanAttrTmpPath, "using 1:6 title 'Size' w lp axes x1y2"); GnuPlot.HoldOff(); }
void PlotNutritionAndJumpmen() { GnuPlot.Set("xlabel 'Time [Seconds]'"); GnuPlot.Set("ylabel 'Total nutrition'"); GnuPlot.Set("y2label 'Amount of jumpmen'"); GnuPlot.Set("ytics nomirror"); GnuPlot.Set("y2tics"); GnuPlot.Set("tics out"); GnuPlot.Unset("yrange"); GnuPlot.Unset("y2range"); //GnuPlot.Set("autoscale y"); //GnuPlot.Set("autoscale y2"); GnuPlot.Set("key left top Left box 3"); GnuPlot.HoldOn(); GnuPlot.Plot(tracker.nutritionTmpPath, "using 1:2 title 'Nutrition' w l axes x1y1"); GnuPlot.Plot(tracker.jumpmanCountTmpPath, "using 1:2 title 'Jumpmen' w lp axes x1y2"); GnuPlot.HoldOff(); }
public void MakeContour(double[] xBound, double[] yBound) { int id = x.Count() - 1; double[] x1plot = new double[id + 1]; double[] x2plot = new double[id + 1]; for (int i = 0; i <= id; i++) { x1plot[i] = x[i][0]; x2plot[i] = x[i][1]; } string xr = "xr[" + xBound[0] + ":" + xBound[1] + "]"; string yr = "yr[" + yBound[0] + ":" + yBound[1] + "]"; GnuPlot.Unset("key"); //hide the key or legend GnuPlot.HoldOn(); GnuPlot.Set(xr, yr, "cntrparam levels 20", "isosamples 50", xr, yr, "decimalsign locale"); //notice cntrparam levels (# height levels) GnuPlot.Plot(x1plot, x2plot, "with linespoints linestyle 1"); GnuPlot.Contour(filename, "lc rgb 'blue'"); }
public void Radius10_Azimuth_Spectrum() { // Arrange const int DistanceMax = 3; const double DistanceStep = 0.1; int radius = 10; List <double> distances = getDistances(DistanceStep, DistanceMax); string dirAzimuth45 = "RadiusDistanceOutput_Azimuth45_EffectiveCrossExt"; string dirAzimuth0 = "RadiusDistanceOutput_Azimuth0_EffectiveCrossExt"; string dirAzimuth90 = "RadiusDistanceOutput_Azimuth90_EffectiveCrossExt"; var gp = new GnuPlot(); gp.Set("style data lines"); gp.HoldOn(); Dictionary <decimal, List <double> > spectrum = this.zipToDictionary(distances, dirAzimuth45, radius); string filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim45.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); foreach (double distance in distances) { Dictionary <double, double> azim45 = SimpleFormatter.Read( this.getFileFormat(dirAzimuth45, distance, radius)); gp.Plot(azim45, string.Format(@"title ""{0}""", distance)); } spectrum = this.zipToDictionary(distances, dirAzimuth0, radius); filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim0.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); spectrum = this.zipToDictionary(distances, dirAzimuth90, radius); filename = Path.Combine(BasePath, this.TestContext.TestName, "Azim90.txt"); SimpleFormatter.WriteDictionary(filename, spectrum, distances); gp.Wait(); }