コード例 #1
0
ファイル: Fill.cs プロジェクト: Jmerk523/ScottPlot
        public void ExecuteRecipe(Plot plt)
        {
            double SupplyFunction(double q) => 5 * q + 1;
            double DemandFunction(double q) => - 3 * q + 17;

            const double priceFloor = 12.5;

            double[] xs     = DataGen.Consecutive(5);
            double[] supply = xs.Select(SupplyFunction).ToArray();
            double[] demand = xs.Select(DemandFunction).ToArray();

            plt.AddScatter(xs, supply, markerShape: MarkerShape.none, label: "Supply");
            plt.AddScatter(xs, demand, markerShape: MarkerShape.none, label: "Demand");
            plt.AddHorizontalLine(priceFloor, label: "Price Floor");

            double[] maxProducerSurplusBounds = new double[] { 0, 1.5 };
            var      maxProducerSurplus       = plt.AddFill(maxProducerSurplusBounds, maxProducerSurplusBounds.Select(SupplyFunction).ToArray(), maxProducerSurplusBounds, Enumerable.Repeat(priceFloor, 2).ToArray());

            maxProducerSurplus.LineWidth  = 0;
            maxProducerSurplus.FillColor  = Color.LawnGreen;
            maxProducerSurplus.HatchColor = Color.Transparent;
            maxProducerSurplus.HatchStyle = Drawing.HatchStyle.StripedWideDownwardDiagonal;
            maxProducerSurplus.Label      = "Maximum Possible Producer Surplus";

            double[] minProducerSurplusBounds = new double[] { 1.2, 2.3 };
            var      minProducerSurplus       = plt.AddFill(minProducerSurplusBounds, minProducerSurplusBounds.Select(SupplyFunction).ToArray(), minProducerSurplusBounds, Enumerable.Repeat(priceFloor, 2).ToArray());

            minProducerSurplus.LineWidth  = 0;
            minProducerSurplus.FillColor  = Color.Transparent;
            minProducerSurplus.HatchColor = Color.Red;
            minProducerSurplus.HatchStyle = Drawing.HatchStyle.StripedWideDownwardDiagonal;
            minProducerSurplus.Label      = "Minimum Possible Producer Surplus";

            plt.Legend();
        }
コード例 #2
0
        public FormsPlotMouseYTrack()
        {
            MouseMove          += FormsPlotMouseXTrack_MouseMove;
            MouseHorisontalLine = Plot.AddHorizontalLine(0, Color.Green, 1, LineStyle.Dash);

            ZeroHorisontalLine = Plot.AddHorizontalLine(0, Color.Gray, 1, LineStyle.DashDot);

            YMaxWarningHorisontalLine = Plot.AddHorizontalLine(0, Color.Orange, 1, LineStyle.DashDot);
            YMinWarningHorisontalLine = Plot.AddHorizontalLine(0, Color.Orange, 1, LineStyle.DashDot);
        }
コード例 #3
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddFunction(x => Math.Pow(x, 2), lineStyle: LineStyle.Dash);
            plt.AddFunction(x => Math.Sqrt(x), lineStyle: LineStyle.Dash);

            // mark a coordinate from the lower left
            var point1 = plt.AddPoint(1, 1, size: 10, shape: MarkerShape.openCircle);
            var hLine1 = plt.AddHorizontalLine(1, width: 2);

            hLine1.Max   = 1;
            hLine1.Color = point1.Color;
            var vLine1 = plt.AddVerticalLine(1, width: 2);

            vLine1.Max   = 1;
            vLine1.Color = point1.Color;

            // use finate upper and lower limits draw a cross on a point
            var point2 = plt.AddPoint(4, 2, size: 10, shape: MarkerShape.openCircle);
            var vLine2 = plt.AddVerticalLine(4, width: 2);

            vLine2.Min   = 1.5;
            vLine2.Max   = 2.5;
            vLine2.Color = point2.Color;
            var hLine2 = plt.AddHorizontalLine(2, width: 2);

            hLine2.Min   = 3.5;
            hLine2.Max   = 4.5;
            hLine2.Color = point2.Color;

            // mark a coordinate from the top right
            var point3 = plt.AddPoint(2, 4, size: 10, shape: MarkerShape.openCircle);
            var hLine3 = plt.AddHorizontalLine(4, width: 2);

            hLine3.Min   = 2;
            hLine3.Color = point3.Color;
            var vLine3 = plt.AddVerticalLine(2, width: 2);

            vLine3.Min   = 4;
            vLine3.Color = point3.Color;

            plt.SetAxisLimits(0, 5, 0, 5);
        }
コード例 #4
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot sample data
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            // add axis lines
            plt.AddHorizontalLine(.85);
            plt.AddVerticalLine(23);

            // customize axis lines with optional arguments
            plt.AddVerticalLine(x: 33, color: Color.Magenta, width: 3, style: LineStyle.Dot);
        }
コード例 #5
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand       = new Random(0);
            int    pointCount = 500;

            double[] xs = DataGen.Consecutive(pointCount);
            double[] ys = DataGen.Random(rand, pointCount);

            double tenthPercentile = Statistics.Common.Percentile(ys, 10);

            plt.Title("10th Percentile");
            plt.AddScatter(xs, ys, lineWidth: 0, markerShape: MarkerShape.openCircle);
            plt.AddHorizontalLine(tenthPercentile, width: 3, style: LineStyle.Dash);
        }
