Example #1
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] data = DataGen.RandomWalk(1000);

            var sig = plt.AddSignal(data);

            sig.FillAboveAndBelow(Color.Green, Color.Red);
            sig.Color     = Color.Black;
            sig.BaselineY = 7;

            plt.Margins(x: 0);
        }
Example #2
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] data = DataGen.RandomWalk(1000);

            var sig = plt.AddSignal(data);

            sig.FillType           = FillType.FillAbove;
            sig.FillColor1         = Color.Blue;
            sig.GradientFillColor1 = Color.Transparent;

            plt.AxisAutoX(0);
        }
Example #3
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.Title("Customized Crosshair");
            plt.XLabel("Horizontal Axis");
            plt.YLabel("Vertical Axis");

            plt.AddSignal(ScottPlot.DataGen.Sin(51));
            plt.AddSignal(ScottPlot.DataGen.Cos(51));

            var ch = plt.AddCrosshair(42, 0.48);

            // you can style both lines at the same time
            ch.LineStyle = LineStyle.Dash;
            ch.Color     = System.Drawing.Color.Blue;
            ch.LineWidth = 2;

            // or reach in and style lines individually
            ch.HorizontalLine.PositionLabelFont.Size = 16;
            ch.VerticalLine.PositionLabelFont.Size   = 8;
            ch.VerticalLine.LineStyle = LineStyle.Dot;
        }
Example #4
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand = new Random(0);

            for (int i = 0; i < 5; i++)
            {
                // add a new signal plot with one million points
                double[] values = DataGen.RandomWalk(rand, 1_000_000);
                plt.AddSignal(values);
            }
            plt.Benchmark(enable: true);
        }
Example #5
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot the positive data in the negative space
            double[] values = DataGen.Sin(50);
            var      sig    = plt.AddSignal(values);

            sig.OffsetX = -50;

            // then invert the sign of the axis tick labels
            plt.XAxis.TickLabelNotation(invertSign: true);
            plt.YAxis.TickLabelNotation(invertSign: true);
        }
Example #6
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot the positive data in the negative space
            double[] values = DataGen.Sin(50);
            var      sig    = plt.AddSignal(values);

            sig.OffsetX = -50;

            // then invert the sign of the axis tick labels
            plt.XAxis.ManualTickSpacing(2);
            plt.YAxis.ManualTickSpacing(.1);
        }
Example #7
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] ys         = DataGen.RandomWalk(null, 500);
            int      sampleRate = 10;

            var sp2 = plt.AddSignal(ys, sampleRate, Color.Magenta);

            sp2.OffsetY   = 1000;
            sp2.OffsetX   = 300;
            sp2.LineStyle = LineStyle.Dash;
            sp2.LineWidth = 2;
        }
Example #8
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot one set of data using the primary Y axis
            var sigSmall = plt.AddSignal(DataGen.Sin(51, mult: 1), sampleRate: 1);
            sigSmall.YAxisIndex = 0;
            sigSmall.XAxisIndex = 0;
            plt.XAxis.Label("Primary X Axis");
            plt.YAxis.Label("Secondary Y Axis");
            plt.XAxis.Color(sigSmall.Color);
            plt.YAxis.Color(sigSmall.Color);

            // plot another set of data using the secondary axes
            var sigBig = plt.AddSignal(DataGen.Cos(51, mult: 100), sampleRate: 100);
            sigBig.YAxisIndex = 1;
            sigBig.XAxisIndex = 1;
            plt.YAxis2.Ticks(true); // ticks weren't visible by default
            plt.XAxis2.Ticks(true); // ticks weren't visible by default
            plt.YAxis2.Color(sigBig.Color);
            plt.XAxis2.Color(sigBig.Color);
            plt.YAxis2.Label("Secondary Y Axis");
            plt.XAxis2.Label("Secondary X Axis");
        }
Example #9
0
        public void ExecuteRecipe(Plot plt)
        {
            var rand = new Random(0);

            double[] values     = DataGen.RandomWalk(rand, 100_000);
            int      sampleRate = 20_000;

            // Signal plots require a data array and a sample rate (points per unit)
            plt.AddSignal(values, sampleRate);

            plt.Benchmark(enable: true);
            plt.Title($"Signal Plot: One Million Points");
        }
