/// <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"); }
/// <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"); }
/// <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"); }
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(); }
/// <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"); }
/// <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"); }