Пример #1
0
        public PopulationPlot(Population population, string label = null, Color?color = null)
        {
            var populations = new Population[] { population };
            var ps          = new PopulationSeries(populations, label, color ?? Color.LightGray);

            popMultiSeries = new PopulationMultiSeries(new PopulationSeries[] { ps });
        }
Пример #2
0
        public PlottablePopulations(PopulationSeries populationSeries, string label = null, System.Drawing.Color?color = null)
        {
            if (color is null)
            {
                color = System.Drawing.Color.LightGray;
            }

            popMultiSeries = new PopulationMultiSeries(new PopulationSeries[] { populationSeries });
        }
Пример #3
0
        public PlottablePopulations(Population[] populations, string label = null, System.Drawing.Color?color = null)
        {
            if (color is null)
            {
                color = System.Drawing.Color.LightGray;
            }

            var ps = new PopulationSeries(populations, label, color.Value);

            popMultiSeries = new PopulationMultiSeries(new PopulationSeries[] { ps });
        }
Пример #4
0
        public PopulationPlot PlotPopulations(PopulationSeries series, string label = null)
        {
            series.color = settings.GetNextColor();
            if (label != null)
            {
                series.seriesLabel = label;
            }
            var plottable = new PopulationPlot(series);

            Add(plottable);
            return(plottable);
        }
Пример #5
0
 public PopulationPlot(PopulationSeries populationSeries)
 {
     popMultiSeries = new PopulationMultiSeries(new PopulationSeries[] { populationSeries });
 }
Пример #6
0
 public PlottablePopulations(PopulationSeries populationSeries)
 {
     popMultiSeries = new PopulationMultiSeries(new PopulationSeries[] { populationSeries });
 }
Пример #7
0
        public PlottablePopulations(Population[] populations, string label = null, Color?color = null)
        {
            var ps = new PopulationSeries(populations, label, color ?? Color.LightGray);

            popMultiSeries = new PopulationMultiSeries(new PopulationSeries[] { ps });
        }
Пример #8
0
        public void Test_PlottablePopulations_MultiSeries()
        {
            // This example will display age, grouped by location, and by year.
            // This example has 3 series (years), each of which has 5 population objects (locations).

            // for this example we will simulate countries by creating random data
            Random rand = new Random(0);

            // start by collecting series data as Population[] arrays
            var ages1957 = new Population[]
            {
                new Population(rand, 54, 42, 4), // africa
                new Population(rand, 35, 56, 6), // americas
                new Population(rand, 48, 47, 5), // asia
                new Population(rand, 44, 66, 2), // europe
                new Population(rand, 14, 70, 1), // oceania
            };

            var ages1987 = new Population[]
            {
                new Population(rand, 54, 52, 8), // africa
                new Population(rand, 35, 70, 3), // americas
                new Population(rand, 48, 66, 3), // asia
                new Population(rand, 44, 75, 2), // europe
                new Population(rand, 14, 75, 1), // oceania
            };

            var ages2007 = new Population[]
            {
                new Population(rand, 54, 53, 5), // africa
                new Population(rand, 35, 72, 3), // americas
                new Population(rand, 48, 72, 4), // asia
                new Population(rand, 44, 78, 2), // europe
                new Population(rand, 14, 81, 1), // oceania
            };

            // now create a PopulationSeries object for each series
            string[] groupLabels = new string[] { "Africa", "Americas", "Asia", "Europe", "Oceania" };
            var      series1957  = new PopulationSeries(ages1957, "1957", color: System.Drawing.Color.Red);
            var      series1987  = new PopulationSeries(ages1987, "1987", color: System.Drawing.Color.Green);
            var      series2007  = new PopulationSeries(ages2007, "2007", color: System.Drawing.Color.Blue);

            // now collect all the series into a MultiSeries
            var multiSeries          = new PopulationSeries[] { series1957, series1987, series2007 };
            var plottableMultiSeries = new PopulationMultiSeries(multiSeries);
            var customPlottable      = new PopulationPlot(plottableMultiSeries);

            // plot the multi-series
            var plt = new ScottPlot.Plot();

            plt.Add(customPlottable);
            plt.XTicks(labels: groupLabels);
            plt.XAxis.TickLabelStyle(fontSize: 18);
            plt.YAxis.TickLabelStyle(fontSize: 18);

            // additional plot styling
            plt.XAxis2.Label(label: "Life Expectancy", size: 26);
            plt.YAxis.Label(label: "Age (years)", size: 18);
            plt.Legend(location: Alignment.LowerRight);
            plt.Grid(lineStyle: LineStyle.Dot);
            plt.XAxis.Grid(false);

            TestTools.SaveFig(plt);
        }