Example #10
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot sample data
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            // add axis lines and configure their drag settings
            var hLine = plt.AddHorizontalLine(.85);

            hLine.DragEnabled  = true;
            hLine.DragLimitMin = -1;
            hLine.DragLimitMax = 1;

            var vLine = plt.AddVerticalLine(23);

            vLine.DragEnabled  = true;
            vLine.DragLimitMin = 0;
            vLine.DragLimitMax = 50;

            // you can access the position of an axis line at any time
            string message = $"Vertical line is at X={vLine.X}";
        }
Example #11
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] values = DataGen.RandomWalk(100);
            var sig = plt.AddSignal(values);
            sig.XAxisIndex = 1;

            plt.XAxis.Ticks(false);
            plt.XAxis.Grid(false);
            plt.XAxis2.Ticks(true);
            plt.XAxis2.Grid(true);
            plt.XAxis2.Label("Sample Number");
            plt.YAxis.Label("Value");
        }
Example #12
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            var hline = plt.AddHorizontalLine(.85);

            hline.LineWidth               = 2;
            hline.PositionLabel           = true;
            hline.PositionLabelBackground = hline.Color;
            hline.DragEnabled             = true;

            var vline = plt.AddVerticalLine(23);

            vline.LineWidth               = 2;
            vline.PositionLabel           = true;
            vline.PositionLabelBackground = vline.Color;
            vline.DragEnabled             = true;

            Func <double, string> xFormatter = x => $"X={x:F2}";

            vline.PositionFormatter = xFormatter;
        }
Example #13
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] ys = DataGen.Sin(50);
            plt.AddSignal(ys);

            var tt = plt.AddTooltip("This point has\na negative slope", 25, ys[25]);

            tt.Font.Size   = 24;
            tt.Font.Color  = System.Drawing.Color.White;
            tt.FillColor   = System.Drawing.Color.Blue;
            tt.BorderWidth = 5;
            tt.BorderColor = System.Drawing.Color.Navy;
            tt.ArrowSize   = 15;
        }
Example #14
0
        public void ExecuteRecipe(Plot plt)
        {
            //Generate a single signal containing 3 harmonic signals
            int sampleCount = 500;

            double[] signal1 = ScottPlot.DataGen.Sin(sampleCount, 10);
            double[] signal2 = ScottPlot.DataGen.Sin(sampleCount, 20);
            double[] signal3 = ScottPlot.DataGen.Sin(sampleCount, 30);

            double[] signal = new double[sampleCount];
            for (int index = 0; index < sampleCount; index++)
            {
                signal[index] = signal1[index] + signal2[index] + signal3[index];
            }

            // Plot the signal
            plt.AddSignal(signal);

            // Create a draggable RepeatingVLine with 5 lines spaced evenly by 50 X units, starting at position 0
            // The first line will be thicker than the others
            ScottPlot.Plottable.RepeatingVLine vlines1 = new();
            vlines1.DragEnabled             = true;
            vlines1.count                   = 5;
            vlines1.shift                   = 50;
            vlines1.Color                   = System.Drawing.Color.Magenta;
            vlines1.LineWidth               = 2;
            vlines1.LineStyle               = LineStyle.Dash;
            vlines1.PositionLabel           = true;
            vlines1.PositionLabelBackground = vlines1.Color;
            vlines1.relativeposition        = false;
            plt.Add(vlines1);

            // Create a draggable RepeatingVLine with 5 lines spaced evenly by 50 X units, starting at position 0, with a -4 offset
            // The first line will be thicker than the others
            ScottPlot.Plottable.RepeatingVLine vlines2 = new();
            vlines2.DragEnabled             = true;
            vlines2.count                   = 3;
            vlines2.shift                   = 50;
            vlines2.offset                  = -1;
            vlines2.Color                   = System.Drawing.Color.DarkGreen;
            vlines2.LineWidth               = 2;
            vlines2.LineStyle               = LineStyle.Dot;
            vlines2.PositionLabel           = true;
            vlines2.PositionLabelBackground = vlines2.Color;
            vlines2.relativeposition        = false;
            plt.Add(vlines2);

            plt.SetAxisLimitsX(-100, 300);
        }
Example #15
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);
        }
Example #16
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);
        }
