Exemple #1
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] xs = DataGen.Range(0, 5, .1);
            plt.AddScatter(xs, DataGen.Sin(xs));
            plt.AddScatter(xs, DataGen.Cos(xs));

            // default placement is upper left
            plt.AddAnnotation("Top Left", 10, 10);

            // negative coordinates can be used to place text along different edges
            plt.AddAnnotation("Lower Left", 10, -10);
            plt.AddAnnotation("Top Right", -10, 10);
            plt.AddAnnotation("Lower Right", -10, -10);

            // Additional customizations are available
            var fancy = plt.AddAnnotation("Fancy Annotation", 10, 40);

            fancy.FontSize        = 24;
            fancy.FontName        = "Impact";
            fancy.FontColor       = Color.Red;
            fancy.Shadow          = false;
            fancy.BackgroundColor = Color.FromArgb(25, Color.Blue);
            fancy.BorderWidth     = 2;
            fancy.BorderColor     = Color.Magenta;
        }
Exemple #2
0
 public DisplayScaling()
 {
     InitializeComponent();
     WpfPlot1.Plot.AddSignal(DataGen.Sin(51));
     WpfPlot1.Plot.AddSignal(DataGen.Cos(51));
     CheckBox_Checked(null, null);
 }
        public ToggleVisibility()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            int      pointCount = 51;
            double[] dataXs     = DataGen.Consecutive(pointCount);
            double[] dataSin    = DataGen.Sin(pointCount);
            double[] dataCos    = DataGen.Cos(pointCount);

            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            sinPlot = avaPlot1.Plot.AddScatter(dataXs, dataSin);
            cosPlot = avaPlot1.Plot.AddScatter(dataXs, dataCos);
            vline1  = avaPlot1.Plot.AddVerticalLine(0);
            vline2  = avaPlot1.Plot.AddVerticalLine(50);

            avaPlot1.Refresh();

            this.Find <CheckBox>("sineCheckbox").Checked   += SinShow;
            this.Find <CheckBox>("sineCheckbox").Unchecked += SinHide;

            this.Find <CheckBox>("cosineCheckbox").Checked   += CosShow;
            this.Find <CheckBox>("cosineCheckbox").Unchecked += CosHide;

            this.Find <CheckBox>("linesCheckbox").Checked   += LinesShow;
            this.Find <CheckBox>("linesCheckbox").Unchecked += LinesHide;
        }
Exemple #4
0
        public RightClickMenu()
        {
            InitializeComponent();

            wpfPlot1.plt.PlotSignal(DataGen.Sin(51));
            wpfPlot1.plt.PlotSignal(DataGen.Cos(51));
            wpfPlot1.Render();

            MenuItem addSinMenuItem = new MenuItem()
            {
                Header = "Add Sine Wave"
            };

            addSinMenuItem.Click += AddSine;
            MenuItem clearPlotMenuItem = new MenuItem()
            {
                Header = "Clear Plot"
            };

            clearPlotMenuItem.Click += ClearPlot;

            ContextMenu rightClickMenu = new ContextMenu();

            rightClickMenu.Items.Add(addSinMenuItem);
            rightClickMenu.Items.Add(clearPlotMenuItem);

            wpfPlot1.ContextMenu = rightClickMenu;
        }
        public TransparentBackground()
        {
            InitializeComponent();

            // move content onto a backgroundimagecontrol for image support
            this.Content = new BackgroundImageControl()
            {
                Content = this.Content
            };

            this.button1.Click += this.button1_Click;
            this.button2.Click += this.button2_Click;
            this.button3.Click += this.button3_Click;
            this.button4.Click += this.button4_Click;
            this.button5.Click += this.button5_Click;
            this.button6.Click += this.button6_Click;

            int pointCount = 51;

            double[] x   = DataGen.Consecutive(pointCount);
            double[] sin = DataGen.Sin(pointCount);
            double[] cos = DataGen.Cos(pointCount);

            formsPlot1.Plot.AddScatter(x, sin);
            formsPlot1.Plot.AddScatter(x, cos);

            formsPlot1.Plot.Style(figureBackground: System.Drawing.Color.Transparent, dataBackground: System.Drawing.Color.Transparent);
            formsPlot1.BackgroundColor = Colors.Transparent;
            button6_Click(null, null);
        }
