Exemple #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");
        }
Exemple #2
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");
        }
Exemple #3
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");
        }
Exemple #4
0
        /// <summary>
        /// Draw a square with an X in it
        /// </summary>
        public static void demo_007()
        {
            // create a new ScottPlot figure
            var fig = new ScottPlot.Figure(640, 480);

            // zoom and pan axes before drawing on them
            fig.Zoom(.8, .8);

            // draw a blue X
            fig.PlotLines(-10, 10, -10, 10, 5, Color.Blue);
            fig.PlotLines(-10, 10, 10, -10, 5, Color.Blue);

            // draw a red rectangle
            double[] Xs = { -10, 10, 10, -10, -10 };
            double[] Ys = { -10, -10, 10, 10, -10 };
            fig.PlotLines(Xs, Ys, 5, Color.Red);

            // save the file
            fig.Save("output/demo_007.png");
        }
 public void ResizeAndRedraw()
 {
     if (fig == null)
     {
         return;
     }
     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();
 }
Exemple #6
0
        /// <summary>
        /// Zooming
        /// </summary>
        public static void demo_002()
        {
            var fig = new ScottPlot.Figure(640, 480);

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

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

            fig.AxisAuto(Xs, Ys, null, null); // fit data precisely
            fig.Zoom(2, .5);                  // now zoom in horizontally and out vertically

            fig.PlotLines(Xs, Ys, 1, Color.Red);
            fig.PlotScatter(Xs, Ys, 5, Color.Blue);

            fig.Save("output/demo_002.png");
        }
Exemple #7
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");
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var fig = new ScottPlot.Figure(pictureBox1.Width, pictureBox1.Height);

            fig.styleForm(); // optimizes colors for forms
            fig.labelTitle = "Plotting Point Arrays";
            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);
            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);

            pictureBox1.Image = fig.Render();
        }
Exemple #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");
        }