Ejemplo n.º 1
0
            public static void DrawToFile(string filePath, params Point3Series[] series)
            {
                // arguments check
                if (string.IsNullOrWhiteSpace(filePath)) throw new ArgumentNullException(nameof(filePath));

                var plen = series
                    .Select(item => item._Points.Count)
                    .Max();

                if (plen < 1) throw new ArgumentOutOfRangeException($"The series only has {plen} values", nameof(series));

                if (series.Any(item => item._Lines))
                {
                    plen = series
                        .Where(item => item._Lines)
                        .Select(item => item._Points.Count)
                        .Max();

                    if (plen < 2) throw new ArgumentOutOfRangeException($"The series only has {plen} values", nameof(series));
                }

                var bounds = GetBounds(series);

                using (var pl = new PLplot.PLStream())
                {
                    pl.sdev("pngcairo");
                    pl.sfnam(filePath);
                    pl.spal0("cmap0_alternate.pal");

                    pl.init();

                    pl.env(bounds.Item1.X, bounds.Item2.X, bounds.Item1.Y, bounds.Item2.Y, PLplot.AxesScale.Independent, PLplot.AxisBox.BoxTicksLabelsAxes);

                    for (int i = 0; i < series.Length; ++i)
                    {
                        var ps = series[i];
                        var s = ps._Points;

                        var seriesX = new double[s.Count];
                        var seriesY = new double[s.Count];
                        var seriesZ = new double[s.Count];

                        for (int j = 0; j < s.Count; ++i)
                        {
                            seriesX[j] = s[j].X;
                            seriesY[j] = s[j].Y;
                            seriesZ[j] = s[j].Z;
                        }

                        pl.col0(i + 2);

                        if (ps._Lines) pl.line3(seriesX, seriesY, seriesZ);
                        else pl.poin3(seriesX, seriesY, seriesZ, ps._PointGlyph);
                    }

                    pl.eop(); // write to disk
                }
            }
Ejemplo n.º 2
0
            public static void DrawToFile(string filePath, params Point2Series[] series)
            {
                // arguments check
                if (string.IsNullOrWhiteSpace(filePath))
                {
                    throw new ArgumentNullException(nameof(filePath));
                }

                var bounds = GetBounds(series);

                try
                {
                    using (var pl = new PLplot.PLStream())
                    {
                        pl.sdev("pngcairo");
                        pl.sfnam(filePath);
                        pl.spal0("cmap0_alternate.pal");

                        pl.init();

                        pl.env(bounds.Item1.X, bounds.Item2.X, bounds.Item1.Y, bounds.Item2.Y, PLplot.AxesScale.Independent, PLplot.AxisBox.BoxTicksLabelsAxes);

                        for (int i = 0; i < series.Length; ++i)
                        {
                            var ps = series[i];
                            var s  = ps._Points;

                            var seriesX = new double[s.Count];
                            var seriesY = new double[s.Count];

                            for (int j = 0; j < s.Count; ++j)
                            {
                                seriesX[j] = s[j].X;
                                seriesY[j] = s[j].Y;
                            }

                            pl.col0(i + 2);

                            if (ps.LineType == LineType.Continuous)
                            {
                                pl.line(seriesX, seriesY);
                            }
                            else
                            {
                                pl.poin(seriesX, seriesY, (char)ps.LineType);
                            }
                        }

                        pl.eop(); // write to disk
                    }
                }
                catch
                {
                    NUnit.Framework.TestContext.WriteLine("PLPlot not supported.");
                }
            }