Esempio n. 1
0
        /// <summary>
        /// Create a plot of data from two arrays of doubles (Xs and Ys)
        /// </summary>
        public static void demo_001()
        {
            // create a new ScottPlot figure
            var fig = new ScottPlot.Figure(640, 480);

            fig.labelTitle = "Super Special Data";
            fig.labelY     = "Random Walk";
            fig.labelX     = "Sample Number";

            // generate data
            int pointCount = 123;

            double[] Xs = fig.gen.Sequence(pointCount);
            double[] Ys = fig.gen.RandomWalk(pointCount);

            // adjust the axis to fit the data (then zoom out slightly)
            fig.AxisAuto(Xs, Ys, .9, .9);

            // make the plot
            fig.BenchmarkThis();
            fig.PlotLines(Xs, Ys, 1, Color.Red);
            fig.PlotScatter(Xs, Ys, 5, Color.Blue);

            // save the file
            fig.Save("output/demo_001.png");
        }
Esempio n. 2
0
        /// <summary>
        /// Overlapping plots of different sizes and colors
        /// </summary>
        public static void demo_004()
        {
            var fig = new ScottPlot.Figure(640, 480);

            fig.labelTitle = "Super Special Data";
            fig.labelY     = "Random Walk";
            fig.labelX     = "Sample Number";

            // use the same Xs every time
            double[] Xs = fig.gen.Sequence(123);

            // manually define axis
            fig.AxisSet(-5, 130, -10, 10);

            fig.BenchmarkThis();
            fig.PlotLines(Xs, fig.gen.RandomWalk(123), 1, Color.Red);
            fig.PlotLines(Xs, fig.gen.RandomWalk(123), 2, Color.Orange);
            fig.PlotLines(Xs, fig.gen.RandomWalk(123), 3, Color.Yellow);
            fig.PlotLines(Xs, fig.gen.RandomWalk(123), 4, Color.Green);
            fig.PlotLines(Xs, fig.gen.RandomWalk(123), 5, Color.Blue);
            fig.PlotLines(Xs, fig.gen.RandomWalk(123), 6, Color.Indigo);
            fig.PlotLines(Xs, fig.gen.RandomWalk(123), 7, Color.Violet);

            fig.Save("output/demo_004.png");
        }
Esempio n. 3
0
        /// <summary>
        /// Scatter plot features
        /// </summary>
        public static void demo_006()
        {
            // create a new ScottPlot figure
            var fig = new ScottPlot.Figure(640, 480);

            fig.labelTitle = "Super Special Data";
            fig.labelY     = "Random Walk";
            fig.labelX     = "Sample Number";

            // generate data
            int pointCount = 40;

            double[] Xs = fig.gen.Sequence(pointCount);

            // manually define axis
            fig.AxisSet(-3, 43, -2, 4);

            // make the plot
            fig.BenchmarkThis();
            fig.PlotScatter(Xs, fig.gen.RandomWalk(pointCount), 2, Color.Black);
            fig.PlotScatter(Xs, fig.gen.RandomWalk(pointCount), 5, Color.Red);
            fig.PlotScatter(Xs, fig.gen.RandomWalk(pointCount), 10, Color.Green);
            fig.PlotScatter(Xs, fig.gen.RandomWalk(pointCount), 20, Color.FromArgb(100, 0, 0, 255));

            // save the file
            fig.Save("output/demo_006.png");
        }
Esempio n. 4
0
        /// <summary>
        /// Demonstrate transparency
        /// </summary>
        public static void demo_005()
        {
            var fig = new ScottPlot.Figure(640, 480);

            fig.labelTitle = "Super Special Data";
            fig.labelY     = "Random Walk";
            fig.labelX     = "Sample Number";

            // use the same Xs every time
            double[] Xs = fig.gen.Sequence(123);

            // manually define axis
            fig.AxisSet(-5, 130, -10, 10);

            // plot lines with different colors
            Color[] colors = new Color[] { Color.FromArgb(100, 255, 0, 0),   // red
                                           Color.FromArgb(100, 0, 150, 0),   // green
                                           Color.FromArgb(100, 0, 0, 255) }; // blue

            fig.BenchmarkThis();
            for (int i = 0; i < colors.Length; i++) // for each color
            {
                for (int j = 0; j < 3; j++)         // draw 3 lines
                {
                    fig.PlotLines(Xs, fig.gen.RandomWalk(123), 5, colors[i]);
                }
            }

            fig.Save("output/demo_005.png");
        }