Exemple #6
0
        public void ExecuteRecipe(Plot plt)
        {
            var sig1 = plt.AddSignal(DataGen.Sin(51));

            sig1.Label      = "Sin";
            sig1.MarkerSize = 7;
            sig1.LineWidth  = 2;

            var sig2 = plt.AddSignal(DataGen.Cos(51));

            sig2.Label      = "Cos";
            sig2.MarkerSize = 7;
            sig2.LineWidth  = 2;

            var legend = plt.Legend();

            legend.FontSize = 24;

            plt.Title("Plot with Large Features");
            plt.YLabel("Vertical Axis");
            plt.XLabel("Horizontal Axis");

            plt.YAxis.LabelStyle(fontSize: 24);
            plt.XAxis.LabelStyle(fontSize: 24);
            plt.XAxis2.LabelStyle(fontSize: 36);

            plt.YAxis.TickLabelStyle(fontSize: 18);
            plt.XAxis.TickLabelStyle(fontSize: 18);

            plt.YAxis.MajorGrid(lineWidth: 2);
            plt.XAxis.MajorGrid(lineWidth: 2);
        }
Exemple #7
0
        public void SaveScottPlotTestFromWebsite()
        {
            string saveFileLocation = "C:\\Temp\\Quickstart_Quickstart_Scatter.png";
            var    plt = new ScottPlot.Plot(600, 400);

            int pointCount = 51;

            double[] xs  = DataGen.Consecutive(pointCount);
            double[] sin = DataGen.Sin(pointCount);
            double[] cos = DataGen.Cos(pointCount);

            plt.AddScatter(sin, cos, label: "sin");
            plt.AddScatter(xs, cos, label: "cos");
            plt.Legend();

            plt.Title("Scatter Plot Quickstart");
            plt.YLabel("Vertical Units");
            plt.XLabel("Horizontal Units");

            plt.SaveFig(saveFileLocation);

            Assert.IsTrue(System.IO.File.Exists(saveFileLocation));

            System.IO.File.Delete(saveFileLocation);
        }
Exemple #8
0
            public void Render(Plot plt)
            {
                int pointCount = 51;

                double[] x   = DataGen.Consecutive(pointCount);
                double[] sin = DataGen.Sin(pointCount);
                double[] cos = DataGen.Cos(pointCount);

                plt.PlotScatter(x, sin);
                plt.PlotScatter(x, cos);

                plt.PlotVSpan(y1: .15, y2: .85, label: "Adjustable VSpan",
                              draggable: true, dragLimitLower: -1, dragLimitUpper: 1);

                plt.PlotHSpan(x1: 10, x2: 25, label: "Adjustable HSpan",
                              draggable: true, dragLimitLower: 0, dragLimitUpper: 50);

                plt.PlotVSpan(y1: -.25, y2: -.05, label: "Fixed Size VSpan",
                              draggable: true, dragLimitLower: -1, dragLimitUpper: 1,
                              dragFixedSize: true);

                plt.PlotHSpan(x1: 5, x2: 7, label: "Fixed Size HSpan",
                              draggable: true, dragLimitLower: 0, dragLimitUpper: 50,
                              dragFixedSize: true);

                plt.Grid(lineStyle: LineStyle.Dot);
                plt.Legend();
            }
