Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
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");
        }
Ejemplo n.º 3
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");
        }
Ejemplo n.º 4
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");
        }
Ejemplo n.º 5
0
        public double[] Xs, Ys; // this is where data is stored for interactive plotting

        public ucInteractive()
        {
            InitializeComponent();
            this.pictureBox1.MouseWheel += pictureBox1_MouseWheel;
            SP = new ScottPlot.Figure();
            GraphResize();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            // create data with our own routines
            int nPoints = 250;

            double[] Xs  = ScottPlot.Generate.Sequence(nPoints);
            double[] Ys1 = ScottPlot.Generate.Sine(nPoints, 4);
            double[] Ys2 = ScottPlot.Generate.Sine(nPoints, 4.5, .8);

            // create a ScottPlot figure
            ScottPlot.Figure SP = new ScottPlot.Figure();

            // manually set axis before drawing anything (very important)
            SP.AxisAuto(Xs, Ys1, 0, 0.1);

            // prepare by first drawing a grid
            SP.Grid();

            // add the line to the bitmap
            SP.PlotLine(Xs, Ys1, "g", 5, true);
            SP.PlotLine(Xs, Ys2, "b", 2);

            // render the bitmap and save it as a file
            SP.SaveFig("demo.jpg");
        }
Ejemplo n.º 7
0
        public ScottPlotUC()
        {
            InitializeComponent();
            // instantiate the SP class we will use forever
            SP = new ScottPlot.Figure();

            // place the debug text box in a good location and set its startup message
            richTextBox1.Location = new System.Drawing.Point(40, 10);
            richTextBox1.Text     = $"ScottPlot v{VERSION}";
        }
Ejemplo n.º 8
0
        public Form1()
        {
            InitializeComponent();

            // create the figure and apply styling
            fig = new ScottPlot.Figure(pictureBox1.Width, pictureBox1.Height);
            fig.styleForm();
            fig.labelTitle = "Awesome Data";
            fig.labelY     = "Random Walk";
            fig.labelX     = "Sample Number";

            // synthesize data
            int pointCount = 123;

            Xs = fig.gen.Sequence(pointCount);
            Ys = fig.gen.RandomWalk(pointCount);
            fig.AxisAuto(Xs, Ys, .9, .9);
        }
Ejemplo n.º 9
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();
        }
Ejemplo n.º 10
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");
        }
Ejemplo n.º 11
0
        /// <summary>
        /// THIS CODE BLOCK IS LEFT HERE FOR PARSING PURPOSES
        /// </summary>

        /*
         *
         *
         *  THESE EXAMPLES ARE VERY COMPLEX AND/OR LOW LEVEL
         *
         *
         */

        /// <summary>
        /// Draw by directly interacting with the graphics object and position/pixel conversion
        /// </summary>
        public static void demo_101()
        {
            // create a new ScottPlot figure
            var fig = new ScottPlot.Figure(640, 480);

            fig.labelTitle = "Direct Graphics Drawing";
            fig.labelY     = "Pure Awesomeness";
            fig.labelX     = "Relative Time (years)";
            fig.AxisSet(-15, 35, -10, 110); // x1, x2, y1, y2

            // draw a line directly on the Graphics object in AXIS units
            Point pt1 = new Point(fig.xAxis.GetPixel(0), fig.yAxis.GetPixel(13));
            Point pt2 = new Point(fig.xAxis.GetPixel(32), fig.yAxis.GetPixel(98));

            fig.gfxGraph.DrawLine(new Pen(new SolidBrush(Color.Blue), 5), pt1, pt2);

            // save the file
            fig.Save("output/demo_101.png");
        }
Ejemplo n.º 12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // init the figure only after the form loaded (so we know final pictureBox1 dimensions)
            fig = new ScottPlot.Figure(pictureBox1.Width, pictureBox1.Height);

            // create the figure and apply styling
            fig.styleForm();
            fig.labelTitle = "Awesome Data";
            fig.labelY     = "Random Walk";
            fig.labelX     = "Sample Number";

            // synthesize data
            int pointCount = 123;

            Xs = fig.gen.Sequence(pointCount);
            Ys = fig.gen.RandomWalk(pointCount);
            fig.AxisAuto(Xs, Ys, .9, .9);

            ResizeAndRedraw();
        }
Ejemplo n.º 13
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");
        }
Ejemplo n.º 14
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");
        }
Ejemplo n.º 15
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");
        }
Ejemplo n.º 16
0
        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();
        }
Ejemplo n.º 17
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");
        }