예제 #1
0
        // give the ScottPlotUC data to store in memory
        public void SetData(double[] Xs, double[] Ys)
        {
            this.Xs = Xs;
            this.Ys = Ys;
            SP.AxisAuto(Xs, Ys);

            UpdateGraph();
            MessageUpdate();
        }
예제 #2
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");
        }
예제 #3
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");
        }
예제 #4
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();
        }
예제 #5
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);
        }
예제 #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");
        }
예제 #7
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();
        }
예제 #8
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");
        }
예제 #9
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");
        }
예제 #10
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();
        }
예제 #11
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");
        }