Exemple #9
0
        public void ExecuteRecipe(Plot plt)
        {
            // display some sample data
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            // display an image with 3 different alignments
            Bitmap monaLisa = DataGen.SampleImage();
            var    ip1      = new ScottPlot.Plottable.Image()
            {
                Bitmap = monaLisa, X = 10
            };
            var ip2 = new ScottPlot.Plottable.Image()
            {
                Bitmap = monaLisa, X = 25, Alignment = Alignment.MiddleCenter
            };
            var ip3 = new ScottPlot.Plottable.Image()
            {
                Bitmap = monaLisa, X = 40, Alignment = Alignment.LowerRight
            };

            plt.Add(ip1);
            plt.Add(ip2);
            plt.Add(ip3);

            plt.AddPoint(ip1.X, ip1.Y, Color.Magenta, size: 20);
            plt.AddPoint(ip2.X, ip2.Y, Color.Magenta, size: 20);
            plt.AddPoint(ip3.X, ip3.Y, Color.Magenta, size: 20);
        }
Exemple #10
0
        public void Test_SaveFig_OutputScaling()
        {
            var plt = new ScottPlot.Plot();

            plt.AddSignal(DataGen.Sin(51), label: "sin");
            plt.AddSignal(DataGen.Cos(51), label: "cos");
            plt.Title("Scaled Figure Demo");
            plt.XLabel("Horizontal Axis");
            plt.YLabel("Vertical Axis");
            plt.Legend();

            System.Drawing.Bitmap bmpA = plt.Render(400, 300);
            Assert.AreEqual(400, bmpA.Width);
            Assert.AreEqual(300, bmpA.Height);

            System.Drawing.Bitmap bmpB = plt.Render(400, 300, scale: .5);
            Assert.AreEqual(200, bmpB.Width);
            Assert.AreEqual(150, bmpB.Height);

            System.Drawing.Bitmap bmpC = plt.Render(400, 300, scale: 2);
            Assert.AreEqual(800, bmpC.Width);
            Assert.AreEqual(600, bmpC.Height);

            System.Drawing.Bitmap bmpD = plt.Render(300, 400, scale: 2);
            Assert.AreEqual(600, bmpD.Width);
            Assert.AreEqual(800, bmpD.Height);

            System.Drawing.Bitmap legendNormal = plt.RenderLegend();
            System.Drawing.Bitmap legendBig    = plt.RenderLegend(scale: 2);
            Assert.Greater(legendBig.Width, legendNormal.Width);
            Assert.Greater(legendBig.Height, legendNormal.Height);
        }
Exemple #11
0
            public void Render(Plot plt)
            {
                int pointCount = 51;

                double[] x   = DataGen.Consecutive(pointCount);
                double[] sin = DataGen.Sin(pointCount);
                double[] cos = DataGen.Cos(pointCount);

                plt.PlotScatter(x, sin);
                plt.PlotScatter(x, cos);

                plt.PlotPoint(25, 0.8, color: Color.Green);
                plt.PlotText(" important point", 25, 0.8, color: Color.Green);

                plt.PlotPoint(30, 0.3, color: Color.Black, markerSize: 15);
                plt.PlotText(" default alignment", 30, 0.3, fontSize: 16, bold: true, color: Color.Magenta);

                plt.PlotPoint(30, 0, color: Color.Black, markerSize: 15);
                plt.PlotText("middle center", 30, 0, fontSize: 16, bold: true, color: Color.Magenta, alignment: Alignment.MiddleCenter);

                plt.PlotPoint(30, -0.3, color: Color.Black, markerSize: 15);
                plt.PlotText("upper left", 30, -0.3, fontSize: 16, bold: true, color: Color.Magenta, alignment: Alignment.UpperLeft);

                plt.PlotPoint(5, -.5, color: Color.Blue, markerSize: 15);
                plt.PlotText(" Rotated Text", 5, -.5, fontSize: 16, color: Color.Blue, bold: true, rotation: -30);

                plt.PlotText("Framed Text", 15, -.6, fontSize: 16, color: Color.White, bold: true, frame: true, frameColor: Color.DarkRed);
            }