Example #17
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] ys = DataGen.Sin(50);
            plt.AddSignal(ys);

            var tt1 = plt.AddTooltip("Top", 12, ys[12]);

            tt1.Font.Color = System.Drawing.Color.Magenta;
            tt1.Font.Size  = 24;

            var tt2 = plt.AddTooltip("Negative Slope", 25, ys[25]);

            tt2.Font.Name = "Comic Sans MS";
            tt2.Font.Bold = true;
        }
Example #18
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand = new Random(0);

            const int n = 500;

            double[] ys = DataGen.Random(rand, n);

            double second_septile = ScottPlot.Statistics.Common.Quantile(ys, 2, 7); // A septile is a 7-quantile

            plt.AddSignal(ys, label: "Random Data");
            plt.AddHorizontalLine(second_septile, label: "2nd Septile");

            plt.Legend();
        }
Example #19
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand = new Random(0);

            const int n = 500;

            double[] ys = DataGen.Random(rand, n);

            double tenth_percentile = ScottPlot.Statistics.Common.Percentile(ys, 10); // Note that the 10th percentile is different from 10% lows, which is the average of the bottom 10%

            plt.AddSignal(ys, label: "Random Data");
            plt.AddHorizontalLine(tenth_percentile, label: "10th Percentile");

            plt.Legend();
        }
Example #20
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand = new Random(0);

            const int n = 500;

            double[] ys = DataGen.Random(rand, n);

            int k = 200;

            double y = ScottPlot.Statistics.Common.NthOrderStatistic(ys, k);

            plt.AddSignal(ys, label: "Random Data");
            plt.AddHorizontalLine(y, label: $"{k}th Order Statistic");

            plt.Legend();
        }
Example #21
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.FillType           = FillType.FillAboveAndBelow;
            sig.FillColor1         = Color.FromArgb(255, 44, 160, 44); // Green
            sig.GradientFillColor1 = Color.Transparent;
            sig.FillColor2         = Color.FromArgb(255, 214, 39, 40); // Red
            sig.GradientFillColor2 = Color.Transparent;
            sig.BaselineY          = 5;

            plt.AxisAutoX(0);
        }
Example #22
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand       = new(0);
            int    pointCount = 100;

            double[] xs = ScottPlot.DataGen.Consecutive(pointCount);

            // plot a shaded region
            double[] lower = ScottPlot.DataGen.Sin(pointCount, 5, offset: 3);
            double[] upper = ScottPlot.DataGen.Cos(pointCount, 5, offset: -3);
            var      poly  = plt.AddFill(xs, lower, upper);

            poly.FillColor = Color.FromArgb(50, Color.Green);

            // plot a line within that region
            double[] ys  = ScottPlot.DataGen.Random(rand, pointCount);
            var      sig = plt.AddSignal(ys);

            sig.Color = plt.Palette.GetColor(0);

            plt.Margins(0, .5);
        }
Example #23
0
        public void ExecuteRecipe(Plot plt)
        {
            // generate some data
            double[] price        = DataGen.RandomWalk(null, 60 * 8, 10000);
            DateTime start        = new DateTime(2019, 08, 25, 8, 30, 00);
            double   pointsPerDay = 24 * 60;

            // create the plot
            var sig = plt.AddSignal(price, pointsPerDay);

            sig.OffsetX = start.ToOADate();

            // set the localization
            var culture = System.Globalization.CultureInfo.CreateSpecificCulture("hu"); // Hungarian

            plt.SetCulture(culture);

            // further decorate the plot
            plt.XAxis.DateTimeFormat(true);
            plt.YAxis.Label("Price");
            plt.XAxis.Label("Date and Time");
            plt.XAxis2.Label("Hungarian Formatted DateTime Tick Labels");
        }
Example #24
0
 public void ExecuteRecipe(Plot plt)
 {
     double[] values = DataGen.RandomWalk(1_000_000);
     plt.AddSignal(values, sampleRate: 48_000);
     plt.Title("One Million Points");
 }
Example #25
0
 public void ExecuteRecipe(Plot plt)
 {
     plt.AddSignal(ScottPlot.DataGen.Sin(51));
     plt.AddSignal(ScottPlot.DataGen.Cos(51));
Example #26
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(ScottPlot.DataGen.Sin(51));
            plt.AddSignal(ScottPlot.DataGen.Cos(51));

            var ch = plt.AddCrosshair(20, 0);