Beispiel #1
0
        private MeanPixel Mean(ScottPlot.Renderable.Axis axis, PlotDimensions dims = null, bool save = true)
        {
            var verticalDims = new PlotDimensions(
                figureSize: new SizeF(100, 500),
                dataSize: new SizeF(20, 400),
                dataOffset: new PointF(75, 50),
                axisLimits: (-1, 1, -100, 100));

            var horizontalDims = new PlotDimensions(
                figureSize: new SizeF(500, 100),
                dataSize: new SizeF(400, 20),
                dataOffset: new PointF(50, 25),
                axisLimits: (-100, 100, -1, 1));

            var altDims = axis.IsVertical ? verticalDims : horizontalDims;

            dims = dims ?? altDims;

            using (var bmp = new System.Drawing.Bitmap((int)dims.Width, (int)dims.Height))
                using (var gfx = GDI.Graphics(bmp, lowQuality: true))
                    using (var brush = GDI.Brush(Color.FromArgb(25, Color.Black)))
                    {
                        gfx.Clear(Color.White);
                        gfx.FillRectangle(brush, dims.DataOffsetX, dims.DataOffsetY, dims.DataWidth, dims.DataHeight);
                        axis.RecalculateTickPositions(dims);
                        axis.Render(dims, bmp);
                        if (save)
                        {
                            TestTools.SaveFig(bmp);
                        }
                        return(new MeanPixel(bmp));
                    }
        }
Beispiel #2
0
        public MultiAxisLock()
        {
            InitializeComponent();

            Random rand = new Random();

            // Add 3 signals each with a different vertical axis index.
            // Each signal defaults to X axis index 0 so their horizontal axis will be shared.

            var plt1 = formsPlot1.Plot.AddSignal(DataGen.RandomWalk(rand, 100, mult: 1));

            plt1.YAxisIndex = 0;
            plt1.LineWidth  = 3;
            plt1.Color      = Color.Magenta;

            var plt2 = formsPlot1.Plot.AddSignal(DataGen.RandomWalk(rand, 100, mult: 10));

            plt2.YAxisIndex = 1;
            plt2.LineWidth  = 3;
            plt2.Color      = Color.Green;

            var plt3 = formsPlot1.Plot.AddSignal(DataGen.RandomWalk(rand, 100, mult: 100));

            plt3.YAxisIndex = 2;
            plt3.LineWidth  = 3;
            plt3.Color      = Color.Navy;

            // The horizontal axis is shared by these signal plots (XAxisIndex defaults to 0)
            formsPlot1.Plot.XAxis.Label("Horizontal Axis");

            // Customize the primary (left) and secondary (right) axes
            formsPlot1.Plot.YAxis.Color(Color.Magenta);
            formsPlot1.Plot.YAxis.Label("Primary Axis");
            formsPlot1.Plot.YAxis2.Color(Color.Green);
            formsPlot1.Plot.YAxis2.Label("Secondary Axis");

            // the secondary (right) axis ticks are hidden by default so enable them
            formsPlot1.Plot.YAxis2.Ticks(true);

            // Create an additional vertical axis and customize it
            YAxis3 = formsPlot1.Plot.AddAxis(Renderable.Edge.Left, 2);
            YAxis3.Color(Color.Navy);
            YAxis3.Label("Tertiary Axis");

            // adjust axis limits to fit the data once before locking them based on initial check state
            formsPlot1.Plot.AxisAuto();
            SetLocks();

            this.cbPrimary.CheckedChanged   += this.cbPrimary_CheckedChanged;
            this.cbSecondary.CheckedChanged += this.cbSecondary_CheckedChanged;
            this.cbTertiary.CheckedChanged  += this.cbTertiary_CheckedChanged;
        }
Beispiel #3
0
        public MultiAxisLock()
        {
            InitializeComponent();
            PrimaryCheckbox.DataContext   = this;
            SecondaryCheckbox.DataContext = this;
            TertiaryCheckbox.DataContext  = this;

            Random rand = new Random();

            // Add 3 signals each with a different vertical axis index.
            // Each signal defaults to X axis index 0 so their horizontal axis will be shared.

            var plt1 = WpfPlot1.Plot.AddSignal(DataGen.RandomWalk(rand, 100, mult: 1));

            plt1.YAxisIndex = 0;
            plt1.LineWidth  = 3;
            plt1.Color      = System.Drawing.Color.Magenta;

            var plt2 = WpfPlot1.Plot.AddSignal(DataGen.RandomWalk(rand, 100, mult: 10));

            plt2.YAxisIndex = 1;
            plt2.LineWidth  = 3;
            plt2.Color      = System.Drawing.Color.Green;

            var plt3 = WpfPlot1.Plot.AddSignal(DataGen.RandomWalk(rand, 100, mult: 100));

            plt3.YAxisIndex = 2;
            plt3.LineWidth  = 3;
            plt3.Color      = System.Drawing.Color.Navy;

            // The horizontal axis is shared by these signal plots (XAxisIndex defaults to 0)
            WpfPlot1.Plot.XAxis.Label("Horizontal Axis");

            // Customize the primary (left) and secondary (right) axes
            WpfPlot1.Plot.YAxis.Color(System.Drawing.Color.Magenta);
            WpfPlot1.Plot.YAxis.Label("Primary Axis");
            WpfPlot1.Plot.YAxis2.Color(System.Drawing.Color.Green);
            WpfPlot1.Plot.YAxis2.Label("Secondary Axis");

            // the secondary (right) axis ticks are hidden by default so enable them
            WpfPlot1.Plot.YAxis2.Ticks(true);

            // Create an additional vertical axis and customize it
            YAxis3 = WpfPlot1.Plot.AddAxis(Renderable.Edge.Left, 2);
            YAxis3.Color(System.Drawing.Color.Navy);
            YAxis3.Label("Tertiary Axis");

            // adjust axis limits to fit the data once before locking them
            WpfPlot1.Plot.AxisAuto();
            WpfPlot1.Refresh();
            CheckChanged(null, null);
        }