Exemple #12
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot sample data
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            // dragging can be enabled and optionally limited to a range
            var vSpan = plt.AddVerticalSpan(.15, .85);

            vSpan.DragEnabled     = true;
            vSpan.DragLimitMin    = -1;
            vSpan.DragLimitMax    = 1;
            vSpan.BorderColor     = Color.Red;
            vSpan.BorderLineStyle = LineStyle.Dot;
            vSpan.BorderLineWidth = 2;
            vSpan.HatchColor      = Color.FromArgb(100, Color.Blue);
            vSpan.HatchStyle      = Drawing.HatchStyle.SmallCheckerBoard;
            vSpan.Label           = "Customized vSpan";


            // spans can be configured to allow dragging but disallow resizing
            var hSpan = plt.AddHorizontalSpan(10, 25);

            hSpan.DragEnabled   = true;
            hSpan.DragFixedSize = true;
            hSpan.Label         = "Standard hSpan";
            plt.Legend(true);
        }
Exemple #13
0
        public void ExecuteRecipe(Plot plt)
        {
            double CustomSnapFunction(double value)
            {
                // multiple of 3 between 0 and 50
                if (value < 0)
                {
                    return(0);
                }
                else if (value > 50)
                {
                    return(50);
                }
                else
                {
                    return((int)Math.Round(value / 3) * 3);
                }
            }

            // different snap sytems can be created and customized
            var SnapDisabled = new ScottPlot.SnapLogic.NoSnap1D();
            var SnapCustom   = new SnapLogic.Custom1D(CustomSnapFunction);

            plt.AddSignal(DataGen.Sin(51, mult: 5));
            plt.AddSignal(DataGen.Cos(51, mult: 5));

            var vLine = plt.AddVerticalLine(30);

            vLine.DragEnabled = true;
            vLine.DragSnap    = new ScottPlot.SnapLogic.Independent2D(SnapCustom, SnapDisabled);
        }
Exemple #14
0
 public WpfConfig()
 {
     InitializeComponent();
     wpfPlot1.Plot.AddSignal(DataGen.Sin(51));
     wpfPlot1.Plot.AddSignal(DataGen.Cos(51));
     wpfPlot1.Render();
 }
Exemple #15
0
        public void Test_ScaleBar_Default()
        {
            var plt = new ScottPlot.Plot();

            plt.AntiAlias(false, false, false);

            // start plot without scalebar
            plt.PlotSignal(DataGen.Sin(51));
            plt.PlotSignal(DataGen.Cos(51));
            var bmp1 = new System.Drawing.Bitmap(plt.GetBitmap(renderFirst: true));

            // add a scalebar
            var sb = new PlottableScaleBar()
            {
                Width           = 5,
                Height          = .25,
                VerticalLabel   = "5 V",
                HorizontalLabel = "250 ms"
            };

            plt.Add(sb);
            var bmp2 = new System.Drawing.Bitmap(plt.GetBitmap(renderFirst: true));

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            var before = new MeanPixel(bmp1);
            var after  = new MeanPixel(bmp2);

            Console.WriteLine($"Before: {before}");
            Console.WriteLine($"After: {after}");

            Assert.That(after.IsDarkerThan(before));
        }
Exemple #16
0
        public void Test_ScaleBar_FontColor()
        {
            var plt = new ScottPlot.Plot();

            plt.AntiAlias(false, false, false);

            // create plot with generic scalebar settings
            plt.PlotSignal(DataGen.Sin(51));
            plt.PlotSignal(DataGen.Cos(51));
            var sb = new PlottableScaleBar()
            {
                Width           = 5,
                Height          = .25,
                VerticalLabel   = "5 V",
                HorizontalLabel = "250 ms"
            };

            plt.Add(sb);
            var bmp1 = new System.Drawing.Bitmap(plt.GetBitmap(renderFirst: true));

            // customize the scalebar
            sb.FontColor = System.Drawing.Color.Blue;
            var bmp2 = new System.Drawing.Bitmap(plt.GetBitmap(renderFirst: true));

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            var before = new MeanPixel(bmp1);
            var after  = new MeanPixel(bmp2);

            Console.WriteLine($"Before: {before}");
            Console.WriteLine($"After: {after}");

            Assert.That(after.IsMoreBlueThan(before));
        }
