Exemplo n.º 1
0
        /// <summary>
        /// Utility/Debug function, plots numbers at specific coordinates.
        /// </summary>
        /// <param name="X"></param>
        /// <param name="filename"></param>
        public static void PlotCoordinateLabels(this MultidimensionalArray X, string filename)
        {
            using (var gp = new Gnuplot()) {
                int L = X.NoOfRows;
                if (X.NoOfCols != 2)
                {
                    throw new NotSupportedException("works only for 2D grid");
                }

                gp.Cmd("set terminal png");
                gp.Cmd("set output \"{0}\"", filename);

                gp.SetXRange(-4, 4);
                gp.SetYRange(-4, 4);

                for (int l = 0; l < L; l++)
                {
                    gp.Cmd("set label \"{0}\" at {1},{2}", l, X[l, 0], X[l, 1]);
                }

                gp.PlotSlope(0, 0);
                gp.Execute();
            }
        }