コード例 #6
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand       = new Random(0);
            int    pointCount = 500;

            double[] xs = DataGen.Consecutive(pointCount);
            double[] ys = DataGen.Random(rand, pointCount);

            // A septile is a 7-quantile
            double secondSeptile = Statistics.Common.Quantile(ys, 2, 7);

            plt.Title("Second Septile");
            plt.AddScatter(xs, ys, lineWidth: 0, markerShape: MarkerShape.openCircle);
            plt.AddHorizontalLine(secondSeptile, width: 3, style: LineStyle.Dash);
        }
コード例 #7
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand       = new Random(0);
            int    pointCount = 500;

            double[] xs = DataGen.Consecutive(pointCount);
            double[] ys = DataGen.Random(rand, pointCount);

            int    n        = 200;
            double nthValue = Statistics.Common.NthOrderStatistic(ys, n);

            plt.Title($"{n}th Smallest Value (of {pointCount})");
            plt.AddScatter(xs, ys, lineWidth: 0, markerShape: MarkerShape.openCircle);
            plt.AddHorizontalLine(nthValue, width: 3, style: LineStyle.Dash);
        }
コード例 #8
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            var hline = plt.AddHorizontalLine(0.23);

            hline.DragEnabled    = true;
            hline.IgnoreAxisAuto = true;

            var hSpan = plt.AddHorizontalSpan(-10, 20);

            hSpan.DragEnabled    = true;
            hSpan.IgnoreAxisAuto = true;
        }
コード例 #9
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand = new Random(0);

            const int n = 500;

            double[] ys = DataGen.Random(rand, n);

            double second_septile = ScottPlot.Statistics.Common.Quantile(ys, 2, 7); // A septile is a 7-quantile

            plt.AddSignal(ys, label: "Random Data");
            plt.AddHorizontalLine(second_septile, label: "2nd Septile");

            plt.Legend();
        }
コード例 #10
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand = new Random(0);

            const int n = 500;

            double[] ys = DataGen.Random(rand, n);

            double tenth_percentile = ScottPlot.Statistics.Common.Percentile(ys, 10); // Note that the 10th percentile is different from 10% lows, which is the average of the bottom 10%

            plt.AddSignal(ys, label: "Random Data");
            plt.AddHorizontalLine(tenth_percentile, label: "10th Percentile");

            plt.Legend();
        }
コード例 #11
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand = new Random(0);

            const int n = 500;

            double[] ys = DataGen.Random(rand, n);

            int k = 200;

            double y = ScottPlot.Statistics.Common.NthOrderStatistic(ys, k);

            plt.AddSignal(ys, label: "Random Data");
            plt.AddHorizontalLine(y, label: $"{k}th Order Statistic");

            plt.Legend();
        }
コード例 #12
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51, mult: 5));
            plt.AddSignal(DataGen.Cos(51, mult: 5));
            double[] snapPositions = DataGen.Consecutive(11, 5);

            // different snap sytems can be created and customized
            var SnapDisabled      = new ScottPlot.SnapLogic.NoSnap1D();
            var SnapNearestInt    = new ScottPlot.SnapLogic.Integer1D();
            var SnapNearestInList = new ScottPlot.SnapLogic.Nearest1D(snapPositions);

            var hLine = plt.AddHorizontalLine(2);

            hLine.DragEnabled = true;
            hLine.DragSnap    = new ScottPlot.SnapLogic.Independent2D(x: SnapDisabled, y: SnapNearestInt);

            var vLine = plt.AddVerticalLine(30);

            vLine.DragEnabled = true;
            vLine.DragSnap    = new ScottPlot.SnapLogic.Independent2D(x: SnapNearestInList, y: SnapDisabled);
        }
コード例 #13
0
        public void ExecuteRecipe(Plot plt)
        {
            // plot sample data
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            // add axis lines and configure their drag settings
            var hLine = plt.AddHorizontalLine(.85);

            hLine.DragEnabled  = true;
            hLine.DragLimitMin = -1;
            hLine.DragLimitMax = 1;

            var vLine = plt.AddVerticalLine(23);

            vLine.DragEnabled  = true;
            vLine.DragLimitMin = 0;
            vLine.DragLimitMax = 50;

            // you can access the position of an axis line at any time
            string message = $"Vertical line is at X={vLine.X}";
        }
コード例 #14
0
        public void ExecuteRecipe(Plot plt)
        {
            plt.AddSignal(DataGen.Sin(51));
            plt.AddSignal(DataGen.Cos(51));

            var hline = plt.AddHorizontalLine(.85);

            hline.LineWidth               = 2;
            hline.PositionLabel           = true;
            hline.PositionLabelBackground = hline.Color;
            hline.DragEnabled             = true;

            var vline = plt.AddVerticalLine(23);

            vline.LineWidth               = 2;
            vline.PositionLabel           = true;
            vline.PositionLabelBackground = vline.Color;
            vline.DragEnabled             = true;

            Func <double, string> xFormatter = x => $"X={x:F2}";

            vline.PositionFormatter = xFormatter;
        }