Пример #1
0
        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 void ExecuteRecipe(Plot plt)
        {
            double[] xs      = DataGen.Consecutive(51);
            double[] sines   = DataGen.Sin(51);
            double[] cosines = DataGen.Cos(51);

            plt.AddScatter(xs, sines);
            plt.AddScatter(xs, cosines);
            plt.AddFill(xs, sines);
            plt.AddFill(xs, cosines);

            plt.Grid(onTop: true);
        }
Пример #3
0
        public void ExecuteRecipe(Plot plt)
        {
            // create sample data
            double[] xs  = DataGen.Range(0, 10, .1, true);
            double[] ys1 = DataGen.Sin(xs);
            double[] ys2 = DataGen.Cos(xs);

            // add filled polygons
            plt.AddFill(xs, ys1);
            plt.AddFill(xs, ys2, baseline: -.25);

            // tighten the axis limits so we don't see lines on the edges
            plt.SetAxisLimits(xMin: 0, xMax: 10);
        }
Пример #4
0
        public void ExecuteRecipe(Plot plt)
        {
            // create sample data
            double[] xs  = DataGen.Range(0, 10, .1, true);
            double[] ys1 = DataGen.Sin(xs);
            double[] ys2 = DataGen.Cos(xs);

            // add a polygon to fill the region between the two curves
            plt.AddFill(xs, ys1, xs, ys2);

            // add two scatter plots the traditional way
            plt.AddScatter(xs, ys1, color: Color.Black);
            plt.AddScatter(xs, ys2, color: Color.Black);

            // tighten the axis limits so we don't see lines on the edges
            plt.SetAxisLimits(xMin: 0, xMax: 10);
        }
Пример #5
0
        public void ExecuteRecipe(Plot plt)
        {
            Random rand       = new(0);
            int    pointCount = 100;

            double[] xs = ScottPlot.DataGen.Consecutive(pointCount);

            // plot a shaded region
            double[] lower = ScottPlot.DataGen.Sin(pointCount, 5, offset: 3);
            double[] upper = ScottPlot.DataGen.Cos(pointCount, 5, offset: -3);
            var      poly  = plt.AddFill(xs, lower, upper);

            poly.FillColor = Color.FromArgb(50, Color.Green);

            // plot a line within that region
            double[] ys  = ScottPlot.DataGen.Random(rand, pointCount);
            var      sig = plt.AddSignal(ys);

            sig.Color = plt.Palette.GetColor(0);

            plt.Margins(0, .5);
        }