Exemple #1
0
        public FunctionPlot PlotFunction(
            Func <double, double?> function,
            Color?color             = null,
            double lineWidth        = 1,
            double markerSize       = 0,
            string label            = "f(x)",
            MarkerShape markerShape = MarkerShape.none,
            LineStyle lineStyle     = LineStyle.Solid
            )
        {
            if (markerShape != MarkerShape.none || markerSize != 0)
            {
                throw new ArgumentException("function plots do not use markers");
            }

            FunctionPlot functionPlot = new FunctionPlot(function)
            {
                Color     = color ?? settings.GetNextColor(),
                LineWidth = lineWidth,
                LineStyle = lineStyle,
                Label     = label
            };

            Add(functionPlot);
            return(functionPlot);
        }
Exemple #2
0
        public void Test_function_LineStyle()
        {
            var plt = new ScottPlot.Plot();

            // start with default settings
            double?func(double x) => Math.Sqrt(x);

            var funcPlot = new FunctionPlot(func)
            {
            };

            plt.SetAxisLimits(-1, 1, -.5, 1.5);

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

            // change the plottable
            funcPlot.lineStyle = LineStyle.Dash;
            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.IsLighterThan(before));
        }
Exemple #3
0
        /// <summary>
        /// Add a line plot that uses a function (rather than X/Y points) to place the curve
        /// </summary>
        public FunctionPlot AddFunction(Func <double, double?> function, Color?color = null, double lineWidth = 1, LineStyle lineStyle = LineStyle.Solid)
        {
            FunctionPlot plottable = new FunctionPlot(function)
            {
                Color     = color ?? settings.GetNextColor(),
                LineWidth = lineWidth,
                LineStyle = lineStyle
            };

            Add(plottable);
            return(plottable);
        }