Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new data set where <see cref="LogY"/> is to true. Useful
        /// for command chaining on the console.
        /// </summary>
        /// <returns>
        /// A copy of this object where <see cref="LogY"/> equals true.
        /// </returns>
        public Plot2Ddata WithLogY()
        {
            var set = new Plot2Ddata(this);

            set.LogY = true;
            return(set);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Merges the this object and the given data set
        /// <paramref name="other"/> into a new data set (while making a deep
        /// copy of the data)
        /// </summary>
        /// <param name="other">
        /// The data set to be merged into this one
        /// </param>
        /// <returns>
        /// A data set containing all data in this object and
        /// <paramref name="other"/>
        /// </returns>
        public Plot2Ddata Merge(Plot2Ddata other)
        {
            if (this.LogX != other.LogX || this.LogY != other.LogY)
            {
                throw new Exception("Data sets have incompatible logarithmic scaling options");
            }

            IList <XYvalues> mergedGroups = new List <XYvalues>(this.dataGroups.Length + other.dataGroups.Length);

            mergedGroups.AddRange(this.dataGroups.Select(g => g.CloneAs()));
            foreach (XYvalues otherGroup in other.dataGroups)
            {
                if (this.dataGroups.Any(g => g.Name == otherGroup.Name))
                {
                    throw new NotSupportedException(String.Format(
                                                        "Group key '{0}' exists in both data sets. This is not supported.",
                                                        otherGroup.Name));
                }

                mergedGroups.Add(otherGroup.CloneAs());
            }

            Plot2Ddata result = new Plot2Ddata(mergedGroups.ToArray());

            result.LogX = this.LogX;
            result.LogY = this.LogY;
            return(result);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="originalSet">
 /// Object to be copied from.
 /// </param>
 private Plot2Ddata(Plot2Ddata originalSet)
     : this()
 {
     this.dataGroups = originalSet.dataGroups;
     this.LogX       = originalSet.LogX;
     this.LogY       = originalSet.LogY;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// <see cref="Plot2Ddata"/> into an alive Gnuplot object and executes Gnuplot interactively
        /// </summary>
        public static void PlotInteractive(this Plot2Ddata _2DData, GnuplotPageLayout layout = null)
        {
            using (var gp = ToGnuplot(_2DData, layout)) {
                Console.WriteLine("Executing Gnulpot...");
                gp.Execute();

                Console.WriteLine("Press any key to continue...");
                Console.ReadKey(true);
                Console.WriteLine("killing gnuplot...");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Single plot window:
        /// Converts <see cref="Plot2Ddata"/> into an alive Gnuplot object.
        /// </summary>
        public static Gnuplot ToGnuplot(this Plot2Ddata _2DData, GnuplotPageLayout layout = null)
        {
            if (layout != null)
            {
                throw new NotImplementedException("todo");
            }

            Gnuplot gp = new Gnuplot();

            _2DData.ToGnuplot(gp);
            return(gp);
        }