Exemple #17
0
        public void Test_ScaleBar_LineWidth()
        {
            var plt = new ScottPlot.Plot();

            // create plot with generic scalebar settings
            plt.PlotSignal(DataGen.Sin(51));
            plt.PlotSignal(DataGen.Cos(51));
            var sb = new ScottPlot.Plottable.ScaleBar()
            {
                Width           = 5,
                Height          = .25,
                VerticalLabel   = "5 V",
                HorizontalLabel = "250 ms"
            };

            plt.Add(sb);
            var bmp1 = TestTools.GetLowQualityBitmap(plt);

            // customize the scalebar
            sb.LineWidth += 1;
            var bmp2 = TestTools.GetLowQualityBitmap(plt);

            // measure what changed
            //TestTools.SaveFig(bmp1, "1");
            //TestTools.SaveFig(bmp2, "2");
            var before = new MeanPixel(bmp1);
            var after  = new MeanPixel(bmp2);

            Console.WriteLine($"Before: {before}");
            Console.WriteLine($"After: {after}");

            Assert.That(after.IsDarkerThan(before));
        }
Exemple #18
0
 public void ExecuteRecipe(Plot plt)
 {
     plt.AddSignal(DataGen.Sin(51));
     plt.AddSignal(DataGen.Cos(51));
     plt.AxisAuto(0, 0); // zero margin between data and edge of plot
     plt.Frameless();
 }
Exemple #19
0
        public void ExecuteRecipe(Plot plt)
        {
            double[] ys1   = DataGen.Sin(30);
            var      cmap1 = ScottPlot.Drawing.Colormap.Viridis;

            double[] ys2   = DataGen.Cos(30);
            var      cmap2 = ScottPlot.Drawing.Colormap.Turbo;

            for (int i = 0; i < ys1.Length; i++)
            {
                double frac = i / (ys1.Length - 1f);

                var circle = plt.AddMarker(i, ys1[i]);
                circle.MarkerShape     = MarkerShape.openCircle;
                circle.MarkerSize      = i + 5;
                circle.MarkerLineWidth = 1 + i / 2;
                circle.MarkerColor     = cmap1.GetColor(1 - frac, .8);

                var triangle = plt.AddMarker(i, ys2[i]);
                triangle.MarkerShape     = MarkerShape.openTriangleUp;
                triangle.MarkerSize      = i + 5;
                triangle.MarkerLineWidth = 1 + i / 4;
                triangle.MarkerColor     = cmap2.GetColor(frac, .8);
            }

            plt.Margins(.2, .2);
        }