Beispiel #4
0
        public void Test_AxisLine_Enable()
        {
            var axis = new ScottPlot.Renderable.Axis();

            axis.Title.Label = "Sample Left Axis";
            axis.Edge        = ScottPlot.Renderable.Edge.Left;
            axis.Ticks.TickCollection.verticalAxis = true;
            var before = Mean(axis);

            axis.Line.IsVisible = false;
            var after = Mean(axis);

            Assert.That(after.IsLighterThan(before));
        }
Beispiel #5
0
        public void Test_AxisTickLabel_Rotation()
        {
            var axis = new ScottPlot.Renderable.Axis();

            axis.Title.Label = "Sample Bottom Axis";
            axis.Edge        = ScottPlot.Renderable.Edge.Bottom;
            axis.Ticks.TickCollection.verticalAxis = false;
            var before = Mean(axis);

            axis.Ticks.Rotation = 45;
            var after = Mean(axis);

            Assert.That(after.IsDifferentThan(before));
        }
Beispiel #6
0
        public MultiAxisLock()
        {
            InitializeComponent();

            Random rand = new Random();

            double[] data1 = DataGen.RandomWalk(rand, 100, mult: 1);
            double[] data2 = DataGen.RandomWalk(rand, 100, mult: 10);
            double[] data3 = DataGen.RandomWalk(rand, 100, mult: 100);
            double   avg1  = data1.Sum() / data1.Length;
            double   avg2  = data2.Sum() / data2.Length;
            double   avg3  = data3.Sum() / data3.Length;

            // Add signals specifying the vertical axis index for each
            var plt1 = formsPlot1.Plot.AddSignal(data1);

            plt1.YAxisIndex = 0;
            plt1.LineWidth  = 3;
            plt1.Color      = Color.Magenta;

            var plt2 = formsPlot1.Plot.AddSignal(data2);

            plt2.YAxisIndex = 1;
            plt2.LineWidth  = 3;
            plt2.Color      = Color.Green;

            var plt3 = formsPlot1.Plot.AddSignal(data3);

            plt3.YAxisIndex = 2;
            plt3.LineWidth  = 3;
            plt3.Color      = Color.Navy;

            // Add draggable horizontal lines specifying the vertical axis index for each
            var hline1 = formsPlot1.Plot.AddHorizontalLine(avg1);

            hline1.DragEnabled = true;
            hline1.Color       = plt1.Color;
            hline1.LineStyle   = LineStyle.Dash;
            hline1.YAxisIndex  = 0;

            var hline2 = formsPlot1.Plot.AddHorizontalLine(avg2);

            hline2.DragEnabled = true;
            hline2.Color       = plt2.Color;
            hline2.LineStyle   = LineStyle.Dash;
            hline2.YAxisIndex  = 1;

            var hline3 = formsPlot1.Plot.AddHorizontalLine(avg3);

            hline3.DragEnabled = true;
            hline3.Color       = plt3.Color;
            hline3.LineStyle   = LineStyle.Dash;
            hline3.YAxisIndex  = 2;

            // The horizontal axis is shared by these signal plots (XAxisIndex defaults to 0)
            formsPlot1.Plot.XAxis.Label("Horizontal Axis");

            // Customize the primary (left) and secondary (right) axes
            formsPlot1.Plot.YAxis.Color(Color.Magenta);
            formsPlot1.Plot.YAxis.Label("Primary Axis");
            formsPlot1.Plot.YAxis2.Color(Color.Green);
            formsPlot1.Plot.YAxis2.Label("Secondary Axis");

            // the secondary (right) axis ticks are hidden by default so enable them
            formsPlot1.Plot.YAxis2.Ticks(true);

            // Create an additional vertical axis and customize it
            YAxis3 = formsPlot1.Plot.AddAxis(Renderable.Edge.Left, 2);
            YAxis3.Color(Color.Navy);
            YAxis3.Label("Tertiary Axis");

            // adjust axis limits to fit the data once before locking them based on initial check state
            formsPlot1.Plot.AxisAuto();
            SetLocks();

            formsPlot1.Refresh();
        }