Esempio n. 1
0
        public void ExecuteRecipe(Plot plt)
        {
            // create sample data
            Random rand = new Random(3);

            double[] xs = DataGen.Consecutive(201);
            double[] ys = DataGen.RandomWalk(rand, xs.Length);

            // add filled polygons
            plt.AddFillAboveAndBelow(xs, ys);

            // tighten the axis limits so we don't see lines on the edges
            plt.SetAxisLimits(xMin: 0, xMax: 200);
        }
Esempio n. 2
0
        public void ExecuteRecipe(Plot plt)
        {
            var rand = new Random(0);

            double[] ys = DataGen.RandomWalk(rand, 200);
            double[] xs = DataGen.Consecutive(200);

            var sig = plt.AddSignalXY(xs, ys);

            sig.MarkerShape = MarkerShape.filledTriangleUp;
            sig.MarkerSize  = 10;

            plt.SetAxisLimits(100, 120, 10, 15);
        }
Esempio n. 3
0
            public void Render(Plot plt)
            {
                plt.Colorset(Palette.Nord);
                plt.Title($"{plt.Colorset().Name} Colorset");

                Random rand = new Random(0);

                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.AxisAuto(horizontalMargin: 0);
            }
Esempio n. 4
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] values = DataGen.RandomWalk(100);
            var      sig    = plt.AddSignal(values);

            sig.YAxisIndex = 1;

            plt.YAxis.Ticks(false);
            plt.YAxis.Grid(false);
            plt.YAxis2.Ticks(true);
            plt.YAxis2.Grid(true);
            plt.YAxis2.Label("Value");
            plt.XAxis.Label("Sample Number");
        }
Esempio n. 5
0
        public void Test_LargePlot_DateTimeAxis()
        {
            Random rand = new Random(0);

            double[] data     = DataGen.RandomWalk(rand, 100_000);
            DateTime firstDay = new DateTime(2020, 1, 1);

            var plt = new ScottPlot.Plot(4000, 400);

            plt.PlotSignal(data, sampleRate: 60 * 24, xOffset: firstDay.ToOADate());
            plt.Ticks(dateTimeX: true);

            TestTools.SaveFig(plt);
        }
Esempio n. 6
0
        public void Test_AxisLine_FarAwayExpandXY()
        {
            Random rand = new Random(0);

            var plt  = new ScottPlot.Plot();
            var data = DataGen.RandomWalk(rand, 100);

            plt.PlotSignal(data, xOffset: 100, yOffset: 100, label: "scatter");
            plt.PlotVLine(-100, label: "vertical");
            plt.PlotHLine(-100, label: "horizontal");
            plt.Legend();

            TestTools.SaveFig(plt);
        }
Esempio n. 7
0
            public void Render(Plot plt)
            {
                plt.DiagnosticMode = true;

                // plot some valid data
                Random rand = new Random(0);

                double[] ys = DataGen.RandomWalk(rand, 1000);
                double[] xs = DataGen.Consecutive(ys.Length);
                plt.PlotSignalXY(xs, ys);

                // modify X values so they are not all ascending
                xs[245] = xs[244] - 9;
            }
Esempio n. 8
0
            public void Render(Plot plt)
            {
                Random rand       = new Random(0);
                int    pointCount = (int)1e6;
                int    lineCount  = 5;

                for (int i = 0; i < lineCount; i++)
                {
                    plt.PlotSignal(DataGen.RandomWalk(rand, pointCount));
                }

                plt.Title("Signal Plot Quickstart (5 million points)");
                plt.YLabel("Vertical Units");
                plt.XLabel("Horizontal Units");
            }
Esempio n. 9
0
        public void Test_TickAlignment_SnapEdgePixel()
        {
            Random rand = new Random(0);

            double[] xs = DataGen.Range(0, 10, .1, true);
            double[] ys = DataGen.RandomWalk(rand, xs.Length, .5);

            var plt = new ScottPlot.Plot(320, 240);

            plt.AddScatter(xs, ys, markerSize: 0);
            plt.AddScatter(ys, xs, markerSize: 0);
            plt.AxisAuto(0, 0);

            TestTools.SaveFig(plt);
        }