Esempio n. 5
0
 public void ResizeAndRedraw()
 {
     if (fig == null)
     {
         return;
     }
     fig.BenchmarkThis(showBenchmark);
     fig.Resize(pictureBox1.Width, pictureBox1.Height);
     fig.FrameRedraw();
     fig.PlotLines(Xs, Ys, 1, Color.Red);
     fig.PlotScatter(Xs, Ys, 5, Color.Blue);
     pictureBox1.Image = fig.Render();
 }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            fig = new ScottPlot.Figure(pictureBox1.Width, pictureBox1.Height);
            fig.styleForm();
            fig.labelY = "value";
            fig.labelX = "time (seconds)";


            int pointCount = (int)(nud_sec.Value * sampleRate);

            double[] Ys = fig.gen.RandomWalk(pointCount);
            fig.AxisSet(0, pointCount / sampleRate, null, null);
            fig.AxisAuto(null, Ys, .9, .9);

            fig.BenchmarkThis();
            fig.PlotSignal(Ys, 1.0 / sampleRate);
            pictureBox1.Image = fig.Render();
        }
Esempio n. 7
0
        /// <summary>
        /// Stress-test PlotSignal() with 100 MILLION data points
        /// </summary>
        public static void demo_012()
        {
            // create a new ScottPlot figure
            var fig = new ScottPlot.Figure(640, 480);

            fig.labelTitle = "100 Million Point Stress-Test";
            fig.labelY     = "value";
            fig.labelX     = "time (seconds)";

            // create ONE MILLION points
            double[] Ys = fig.gen.RandomWalk(100_000_000);
            fig.AxisAuto(null, Ys, null, .9);             // resize Y to data
            fig.AxisSet(0, Ys.Length / 20e3, null, null); // resize X manually

            // plot using the FAST METHOD
            fig.BenchmarkThis();
            fig.PlotSignal(Ys, 1.0 / 20e3);

            // save the file
            fig.Save("output/demo_012.png");
        }
Esempio n. 8
0
        /// <summary>
        /// Plot one million data points using PlotLines() - do not do this!!
        /// For high density data (with a large number of data points) evenly spaced, use PlotSignal().
        /// The purpose of this demonstration is to highlight how much faster PlotSignal() is over PlotLines()
        /// </summary>
        public static void demo_010()
        {
            // create a new ScottPlot figure
            var fig = new ScottPlot.Figure(640, 480);

            fig.labelTitle = "1 Million Points with PlotLines()";
            fig.labelY     = "value";
            fig.labelX     = "time (seconds)";

            // create ONE MILLION points
            double[] Xs = fig.gen.Sequence(1_000_000, 1.0 / 20e3); // 20 kHz
            double[] Ys = fig.gen.RandomWalk(1_000_000);
            fig.AxisAuto(Xs, Ys, null, .9);

            // using the SLOW METHOD
            fig.BenchmarkThis();
            fig.PlotLines(Xs, Ys, 1, Color.Red);

            // save the file
            fig.Save("output/demo_010.png");
        }
Esempio n. 9
0
        /// <summary>
        /// Changing colors
        /// </summary>
        public static void demo_003()
        {
            var fig = new ScottPlot.Figure(640, 480);

            fig.labelTitle = "Super Special Data";
            fig.labelY     = "Random Walk";
            fig.labelX     = "Sample Number";

            // go to town changing colors
            fig.colorAxis      = Color.Yellow;
            fig.colorFigBg     = Color.FromArgb(255, 30, 30, 30);
            fig.colorGridLines = Color.FromArgb(255, 55, 55, 55);
            fig.colorGraphBg   = Color.FromArgb(255, 40, 40, 40);

            double[] Xs = fig.gen.Sequence(123);
            double[] Ys = fig.gen.RandomWalk(123);
            fig.AxisAuto(Xs, Ys, .9, .9);

            fig.BenchmarkThis();
            fig.PlotLines(Xs, Ys, 1, Color.Gray);
            fig.PlotScatter(Xs, Ys, 5, Color.White);

            fig.Save("output/demo_003.png");
        }