Exemple #1
0
        public void Test_Text_PixelOffset()
        {
            var plt = new ScottPlot.Plot(400, 300);

            plt.AddPoint(30, .5, System.Drawing.Color.Black, 10);

            var txt = plt.AddText("TEST", 30, .5);

            txt.FontSize        = 20;
            txt.BackgroundColor = System.Drawing.Color.FromArgb(50, System.Drawing.Color.Black);
            txt.BackgroundFill  = true;

            var bmp1 = TestTools.GetLowQualityBitmap(plt);

            txt.PixelOffsetX = 10;
            txt.PixelOffsetY = -10;

            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);

            Assert.That(after.IsDifferentThan(before));
        }
Exemple #2
0
        private ScottPlot.Plot GetDemoPlot()
        {
            Random rand = new Random(0);
            var    plt  = new ScottPlot.Plot();

            plt.AddScatter(DataGen.Random(rand, 100, 20), DataGen.Random(rand, 100, 5, 3), label: "scatter1");
            plt.AddSignal(DataGen.RandomWalk(rand, 100), label: "signal1");
            plt.AddScatter(DataGen.Random(rand, 100), ScottPlot.DataGen.Random(rand, 100), label: "scatter2");
            plt.AddSignal(DataGen.RandomWalk(rand, 100), label: "signal2");
            plt.AddVerticalLine(43, width: 4, label: "vline");
            plt.AddHorizontalLine(1.23, width: 4, label: "hline");
            plt.AddText("ScottPlot", 50, 0.25);
            plt.Legend();
            return(plt);
        }