Esempio n. 10
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] data = DataGen.RandomWalk(1000);

            var sig = plt.AddSignal(data);

            sig.FillType           = FillType.FillAboveAndBelow;
            sig.FillColor1         = Color.Green;
            sig.GradientFillColor1 = Color.Green;
            sig.FillColor2         = Color.Red;
            sig.GradientFillColor2 = Color.Red;
            sig.BaselineY          = 5;

            plt.AxisAutoX(0);
        }
Esempio n. 11
0
        private ScottPlot.Plot GetDemoPlot()
        {
            Random rand = new Random(0);
            var    plt  = new ScottPlot.Plot();

            plt.AddScatter(DataGen.Random(rand, 100, 20), DataGen.Random(rand, 100, 5, 3), label: "scatter1");
            plt.AddSignal(DataGen.RandomWalk(rand, 100), label: "signal1");
            plt.AddScatter(DataGen.Random(rand, 100), ScottPlot.DataGen.Random(rand, 100), label: "scatter2");
            plt.AddSignal(DataGen.RandomWalk(rand, 100), label: "signal2");
            plt.AddVerticalLine(43, width: 4, label: "vline");
            plt.AddHorizontalLine(1.23, width: 4, label: "hline");
            plt.AddText("ScottPlot", 50, 0.25);
            plt.Legend();
            return(plt);
        }
Esempio n. 12
0
            public void Render(Plot plt)
            {
                plt.Style(Style.Gray1);
                plt.Colorset(Colorset.OneHalfDark);
                plt.Title($"{plt.Colorset().Name} Colorset");

                Random rand = new Random(0);

                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.PlotSignal(DataGen.RandomWalk(rand, 1000), lineWidth: 2);
                plt.AxisAuto(horizontalMargin: 0);
            }
Esempio n. 13
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] data = DataGen.RandomWalk(1000);

            plt.Style(Style.Gray1);

            var sig = plt.AddSignal(data);

            sig.MarkerSize = 0;
            sig.Color      = Color.Black;
            sig.FillAboveAndBelow(Color.Green, Color.Transparent, Color.Transparent, Color.Red, 1);
            sig.BaselineY = 5;

            plt.Margins(x: 0);
        }
Esempio n. 14
0
        public void Test_LargePlot_DateTimeAxis()
        {
            Random rand = new Random(0);

            double[] data     = DataGen.RandomWalk(rand, 100_000);
            DateTime firstDay = new DateTime(2020, 1, 1);

            var plt = new ScottPlot.Plot(4000, 400);
            var sig = plt.AddSignal(data, sampleRate: 60 * 24);

            sig.OffsetX = firstDay.ToOADate();

            plt.XAxis.DateTimeFormat(true);

            TestTools.SaveFig(plt);
        }
        public PlotInScrollViewer()
        {
            InitializeComponent();

            // initialize plots with random data
            Random Rand = new Random(0);

            wpfPlot1.Plot.AddSignal(DataGen.RandomWalk(Rand, 50));
            wpfPlot2.Plot.AddSignal(DataGen.RandomWalk(Rand, 50));
            wpfPlot3.Plot.AddSignal(DataGen.RandomWalk(Rand, 50));

            // perform an initial render for each control
            wpfPlot1.Refresh();
            wpfPlot2.Refresh();
            wpfPlot3.Refresh();
        }
Esempio n. 16
0
        public void ExecuteRecipe(Plot plt)
        {
            // create a small number of X/Y data points and display them
            Random rand = new(1234);

            double[] xs = DataGen.RandomWalk(rand, 20);
            double[] ys = DataGen.RandomWalk(rand, 20);

            // interpolate the data to create a smooth curve
            (double[] smoothXs, double[] smoothYs) = ScottPlot.Statistics.Interpolation.Cubic.InterpolateXY(xs, ys, 200);

            // plot the original vs interpolated lines
            plt.AddScatter(xs, ys, Color.Green, markerSize: 10, lineWidth: 1, label: "Original");
            plt.AddScatter(smoothXs, smoothYs, Color.Magenta, label: "Interpolated");
            plt.Legend();
        }
Esempio n. 17
0
        public MouseTracker()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.plt.PlotSignal(DataGen.RandomWalk(null, 100));
            vLine = avaPlot1.plt.PlotVLine(0, color: System.Drawing.Color.Red, lineStyle: LineStyle.Dash);
            hLine = avaPlot1.plt.PlotHLine(0, color: System.Drawing.Color.Red, lineStyle: LineStyle.Dash);
            avaPlot1.Render();

            avaPlot1.PointerMoved += OnMouseMove;
        }
