public static Plot CreateAdvancedStatisticsPlot()
        {
            var plt = new ScottPlot.Plot(600, 400);

            // create some sample data to represent test scores
            Random rand = new Random(0);

            double[] scores = DataGen.RandomNormal(rand, 250, 85, 5);

            // create a Population object from the data
            var pop = new ScottPlot.Statistics.Population(scores);

            // display the original values scattered vertically
            double[] ys = DataGen.RandomNormal(rand, pop.values.Length, stdDev: .15);
            plt.PlotScatter(pop.values, ys, markerSize: 10,
                            markerShape: MarkerShape.openCircle, lineWidth: 0);

            // display the bell curve for this distribution
            double[] curveXs = DataGen.Range(pop.minus3stDev, pop.plus3stDev, .1);
            double[] curveYs = pop.GetDistribution(curveXs);
            plt.PlotScatter(curveXs, curveYs, markerSize: 0, lineWidth: 2);

            // improve the style of the plot
            plt.Title($"Test Scores (mean: {pop.mean:0.00} +/- {pop.stDev:0.00}, n={pop.n})");
            plt.XLabel("Score");
            plt.Grid(lineStyle: LineStyle.Dot);

            return(plt);
            //plt.SaveFig("Advanced_Statistics_Population.png");
        }
示例#2
0
        public void Test_Population_CurveSideways()
        {
            Random rand = new Random(0);
            var    ages = new ScottPlot.Statistics.Population(rand, 44, 78, 2);

            double[] curveXs = DataGen.Range(ages.minus3stDev, ages.plus3stDev, .1);
            double[] curveYs = ages.GetDistribution(curveXs);

            var plt = new ScottPlot.Plot(400, 300);

            plt.PlotScatter(DataGen.Random(rand, ages.values.Length), ages.values,
                            markerSize: 10, markerShape: MarkerShape.openCircle, lineWidth: 0);
            plt.PlotScatter(curveYs, curveXs, markerSize: 0);
            plt.Grid(lineStyle: LineStyle.Dot);

            TestTools.SaveFig(plt);
        }