Beispiel #1
0
        /// <summary>
        /// Simple plotting interface
        /// </summary>
        /// <returns>Output of <see cref="GnuplotExtensions.PlotNow(Gnuplot)"/></returns>
        static public object Plot(IEnumerable <double> X1, IEnumerable <double> Y1, string Name1 = null, string Format1 = null,
                                  IEnumerable <double> X2 = null, IEnumerable <double> Y2 = null, string Name2 = null, string Format2 = null,
                                  IEnumerable <double> X3 = null, IEnumerable <double> Y3 = null, string Name3 = null, string Format3 = null,
                                  IEnumerable <double> X4 = null, IEnumerable <double> Y4 = null, string Name4 = null, string Format4 = null,
                                  IEnumerable <double> X5 = null, IEnumerable <double> Y5 = null, string Name5 = null, string Format5 = null,
                                  IEnumerable <double> X6 = null, IEnumerable <double> Y6 = null, string Name6 = null, string Format6 = null,
                                  IEnumerable <double> X7 = null, IEnumerable <double> Y7 = null, string Name7 = null, string Format7 = null,
                                  bool logX = false, bool logY = false)
        {
            using (var gp = new Gnuplot()) {
                IEnumerable <double>[] Xs = new[] { X1, X2, X3, X4, X5, X6, X7 };
                IEnumerable <double>[] Ys = new[] { Y1, Y2, Y3, Y4, Y5, Y6, Y7 };
                string[] Ns = new string[] { Name1, Name2, Name3, Name4, Name5, Name6, Name7 };
                string[] Fs = new string[] { Format1, Format2, Format3, Format4, Format5, Format6, Format7 };

                for (int i = 0; i < 7; i++)
                {
                    if (Ys[i] != null)
                    {
                        var f1 = new PlotFormat();
                        if (Fs[i] != null)
                        {
                            f1.FromString(Fs[i]);
                        }
                        gp.PlotXY(Xs[i], Ys[i], title: Ns[i], format: f1, logX: logX, logY: logY);
                    }
                }

                return(gp.PlotNow());
            }
        }
        /// <summary>
        /// Interactive plotting using gnuplot.
        /// </summary>
        public Gnuplot.Gnuplot Plot()
        {
            var data = this.ResultData;

            if (data == null)
            {
                throw new NotSupportedException("No data available: user must call 'RunAndLog()' first.");
            }

            var gp = new Gnuplot.Gnuplot();

            gp.Cmd("set key t l");

            var fmt   = new PlotFormat("rx-");
            int Kount = 1;

            foreach (var ttt in ExpectedSlopes)
            {
                double[] xVals     = data[ttt.Item1.ToString()];
                string[] allYNames = data.Keys.Where(name => ttt.Item2.WildcardMatch(name)).ToArray();

                foreach (string yName in allYNames)
                {
                    double[] yVals = data[yName];
                    double   Slope = LogLogRegression(xVals, yVals);



                    gp.PlotXY(xVals, yVals, logX: true, logY: true, title: yName, format: (fmt.WithLineColor(Kount).WithPointType(Kount)));
                    gp.SetXLabel(ttt.Item1.ToString());

                    Kount++;
                }
            }


            return(gp);
        }
Beispiel #3
0
        /// <summary>
        /// Maybe useful for multi-plots, when just one plot should show the legend for all plots:
        /// It loops over all plots, collects all names and formats and adds a dummy graph to a specific
        /// plot if the name/format pair is not already shown in this plot.
        /// </summary>
        /// <param name="multiplots"></param>
        /// <param name="I">destination plot (where the dummys are added) row</param>
        /// <param name="J">destination plot (where the dummys are added) column</param>
        /// <param name="byName">
        /// - if true: go by <see cref="Plot2Ddata.XYvalues.Name"/>.
        /// - if false: go by <see cref="Plot2Ddata.XYvalues.Format"/>.
        /// </param>
        /// <param name="DummyX">x-value of the dummy plot to add, should be outside visible range, <see cref="Plot2Ddata.XrangeMax"/>.</param>
        /// <param name="DummyY">y-value of the dummy plot to add, should be outside visible range, <see cref="Plot2Ddata.YrangeMax"/>.</param>
        public static void AddDummyPlotsForLegend(this Plot2Ddata[,] multiplots, int I, int J, bool byName = true, double DummyX = 1e55, double DummyY = 1e56)
        {
            // collect all names & formats
            // ---------------------------

            var names = new List <string>();
            var fomts = new List <PlotFormat>();

            for (int i = 0; i < multiplots.GetLength(0); i++)
            {
                for (int j = 0; j < multiplots.GetLength(1); j++)
                {
                    if (multiplots[i, j] != null)
                    {
                        foreach (var p in multiplots[i, j].dataGroups)
                        {
                            bool isthere;
                            if (byName)
                            {
                                isthere = names.Contains(p.Name);
                            }
                            else
                            {
                                isthere = fomts.Contains(p.Format);
                            }

                            if (!isthere)
                            {
                                names.Add(p.Name);
                                fomts.Add(p.Format);
                            }
                        }
                    }
                }
            }
            // see what we have to add
            // -----------------------

            for (int iGraph = 0; iGraph < names.Count; iGraph++)
            {
                //foreach (var p in multiplots[I, J].dataGroups) {
                //
                //}
                string     nmn = names[iGraph];
                PlotFormat fmt = fomts[iGraph];

                bool isThere;
                if (byName)
                {
                    isThere = multiplots[I, J].dataGroups.Where(gr => gr.Name.Equals(nmn)).Count() > 0;
                }
                else
                {
                    isThere = multiplots[I, J].dataGroups.Where(gr => gr.Format.Equals(fmt)).Count() > 0;
                }

                if (!isThere)
                {
                    Plot2Ddata.XYvalues dummy = new Plot2Ddata.XYvalues(nmn)
                    {
                        Format    = fmt,
                        Abscissas = new double[] { DummyX },
                        Values    = new double[] { DummyY }
                    };

                    ArrayTools.AddToArray(dummy, ref multiplots[I, J].dataGroups);
                }
            }
        }
Beispiel #4
0
 public TargetViewModel(string target, string refId, PlotFormat type)
 {
     Target = target;
     RefId  = refId;
     Format = type;
 }