Esempio n. 18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            vline = formsPlot1.plt.PlotVLine(1);
            hline = formsPlot1.plt.PlotHLine(1);

            formsPlot1.plt.PlotHSpan(10, 20, draggable: true);
            formsPlot1.plt.PlotVSpan(5, 10, draggable: true);

            Random rand = new Random(0);

            double[] xs = DataGen.Consecutive(100);
            double[] ys = DataGen.RandomWalk(rand, 100);
            sph = formsPlot1.plt.PlotScatterHighlight(xs, ys);

            formsPlot1.Render();
        }
Esempio n. 19
0
            public void Render(Plot plt)
            {
                Random rand = new Random(0);

                double[] data = DataGen.RandomWalk(rand, 100_000);
                var      sig  = plt.PlotSignal(data);

                sig.minRenderIndex     = 4000;
                sig.maxRenderIndex     = 5000;
                sig.fillType           = FillType.FillAbove;
                sig.fillColor1         = Color.Blue;
                sig.gradientFillColor1 = Color.Transparent;
                plt.Title($"Partial Display of a {data.Length} values using gradient fill above");
                plt.YLabel("Value");
                plt.XLabel("Array Index");
                plt.AxisAutoX(margin: 0);
            }
Esempio n. 20
0
            public void Render(Plot plt)
            {
                Random rand = new Random(0);
                double[] ys = DataGen.RandomWalk(rand, 100);
                double[] xs = new double[ys.Length];

                DateTime dtStart = new DateTime(1985, 9, 24);
                for (int i = 0; i < ys.Length; i++)
                {
                    DateTime dtNow = dtStart.AddSeconds(i);
                    xs[i] = dtNow.ToOADate();
                }

                plt.PlotScatter(xs, ys);
                plt.Ticks(dateTimeX: true);
                plt.Title("DateTime Axis Labels");
            }
Esempio n. 21
0
        public PlotInScrollViewer()
        {
            InitializeComponent();

            WpfPlot[] wpfPlots = { wpfPlot1, wpfPlot2, wpfPlot3 };

            foreach (WpfPlot wpfPlot in wpfPlots)
            {
                for (int i = 0; i < 3; i++)
                {
                    wpfPlot.Plot.AddSignal(DataGen.RandomWalk(rand, 100));
                }

                wpfPlot.Configuration.ScrollWheelZoom = false;
                wpfPlot.Render();
            }
        }
Esempio n. 22
0
        private void BtnLaunchRandomWalk_Click(object sender, EventArgs e)
        {
            int pointCount = (int)nudWalkPoints.Value;

            double[] randomWalkData = DataGen.RandomWalk(rand, pointCount);

            var plt = new ScottPlot.Plot();

            plt.AddSignal(randomWalkData);
            plt.Title($"{pointCount} Random Walk Points");

            var plotViewer = new ScottPlot.Eto.PlotViewForm(plt, 500, 300, "Random Walk Data");

            plotViewer.PlotView.Configuration.Quality = Control.QualityMode.High; // customize as desired
            plotViewer.Owner = this;                                              // so it closes if this window closes
            plotViewer.Show();                                                    // or ShowDialog() for a blocking window
        }
Esempio n. 23
0
            public void Render(Plot plt)
            {
                // simulate 10 seconds of audio data
                int    pointsPerSecond = 44100;
                Random rand            = new Random(0);

                double[] ys = DataGen.RandomWalk(rand, pointsPerSecond * 10);

                // For DateTime compatibility, sample rate must be points/day.
                // Also, avoid negative dates by offsetting the plot by today's date.
                double secondsPerDay = 24 * 60 * 60;
                double pointsPerDay  = secondsPerDay * pointsPerSecond;
                double today         = DateTime.Today.ToOADate();

                plt.PlotSignal(ys, sampleRate: pointsPerDay, xOffset: today);
                plt.Ticks(dateTimeX: true, dateTimeFormatStringX: "HH:mm:ss.fff");
            }
Esempio n. 24
0
        public MouseTracker()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif

            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.Plot.AddSignal(DataGen.RandomWalk(null, 100));
            Crosshair = avaPlot1.Plot.AddCrosshair(0, 0);
            avaPlot1.Render();

            avaPlot1.PointerMoved += OnMouseMove;
            avaPlot1.PointerLeave += OnMouseLeave;
            avaPlot1.PointerEnter += OnMouseEnter;
        }
