Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            GnuPlot gp = new GnuPlot();

            gp.HoldOn();
            gp.Unset("key");
            gp.Plot(NoisySine(1000, 1));
            gp.Plot(NoisySine(1000, 1.5));
            gp.Plot(NoisySine(1000, 2));
        }
Exemplo n.º 2
0
        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)");
        }
Exemplo n.º 3
0
        // 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\"");
        }
Exemplo n.º 4
0
        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");
        }
Exemplo n.º 5
0
        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();
        }
Exemplo n.º 6
0
        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'");
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            string       path   = "C:\\Users\\King\\Desktop\\EnvisBackUps\\2018-04.cea";
            MyDataReader reader = new MyDataReader();

            reader.LoadCea(path);
            ;

            List <UniArchiveBase> result = new List <UniArchiveBase>();

            for (int i = 0; i < 10000; i++)
            {
                result.Add(reader.LoadNext());
            }

            // values restricted to one day 1.4.2018
            var hours   = reader.values.Where(i => i.Key.Day == 1 && i.Key.Month == 4).Select(i => double.Parse(i.Key.Hour.ToString())).ToArray(); // 8644 values for each 10 seconds
            var values  = reader.values.Where(i => i.Key.Day == 1 && i.Key.Month == 4).Select(i => double.Parse(i.Value)).ToArray();               // 8644 values for each 10 seconds
            var values2 = result.Select(i => double.Parse(i.GetMemberValue("I_avg_3I").ToString())).Take(8644).ToArray();
            var values3 = result.Select(i => double.Parse(i.GetMemberValue("U_avg_U3").ToString())).Take(8644).ToArray();

            GnuPlot.Set("encoding utf8");

            string tempfolder = System.IO.Path.GetTempPath();

            tempfolder = "C:\\\\Users\\\\King\\\\Documents\\\\BP\\\\";
            //data
            GnuPlot.SaveData(hours, values, tempfolder + "plot1.data");
            GnuPlot.SaveData(hours, values2, tempfolder + "plot2.data");
            GnuPlot.SaveData(hours, values3, tempfolder + "plot3.data");

            string output = "output \"" + tempfolder + "P_avg_3P_C_fromGnuPlot.pdf\"";

            //set output to pdf
            GnuPlot.Set("terminal pdf size 10in,8in");
            //GnuPlot.Set("terminal pdf enhanced size 16cm,8cm font \", 10\"");
            GnuPlot.Set(output);


            //set common properties of plot
            string multiplot = "multiplot layout 3, 1 title \"1.4.2018\" font \", 14\"";

            GnuPlot.Set(multiplot);
            GnuPlot.Set("tmargin 3");
            GnuPlot.Set("bmargin 3");
            GnuPlot.Set("rmargin 10");
            GnuPlot.Set("lmargin 10");

            //first line
            GnuPlot.Set("xrange  [0:24]");
            GnuPlot.Set("xtics 1");
            GnuPlot.Set("ytics 600");
            GnuPlot.Set("grid");
            GnuPlot.Set("title \"1.4.2018 řada P-avg-3P-C\"");
            GnuPlot.Set("ylabel  \"P(W)\"");
            GnuPlot.Set("xlabel  \"dayhours (h)\"");
            GnuPlot.Unset("key");
            GnuPlot.Plot(tempfolder + "plot1.data", "with linespoints pt " + (int)PointStyles.Dot + " lt 6 lw 4");

            //second line
            GnuPlot.Set("xrange  [0:24]");
            GnuPlot.Set("xtics 1");
            GnuPlot.Set("ytics 1");
            GnuPlot.Set("grid");
            GnuPlot.Set("title \"1.4.2018 řada I-avg-3I\"");
            GnuPlot.Set("ylabel  \"I(A)\"");
            GnuPlot.Set("xlabel  \"dayhours (h)\"");
            GnuPlot.Unset("key");
            GnuPlot.Plot(tempfolder + "plot2.data", "with linespoints pt " + (int)PointStyles.Dot + " lt 4 lw 4");

            //third line
            GnuPlot.Set("xrange  [0:24]");
            GnuPlot.Set("yrange  [220:250]");
            GnuPlot.Set("xtics 1");
            GnuPlot.Set("ytics 5");
            GnuPlot.Set("grid");
            GnuPlot.Set("title \"1.4.2018 řada U-avg-U3\"");

            GnuPlot.Set("ylabel  \"U(V)\"");
            GnuPlot.Set("xlabel  \"dayhours (h)\"");
            GnuPlot.Unset("key");
            GnuPlot.Plot(tempfolder + "plot3.data", "with linespoints pt " + (int)PointStyles.Dot + " lt 2 lw 4");

            //trying To REMOVe if not works
            GnuPlot.Unset("multiplot");
            GnuPlot.Unset("output");


            //GnuPlot.Replot();
            //GnuPlot.Write("pause 10");
            //GnuPlot.Write("reread");

            //GnuPlot.Set("terminal png size 800,600");
            //GnuPlot.Set("output \"P_avg_3P_C_fromGnuPlot.png\"");
            //GnuPlot.Replot();
            //GnuPlot.Plot(tempfolder + "plot1.data", "with linespoints pt " + (int)PointStyles.Dot + " lt 6 lw 4");

            Console.ReadLine();
        }