Exemple #20
0
            public void Render(Plot plt)
            {
                int pointCount = 51;

                double[] x   = DataGen.Consecutive(pointCount);
                double[] sin = DataGen.Sin(pointCount);
                double[] cos = DataGen.Cos(pointCount);

                plt.PlotScatter(x, sin);
                plt.PlotScatter(x, cos);

                Bitmap image = DataGen.SampleImage();

                plt.PlotBitmap(image, 5, 0.8);
                plt.PlotPoint(5, 0.8, color: Color.Green);

                plt.PlotBitmap(image, 20, 0.3);
                plt.PlotPoint(20, 0.3, color: Color.Black, markerSize: 15);

                plt.PlotBitmap(image, 30, 0, alignment: ImageAlignment.middleCenter);
                plt.PlotPoint(30, 0, color: Color.Black, markerSize: 15);

                plt.PlotBitmap(image, 30, -0.3, alignment: ImageAlignment.upperLeft);
                plt.PlotPoint(30, -0.3, color: Color.Black, markerSize: 15);

                plt.PlotBitmap(image, 5, -.5, rotation: -30);
                plt.PlotPoint(5, -.5, color: Color.Blue, markerSize: 15);

                plt.PlotBitmap(image, 15, -.6, frameSize: 3, frameColor: Color.Magenta);
            }
        public FormsPlotExperimental()
        {
            InitializeComponent();
            IsDesignerMode = Process.GetCurrentProcess().ProcessName == "devenv";
            Settings       = MainPlot.GetSettings(false);

            if (IsDesignerMode)
            {
                MainPlot.Title($"ScottPlot {Tools.GetVersionString()}");
                MainPlot.PlotSignal(DataGen.Sin(51));
                MainPlot.PlotSignal(DataGen.Cos(51));
                MainPlot.Legend();
                MainPlot.XLabel("Horizontal Axis Label");
                MainPlot.YLabel("Vertical Axis Label");
            }

            // set up a timer to check when renders are needed
            RenderTimer.Interval = 1;
            RenderTimer.Tick    += new EventHandler(RenderTimer_Tick);
            RenderTimer.Start();

            // connect mouse events to plot interactions
            pictureBox1.SizeChanged += PictureBox1_SizeChanged;
            pictureBox1.DoubleClick += PictureBox1_DoubleClick;
            pictureBox1.MouseDown   += PictureBox1_MouseDown;
            pictureBox1.MouseMove   += PictureBox1_MouseMove;
            pictureBox1.MouseUp     += PictureBox1_MouseUp;
        }
Exemple #22
0
        public RightClickMenu()
        {
            this.InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
            avaPlot1 = this.Find <AvaPlot>("avaPlot1");

            avaPlot1.plt.PlotSignal(DataGen.Sin(51));
            avaPlot1.plt.PlotSignal(DataGen.Cos(51));
            avaPlot1.Render();

            List <ContextMenuItem> contextMenu = new List <ContextMenuItem>();
            contextMenu.Add(new ContextMenuItem()
            {
                itemName = "Add Sine Wave",
                onClick  = AddSine
            });

            contextMenu.Add(new ContextMenuItem()
            {
                itemName = "Clear Plot",
                onClick  = ClearPlot
            });

            avaPlot1.SetContextMenu(contextMenu);
        }
Exemple #23
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            plt.XAxis.RulerMode(true);
            plt.YAxis.RulerMode(true);
        }
Exemple #24
0
 public void ExecuteRecipe(Plot plt)
 {
     plt.AddSignal(DataGen.Sin(51));
     plt.AddSignal(DataGen.Cos(51));
     plt.XLabel("Horizontal Axis");
     plt.YLabel("Vertical Axis");
     plt.Title("Plot Title");
 }
Exemple #25
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            plt.YAxis.MinimumTickSpacing(1);
            plt.XAxis.MinimumTickSpacing(25);
        }
Exemple #26
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));
            plt.Style(figureBackground: Color.SkyBlue);

            plt.Frameless();
        }
Exemple #27
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            Bitmap monaLisa = DataGen.SampleImage();

            plt.AddImage(monaLisa, 10, .5);
        }
Exemple #28
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot sample data
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            // hide grids
            plt.Grid(false);
        }
Exemple #29
0
 public AxisLimits()
 {
     InitializeComponent();
     wpfPlot1.plt.PlotSignal(DataGen.Sin(51));
     wpfPlot1.plt.PlotSignal(DataGen.Cos(51));
     wpfPlot1.plt.AxisAuto();
     wpfPlot1.plt.SetViewLimits(0, 50, -1, 1);
     wpfPlot1.Render();
 }
Exemple #30
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot sample data
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            // each axis has its own visibility controls
            plt.XAxis.Grid(false);
        }