Esempio n. 25
0
        public void ExecuteRecipe(Plot plt)
        {
            // create data sample data
            DateTime[] myDates = new DateTime[100];
            for (int i = 0; i < myDates.Length; i++)
            {
                myDates[i] = new DateTime(1985, 9, 24).AddDays(7 * i);
            }

            // Convert DateTime[] to double[] before plotting
            double[] xs = myDates.Select(x => x.ToOADate()).ToArray();
            double[] ys = DataGen.RandomWalk(myDates.Length);
            plt.AddScatter(xs, ys);

            // Then tell the axis to display tick labels using a time format
            plt.XAxis.DateTimeFormat(true);
        }
Esempio n. 26
0
        public void Test_Remove_RemovesSinglePlot()
        {
            var plt = new ScottPlot.Plot();

            Random rand = new Random(0);
            var    barX = plt.AddPoint(111, 222, label: "X");
            var    sigA = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "A");
            var    sigB = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "B");
            var    sigC = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "C");
            var    sigD = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "D");
            var    sigE = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "E");
            var    barY = plt.AddPoint(111, 222, label: "Y");

            Assert.AreEqual("X,A,B,C,D,E,Y", GetLegendLabels(plt));
            plt.Remove(sigC);
            Assert.AreEqual("X,A,B,D,E,Y", GetLegendLabels(plt));
        }
Esempio n. 27
0
        private void btnLaunchRandomWalk_Click(object sender, EventArgs e)
        {
            int pointCount = (int)nudWalkPoints.Value;

            double[] randomWalkData = DataGen.RandomWalk(rand, pointCount);

            var plt = new ScottPlot.Plot();

            plt.PlotSignal(randomWalkData);
            plt.Title($"{pointCount} Random Walk Points");

            var plotViewer = new ScottPlot.FormsPlotViewer(plt, 500, 300, "Random Walk Data");

            plotViewer.Owner = this;                                         // so it closes if this window closes
            plotViewer.formsPlot1.Configure(lowQualityWhileDragging: false); // customize as desired
            plotViewer.Show();                                               // or ShowDialog() for a blocking window
        }
Esempio n. 28
0
        public void Test_Remove_RemovesSinglePlot()
        {
            var plt = new ScottPlot.Plot();

            Random rand = new Random(0);
            var    barX = plt.PlotPoint(111, 222, label: "X");
            var    sigA = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "A");
            var    sigB = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "B");
            var    sigC = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "C");
            var    sigD = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "D");
            var    sigE = plt.PlotSignal(DataGen.RandomWalk(rand, 100), label: "E");
            var    barY = plt.PlotPoint(111, 222, label: "Y");

            Assert.AreEqual("X,A,B,C,D,E,Y", string.Join(",", plt.GetPlottables().Select(x => x.GetLegendItems()[0].label)));
            plt.Remove(sigC);
            Assert.AreEqual("X,A,B,D,E,Y", string.Join(",", plt.GetPlottables().Select(x => x.GetLegendItems()[0].label)));
        }
Esempio n. 29
0
        public void ExecuteRecipe(Plot plt)
        {
            int    pointCount = 20;
            Random rand       = new Random(0);

            double[] xs   = DataGen.Consecutive(pointCount);
            double[] ys   = DataGen.RandomWalk(rand, pointCount);
            double[] xErr = DataGen.RandomNormal(rand, pointCount, .2);
            double[] yErr = DataGen.RandomNormal(rand, pointCount);

            var sp = plt.AddScatter(xs, ys);

            sp.XError         = xErr;
            sp.YError         = yErr;
            sp.ErrorCapSize   = 3;
            sp.ErrorLineWidth = 1;
            sp.LineStyle      = LineStyle.Dot;
        }
Esempio n. 30
0
        public void ExecuteRecipe(Plot plt)
        {
            // generate 10 days of data
            int pointCount = 10;

            double[] values = DataGen.RandomWalk(null, pointCount);
            double[] days   = new double[pointCount];
            DateTime day1   = new DateTime(1985, 09, 24);

            for (int i = 0; i < days.Length; i++)
            {
                days[i] = day1.AddDays(1).AddDays(i).ToOADate();
            }

            // plot the data with custom tick format (https://tinyurl.com/ycwh45af)
            plt.AddScatter(days, values);
            plt.XAxis.TickLabelFormat("M\\/dd", dateTimeFormat: true);
        }