public static PlotModel MichelsonMorleyExperiment()
        {
            //// http://www.gutenberg.org/files/11753/11753-h/11753-h.htm
            //// http://en.wikipedia.org/wiki/Michelson%E2%80%93Morley_experiment
            //// http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/morley.html

            var model = new PlotModel();

            var s1 = new BoxPlotSeries
            {
                Title           = "Results",
                Stroke          = OxyColors.Black,
                StrokeThickness = 1,
                OutlierSize     = 2,
                BoxWidth        = 0.4
            };

            // note: approximated data values (not the original values)
            s1.Items.Add(new BoxPlotItem(0, 740, 850, 945, 980, 1070, new[] { 650.0 }));
            s1.Items.Add(new BoxPlotItem(1, 750, 805, 845, 890, 970, new double[] { }));
            s1.Items.Add(new BoxPlotItem(2, 845, 847, 855, 880, 910, new[] { 640.0, 950, 970 }));
            s1.Items.Add(new BoxPlotItem(3, 720, 760, 820, 870, 910, new double[] { }));
            s1.Items.Add(new BoxPlotItem(4, 730, 805, 807, 870, 950, new double[] { }));
            model.Series.Add(s1);
            model.Annotations.Add(new LineAnnotation {
                Type = LineAnnotationType.Horizontal, LineStyle = LineStyle.Solid, Y = 792.458, Text = "true speed"
            });
            model.Axes.Add(new CategoryAxis("Experiment No.", "1", "2", "3", "4", "5"));
            model.Axes.Add(new LinearAxis(AxisPosition.Left, "Speed of light (km/s minus 299,000)")
            {
                MajorStep = 100, MinorStep = 100
            });
            return(model);
        }
Exemple #2
0
        public static PlotModel BoxPlotSeries_DateTimeAxis()
        {
            var m  = new PlotModel();
            var x0 = DateTimeAxis.ToDouble(new DateTime(2013, 05, 04));

            m.Axes.Add(new DateTimeAxis
            {
                Position     = AxisPosition.Bottom,
                Minimum      = x0 - 0.9,
                Maximum      = x0 + 1.9,
                IntervalType = DateTimeIntervalType.Days,
                MajorStep    = 1,
                MinorStep    = 1,
                StringFormat = "yyyy-MM-dd"
            });
            var boxPlotSeries = new BoxPlotSeries
            {
                TrackerFormatString = "X: {1:yyyy-MM-dd}\nUpper Whisker: {2:0.00}\nThird Quartil: {3:0.00}\nMedian: {4:0.00}\nFirst Quartil: {5:0.00}\nLower Whisker: {6:0.00}\nMean: {7:0.00}"
            };

            boxPlotSeries.Items.Add(new BoxPlotItem(x0, 10, 14, 16, 20, 22)
            {
                Mean = 17, Outliers = new[] { 23.5 }
            });
            boxPlotSeries.Items.Add(new BoxPlotItem(x0 + 1, 11, 13, 14, 15, 18)
            {
                Outliers = new[] { 23.4 }
            });
            m.Series.Add(boxPlotSeries);
            return(m);
        }
        /// <summary>
        /// Export the box and whisker series to an oxyplot series.
        /// </summary>
        /// <param name="series">The box and whisker series to be exported.</param>
        /// <param name="labels">Existing axis labels.</param>
        /// <param name="labels">Existing axis labels.</param>
        protected override (Series, AxisLabelCollection) Export(BoxWhiskerSeries series, AxisLabelCollection labels)
        {
            BoxPlotSeries result = new BoxPlotSeries();

            (result.Items, labels) = GetBoxPlotItems(series, labels);
            if (series.ShowOnLegend)
            {
                result.Title = series.Title;
            }

            // Line style/thickness
            result.LineStyle       = series.LineConfig.Type.ToOxyPlotLineStyle();
            result.StrokeThickness = series.LineConfig.Thickness.ToOxyPlotThickness();
            // tbi: line colour configuration
            // result.Stroke = series.LineConfig.Colour.ToOxyPlotColour();

            // Marker type/thickness
            result.OutlierType = series.MarkerConfig.Type.ToOxyPlotMarkerType();
            result.OutlierSize = series.MarkerConfig.Size.ToOxyPlotMarkerSize() * series.MarkerConfig.SizeModifier;

            // Colour
            result.Stroke = OxyColors.Transparent;
            result.Fill   = series.Colour.ToOxyColour();

            // todo: need to account for the possibility of string datatypes here.
            return(result, labels);
        }
Exemple #4
0
        private void MakeBoxPlot([JetBrains.Annotations.NotNull] string fileName, [JetBrains.Annotations.NotNull] string plotName, [JetBrains.Annotations.NotNull] DirectoryInfo basisPath, [JetBrains.Annotations.NotNull] List <double> values,
                                 [JetBrains.Annotations.NotNull] LoadTypeInformation lti)
        {
            const int stepsize   = 24 * 60;
            var       dayEntries = new List <DayEntry>();

            for (var i = 0; i < values.Count; i += stepsize)
            {
                var oneDay = new List <double>();
                for (var j = 0; j < stepsize && i + j < values.Count; j++)
                {
                    oneDay.Add(values[i + j]);
                }
                if (oneDay.Count > 5)
                {
                    var min = oneDay.Min();
                    var max = oneDay.Max();
                    oneDay.Sort();
#pragma warning disable VSD0045 // The operands of a divisive expression are both integers and result in an implicit rounding.
                    var idx = oneDay.Count / 2;
#pragma warning restore VSD0045 // The operands of a divisive expression are both integers and result in an implicit rounding.
                    var median = oneDay[idx];
                    dayEntries.Add(new DayEntry(min, max, median, Percentile(oneDay, 0.25),
                                                Percentile(oneDay, 0.75)));
                }
            }

            var plotModel1 = new PlotModel
            {
                LegendPlacement = LegendPlacement.Outside,
                LegendPosition  = LegendPosition.BottomCenter,
                IsLegendVisible = true
            };
            if (Parameters.ShowTitle)
            {
                plotModel1.Title = plotName;
            }
            var linearAxis1 = new LinearAxis
            {
                Position = AxisPosition.Bottom,
                Title    = "Day"
            };
            plotModel1.Axes.Add(linearAxis1);
            var linearAxis2 = new LinearAxis
            {
                Title = lti.Name + " in " + lti.UnitOfPower
            };
            plotModel1.Axes.Add(linearAxis2);
            var bps = new BoxPlotSeries();
            for (var i = 0; i < dayEntries.Count; i++)
            {
                bps.Items.Add(new BoxPlotItem(i, dayEntries[i].MinValue, dayEntries[i].Percentile25,
                                              dayEntries[i].Median, dayEntries[i].Percentile75, dayEntries[i].MaxValue));
            }
            plotModel1.Series.Add(bps);
            plotModel1.LegendBackground = OxyColor.FromArgb(200, 255, 255, 255);
            var fi          = new FileInfo(fileName);
            var dstFileName = fi.Name.Insert(fi.Name.Length - 4, "MinMax.");
            Save(plotModel1, plotName, fileName, basisPath, CalcOption.HouseSumProfilesFromDetailedDats, dstFileName);
        }
Exemple #5
0
        public static PlotModel BoxPlot()
        {
            const int boxes = 10;

            var model = new PlotModel {
                Title = string.Format("BoxPlot (n={0})", boxes), LegendPlacement = LegendPlacement.Outside
            };

            var s1 = new BoxPlotSeries
            {
                Title    = "BoxPlotSeries",
                BoxWidth = 0.3
            };

            var random = new Random(31);

            for (var i = 0; i < boxes; i++)
            {
                double x      = i;
                var    points = 5 + random.Next(15);
                var    values = new List <double>();
                for (var j = 0; j < points; j++)
                {
                    values.Add(random.Next(0, 20));
                }

                values.Sort();
                var    median       = GetMedian(values);
                var    mean         = values.Average();
                int    r            = values.Count % 2;
                double firstQuartil = GetMedian(values.Take((values.Count + r) / 2));
                double thirdQuartil = GetMedian(values.Skip((values.Count - r) / 2));

                var iqr          = thirdQuartil - firstQuartil;
                var step         = iqr * 1.5;
                var upperWhisker = thirdQuartil + step;
                upperWhisker = values.Where(v => v <= upperWhisker).Max();
                var lowerWhisker = firstQuartil - step;
                lowerWhisker = values.Where(v => v >= lowerWhisker).Min();

                var outliers = new[] { upperWhisker + random.Next(1, 10), lowerWhisker - random.Next(1, 10) };

                s1.Items.Add(new BoxPlotItem(x, lowerWhisker, firstQuartil, median, thirdQuartil, upperWhisker)
                {
                    Mean = mean, Outliers = outliers
                });
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Left
            });
            model.Axes.Add(new LinearAxis {
                Position = AxisPosition.Bottom, MinimumPadding = 0.1, MaximumPadding = 0.1
            });
            return(model);
        }
Exemple #6
0
        private PlotModel PrepareDiagram()
        {
            var foreground = OxyColors.SteelBlue;

            var plotModel = new PlotModel
            {
                PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1),
                PlotAreaBorderColor = foreground,
                TextColor = foreground,
                TitleColor = foreground,
                SubtitleColor = foreground
            };

            var series = new BoxPlotSeries
            {
                Stroke = foreground,
                Fill = OxyColors.DarkOrange
            };
            plotModel.Series.Add(series);

            var outlinerSeries = new BoxPlotSeries
            {
                Stroke = foreground,
                Fill = OxyColors.Firebrick,
                OutlierSize = 4
            };
            plotModel.Series.Add(outlinerSeries);

            plotModel.Axes.Add(new LinearAxis
            {
                Position = AxisPosition.Left,
                TextColor = foreground,
                TicklineColor = foreground,
                TitleColor = foreground
            });

            plotModel.Axes.Add(new CategoryAxis
            {
                Position = AxisPosition.Bottom,
                ItemsSource = new[]
                    {
                        "Age",
                        "Annual Income",
                        "Spending Score"
                    },
                TextColor = foreground,
                TicklineColor = OxyColors.Transparent,
                TitleColor = foreground
            });

            Diagram.Model = plotModel;

            return plotModel;
        }
Exemple #7
0
        Task RenderBox(Series plot)
        {
            var boxSeries = new BoxPlotSeries();

            foreach (var item in plot.Data)
            {
                boxSeries.Items.Add(new BoxPlotItem(item.X, item.LowerWhisker, item.BoxBottom, item.Median, item.BoxTop, item.UpperWhisker));
            }
            OxyplotModel.Series.Add(boxSeries);

            return(Task.CompletedTask);
        }
Exemple #8
0
        public static BoxPlotSeries BoxPlot(PlotModel plot, IReadOnlyList <IReadOnlyList <double> > samples)
        {
            var bp = new BoxPlotSeries();

            for (int i = 0; i < samples.Count; i++)
            {
                var sample = samples[i];
                var bpi    = Box(i, sample);
                bp.Items.Add(bpi);
            }
            plot.Series.Add(bp);

            return(bp);
        }
Exemple #9
0
        private BoxPlotSeries CreateSeries(FieldViewModel field, int index)
        {
            // A single series may contain multiple boxes,
            // but the problem is that they must all share the same color,
            // so here each series contains a single box,
            // so that each box can have its own color
            BoxPlotSeries series = new BoxPlotSeries();

            series.Items         = new[] { GetBox(field, index) };
            series.MeanThickness = 0.0;
            series.Stroke        = ColorsToUse.NextColor();
            field.PlotColor      = series.Stroke;
            return(series);
        }
        private PlotModel PrepareDiagram(string[] categories)
        {
            var foreground = OxyColors.SteelBlue;

            var plotModel = new PlotModel
            {
                PlotAreaBorderThickness = new OxyThickness(1, 0, 0, 1),
                PlotAreaBorderColor     = foreground,
                TextColor       = foreground,
                TitleColor      = foreground,
                TitleFontWeight = 2,
                SubtitleColor   = foreground
            };

            var cleanSeries = new BoxPlotSeries
            {
                Stroke = foreground,
                Fill   = OxyColors.DarkOrange
            };

            plotModel.Series.Add(cleanSeries);

            var outlinerSeries = new BoxPlotSeries
            {
                Stroke      = foreground,
                Fill        = OxyColors.Firebrick,
                OutlierSize = 4
            };

            plotModel.Series.Add(outlinerSeries);

            plotModel.Axes.Add(new LinearAxis
            {
                Position      = AxisPosition.Left,
                TextColor     = foreground,
                TicklineColor = foreground,
                TitleColor    = foreground
            });

            plotModel.Axes.Add(new CategoryAxis
            {
                Position      = AxisPosition.Bottom,
                ItemsSource   = categories,
                TextColor     = foreground,
                TicklineColor = OxyColors.Transparent,
                TitleColor    = foreground
            });

            return(plotModel);
        }
Exemple #11
0
        public void TestMarkerFill()
        {
            MarkerType[] filledMarkers = new MarkerType[4]
            {
                MarkerType.FilledCircle,
                MarkerType.FilledDiamond,
                MarkerType.FilledSquare,
                MarkerType.FilledTriangle
            };
            MarkerType[] nonFilledMarkers = new MarkerType[]
            {
                MarkerType.Circle,
                MarkerType.Cross,
                MarkerType.Diamond,
                MarkerType.None,
                MarkerType.Plus,
                MarkerType.Square,
                MarkerType.Star,
                MarkerType.Triangle
            };

            object[] x = new object[5] {
                0d, 1d, 2d, 3d, 4d
            };
            object[] y = new object[5] {
                0d, 0d, 1d, 2d, 2d
            };
            Line line = new Line(LineType.Solid, LineThickness.Normal);

            foreach (MarkerType markerType in filledMarkers)
            {
                Marker           marker    = new Marker(markerType, MarkerSize.Normal, 1);
                BoxWhiskerSeries series    = new BoxWhiskerSeries("Title", Color.Green, true, x, y, line, marker, "", "");
                BoxPlotSeries    oxySeries = (BoxPlotSeries)exporter.Export(series, AxisLabelCollection.Empty()).Result;

                // Because marker type is "filled", series should be filled with colour.
                Assert.AreEqual(OxyColors.Green, oxySeries.Fill);
            }

            foreach (MarkerType markerType in nonFilledMarkers)
            {
                Marker           marker    = new Marker(markerType, MarkerSize.Normal, 1);
                BoxWhiskerSeries series    = new BoxWhiskerSeries("Title", Color.Green, true, x, y, line, marker, "", "");
                BoxPlotSeries    oxySeries = (BoxPlotSeries)exporter.Export(series, AxisLabelCollection.Empty()).Result;

                // Because marker type is "filled", series should be filled with colour.
                // todo
                // Assert.AreEqual(OxyColors.Transparent, oxySeries.Fill);
            }
        }
Exemple #12
0
        public BoxPlotPerFieldPlotModel(IList <FieldViewModel> fields, string yAxisTitle)
        {
            Axes.Add(CreateXAxis(fields));
            Axes.Add(CreateYAxis(yAxisTitle));

            ColorsToUse = new OxyPlotColorsToUse();

            int i = 0;

            foreach (FieldViewModel field in fields)
            {
                BoxPlotSeries series = CreateSeries(field, i++);
                Series.Add(series);
            }
        }
        public static PlotModel BoxPlot()
        {
            const int boxes = 10;

            var model = new PlotModel { Title = string.Format("BoxPlot (n={0})", boxes), LegendPlacement = LegendPlacement.Outside };

            var s1 = new BoxPlotSeries
                {
                    Title = "BoxPlotSeries",
                    BoxWidth = 0.3
                };

            var random = new Random(31);
            for (var i = 0; i < boxes; i++)
            {
                double x = i;
                var points = 5 + random.Next(15);
                var values = new List<double>();
                for (var j = 0; j < points; j++)
                {
                    values.Add(random.Next(0, 20));
                }

                values.Sort();
                var median = GetMedian(values);
                var mean = values.Average();
                int r = values.Count % 2;
                double firstQuartil = GetMedian(values.Take((values.Count + r) / 2));
                double thirdQuartil = GetMedian(values.Skip((values.Count - r) / 2));

                var iqr = thirdQuartil - firstQuartil;
                var step = iqr * 1.5;
                var upperWhisker = thirdQuartil + step;
                upperWhisker = values.Where(v => v <= upperWhisker).Max();
                var lowerWhisker = firstQuartil - step;
                lowerWhisker = values.Where(v => v >= lowerWhisker).Min();

                var outliers = new[] { upperWhisker + random.Next(1, 10), lowerWhisker - random.Next(1, 10) };

                s1.Items.Add(new BoxPlotItem(x, lowerWhisker, firstQuartil, median, thirdQuartil, upperWhisker) { Mean = mean, Outliers =  outliers });
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Left });
            model.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, MinimumPadding = 0.1, MaximumPadding = 0.1 });
            return model;
        }
Exemple #14
0
        public void TestSimpleCase()
        {
            object[] x = new object[7] {
                0d, 1d, 2d, 3d, 4d, 5d, 6d
            };
            object[] y = new object[7] {
                0d, 1d, 1d, 2d, 3d, 3d, 4d
            };
            Line             line   = new Line(LineType.Solid, LineThickness.Normal);
            Marker           marker = new Marker(MarkerType.FilledSquare, MarkerSize.Normal, 1);
            BoxWhiskerSeries series = new BoxWhiskerSeries("Title", Color.Red, true, x, y, line, marker, "", "");
            var oxySeries           = exporter.Export(series, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(oxySeries);
            Assert.True(oxySeries is BoxPlotSeries);
            BoxPlotSeries boxPlot = (BoxPlotSeries)oxySeries;

            // Line style
            Assert.AreEqual(OxyPlot.LineStyle.Solid, boxPlot.LineStyle);
            Assert.AreEqual(0.5, boxPlot.StrokeThickness);

            // Marker style
            Assert.AreEqual(OxyPlot.MarkerType.Square, boxPlot.OutlierType);
            Assert.AreEqual(7, boxPlot.OutlierSize);

            // Colours
            Assert.AreEqual(OxyColors.Transparent, boxPlot.Stroke);
            Assert.AreEqual(OxyColors.Red, boxPlot.Fill);

            // Title
            Assert.AreEqual("Title", boxPlot.Title);

            // Contents of series.
            Assert.AreEqual(1, boxPlot.Items.Count);
            BoxPlotItem item = boxPlot.Items[0];

            Assert.NotNull(item);

            // Test box plot whisker values.
            Assert.AreEqual(0, item.X);
            Assert.AreEqual(0, item.LowerWhisker);
            Assert.AreEqual(1, item.BoxBottom);
            Assert.AreEqual(2, item.Median);
            Assert.AreEqual(3, item.BoxTop);
            Assert.AreEqual(4, item.UpperWhisker);
        }
        public static PlotModel BoxPlotSeries_DateTimeAxis()
        {
            var m  = new PlotModel();
            var x0 = DateTimeAxis.ToDouble(new DateTime(2013, 05, 04));
            var a  = new DateTimeAxis(AxisPosition.Bottom)
            {
                Minimum      = x0 - 0.9,
                Maximum      = x0 + 1.9,
                IntervalType = DateTimeIntervalType.Days,
                MajorStep    = 1,
                MinorStep    = 1
            };

            a.StringFormat = "yyyy-MM-dd";
            m.Axes.Add(a);
            var s = new BoxPlotSeries();

            s.TrackerFormatString =
                "X: {1:yyyy-MM-dd}\nUpper Whisker: {2:0.00}\nThird Quartil: {3:0.00}\nMedian: {4:0.00}\nFirst Quartil: {5:0.00}\nLower Whisker: {6:0.00}";
            s.Items.Add(new BoxPlotItem(x0, 10, 14, 16, 20, 22, new[] { 23.5 }));
            s.Items.Add(new BoxPlotItem(x0 + 1, 11, 13, 14, 15, 18, new[] { 23.4 }));
            m.Series.Add(s);
            return(m);
        }
        public PlotModel CreateBoxPlot(int patientID)
        {
            var plot = new PlotModel
            {
                Title    = "Box Plot",
                Subtitle = "Patient ID: " + patientID
            };
            var items = new Collection <Item>();

            foreach (var item in MainWindow.classificationDistances)
            {
                items.Add(new Item {
                    Label = item.Key.ToString()
                });
            }

            plot.Axes.Add(new LinearAxis
            {
                Position        = AxisPosition.Left,
                MajorStep       = 0.025,
                MinorStep       = 0.005,
                Key             = "Distance",
                TickStyle       = TickStyle.Crossing,
                AbsoluteMaximum = 1,
                AbsoluteMinimum = -0.25
            });

            plot.Axes.Add(new CategoryAxis
            {
                Position       = AxisPosition.Bottom,
                ItemsSource    = items,
                LabelField     = "Label",
                Key            = "Classification",
                IsTickCentered = true,
                TickStyle      = TickStyle.None,
                IsZoomEnabled  = false
            });


            var s1 = new BoxPlotSeries
            {
                Fill            = OxyColor.FromRgb(0x1e, 0xb4, 0xda),
                StrokeThickness = 1.1,
                WhiskerWidth    = 1
            };

            double x = 0;

            foreach (var item in MainWindow.classificationDistances)
            {
                var values = new List <double>();
                foreach (var value in item.Value)
                {
                    values.Add(value);
                }

                values.Sort();
                var    median       = getMedian(values);
                int    r            = values.Count % 2;
                double firstQuartil = getMedian(values.Take((values.Count + r) / 2)); // 25%-Quartil
                double thirdQuartil = getMedian(values.Skip((values.Count - r) / 2)); // 75%-Quartil

                var iqr          = thirdQuartil - firstQuartil;                       // Quartilabstand
                var step         = 1.5 * iqr;
                var upperWhisker = thirdQuartil + step;
                upperWhisker = values.Max();
                var lowerWhisker = firstQuartil - step;
                lowerWhisker = values.Min();
                var outliers = values.Where(v => v > upperWhisker || v < lowerWhisker).ToList();

                s1.Items.Add(new BoxPlotItem(x, lowerWhisker, firstQuartil, median, thirdQuartil, upperWhisker));
                x++;
            }

            plot.Series.Add(s1);
            return(plot);
        }
 public static PlotModel BoxPlotSeries_DateTimeAxis()
 {
     var m = new PlotModel();
     var x0 = DateTimeAxis.ToDouble(new DateTime(2013, 05, 04));
     var a = new DateTimeAxis(AxisPosition.Bottom)
                 {
                     Minimum = x0 - 0.9,
                     Maximum = x0 + 1.9,
                     IntervalType = DateTimeIntervalType.Days,
                     MajorStep = 1,
                     MinorStep = 1
                 };
     a.StringFormat = "yyyy-MM-dd";
     m.Axes.Add(a);
     var s = new BoxPlotSeries();
     s.TrackerFormatString =
                     "X: {1:yyyy-MM-dd}\nUpper Whisker: {2:0.00}\nThird Quartil: {3:0.00}\nMedian: {4:0.00}\nFirst Quartil: {5:0.00}\nLower Whisker: {6:0.00}";
     s.Items.Add(new BoxPlotItem(x0, 10, 14, 16, 20, 22, new[] { 23.5 }));
     s.Items.Add(new BoxPlotItem(x0 + 1, 11, 13, 14, 15, 18, new[] { 23.4 }));
     m.Series.Add(s);
     return m;
 }
        public static PlotModel MichelsonMorleyExperiment()
        {
            //// http://www.gutenberg.org/files/11753/11753-h/11753-h.htm
            //// http://en.wikipedia.org/wiki/Michelson%E2%80%93Morley_experiment
            //// http://stat.ethz.ch/R-manual/R-devel/library/datasets/html/morley.html

            var model = new PlotModel();

            var s1 = new BoxPlotSeries
            {
                Title = "Results",
                Stroke = OxyColors.Black,
                StrokeThickness = 1,
                OutlierSize = 2,
                BoxWidth = 0.4
            };

            // note: approximated data values (not the original values)
            s1.Items.Add(new BoxPlotItem(0, 740, 850, 945, 980, 1070, new[] { 650.0 }));
            s1.Items.Add(new BoxPlotItem(1, 750, 805, 845, 890, 970, new double[] { }));
            s1.Items.Add(new BoxPlotItem(2, 845, 847, 855, 880, 910, new[] { 640.0, 950, 970 }));
            s1.Items.Add(new BoxPlotItem(3, 720, 760, 820, 870, 910, new double[] { }));
            s1.Items.Add(new BoxPlotItem(4, 730, 805, 807, 870, 950, new double[] { }));
            model.Series.Add(s1);
            model.Annotations.Add(new LineAnnotation { Type = LineAnnotationType.Horizontal, LineStyle = LineStyle.Solid, Y = 792.458, Text = "true speed" });
            model.Axes.Add(new CategoryAxis("Experiment No.", "1", "2", "3", "4", "5"));
            model.Axes.Add(new LinearAxis(AxisPosition.Left, "Speed of light (km/s minus 299,000)") { MajorStep = 100, MinorStep = 100 });
            return model;
        }
Exemple #19
0
        public void CreateGraphs()
        {
            Simulations sims = CreateTemplate();

            sims.FileName = Path.ChangeExtension(Path.GetTempFileName(), ".apsimx");

            DataStore storage = sims.FindInScope <DataStore>();

            storage.FileName = Path.ChangeExtension(sims.FileName, ".db");

            // Run the file to populate the datastore.
            Runner           runner = new Runner(sims);
            List <Exception> errors = runner.Run();

            if (errors != null && errors.Count > 0)
            {
                throw errors[0];
            }

            // Open the .apsimx file in the GUI.
            sims.Write(sims.FileName);
            ExplorerPresenter explorer = UITestsMain.MasterPresenter.OpenApsimXFileInTab(sims.FileName, true);

            GtkUtilities.WaitForGtkEvents();
            sims = explorer.ApsimXFile;

            // Create a graphs folder under the zone.
            IModel paddock = sims.FindInScope <Zone>();
            Folder graphs  = new Folder();

            graphs.Name = "Graphs";

            var command = new AddModelCommand(paddock, graphs);

            explorer.CommandHistory.Add(command, true);

            // Add an empty graph to the folder.
            Models.Graph graph = new Models.Graph();
            graph.Name = "Graph";
            command    = new AddModelCommand(graphs, graph);
            explorer.CommandHistory.Add(command, true);

            // Add an empty series to the graph.
            Models.Series series = new Models.Series();
            series.Name = "Series";
            command     = new AddModelCommand(graph, series);
            explorer.CommandHistory.Add(command, true);
            explorer.Refresh();

            // click on the series node.
            explorer.SelectNode(series.FullPath);
            GtkUtilities.WaitForGtkEvents();

            // Get a reference to the OxyPlot PlotView via reflection.
            SeriesView seriesView = explorer.CurrentRightHandView as SeriesView;
            GraphView  view       = seriesView?.GraphView as GraphView;

            Assert.NotNull(view);

            PlotView plot = ReflectionUtilities.GetValueOfFieldOrProperty("plot1", view) as PlotView;

            Assert.NotNull(plot);

            // Series has no table name or x/y series names yet, so there should
            // be nothing shown on the graph.
            Assert.AreEqual(0, plot.Model.Series.Count);

            // Now draw some data on the graph.
            seriesView.DataSource.SelectedValue = "Report";
            seriesView.X.SelectedValue          = "n";
            seriesView.Y.SelectedValue          = "n2";
            seriesView.SeriesType.SelectedValue = "Scatter";

            GtkUtilities.WaitForGtkEvents();

            // There should now be one series showing.
            Assert.AreEqual(1, plot.Model.Series.Count);

            // It should be a line series.
            Assert.True(plot.Model.Series[0] is LineSeries, "Graph series type is set to scatter, but the series object is not a LineSeries.");

            // Series colour should not be white, and should not be the same as the background colour.
            LineSeries line = plot.Model.Series[0] as LineSeries;

            OxyPlot.OxyColor empty = OxyPlot.OxyColor.FromArgb(0, 0, 0, 0);
            OxyPlot.OxyColor white = OxyPlot.OxyColor.FromArgb(0, 255, 255, 255);
            Assert.AreNotEqual(empty, line.Color, "Graph line series default colour is white on white.");
            Assert.AreNotEqual(white, line.Color, "Graph line series default colour is white on white.");

            // Legend should be visible but empty by default.
            Assert.True(plot.Model.IsLegendVisible);
            // todo - ensure legend is empty

            // Next, we want to change the legend position and ensure that the legend actually moves.

            // Click on the 'show in legend' checkbox.
            seriesView.ShowInLegend.Checked = true;
            GtkUtilities.WaitForGtkEvents();

            // Double click on the middle of the legend.
            Cairo.Rectangle legendRect = plot.Model.LegendArea.ToRect(true);
            double          x          = (legendRect.X + (legendRect.X + legendRect.Width)) / 2;
            double          y          = (legendRect.Y + (legendRect.Y + legendRect.Height)) / 2;

            GtkUtilities.DoubleClick(plot, x, y, wait: true);

            // Default legend position should be top-left.
            Assert.AreEqual(plot.Model.LegendPosition, OxyPlot.LegendPosition.TopLeft);

            // Now we want to change the legend position. First, get a reference to the legend view
            // via the legend presenter, via the graph presenter, via the series presenter, via the explorer presenter.
            Assert.True(explorer.CurrentPresenter is SeriesPresenter);
            SeriesPresenter seriesPresenter = explorer.CurrentPresenter as SeriesPresenter;
            LegendPresenter legendPresenter = seriesPresenter.GraphPresenter.CurrentPresenter as LegendPresenter;

            // todo: should we add something like a GetView() method to the IPresenter interface?
            // It might be a bit of work to set up but would save us having to use reflection
            LegendView legendView = ReflectionUtilities.GetValueOfFieldOrProperty("view", legendPresenter) as LegendView;

            // The legend options are inside a Gtk expander.
            Assert.IsTrue(legendView.MainWidget.Parent is Expander);
            Expander expander = legendView.MainWidget.Parent as Expander;

            // The expander should be expanded and the options visible.
            Assert.IsTrue(expander.Expanded);
            Assert.IsTrue(legendView.MainWidget.Visible);

            // The legend view contains a combo box with the legend position options (top-right, bottom-left, etc).
            // This should really be refactored to use a public IDropDownView, which is much more convenient to use.
            // First, get a reference to the combo box via reflection.
            ComboBox combo = ReflectionUtilities.GetValueOfFieldOrProperty("combobox1", legendView) as ComboBox;

            // fixme - we should support all valid OxyPlot legend position types.
            foreach (Models.Graph.LegendPositionType legendPosition in Enum.GetValues(typeof(Models.Graph.LegendPositionType)))
            {
                string name = legendPosition.ToString();
                GtkUtilities.SelectComboBoxItem(combo, name, wait: true);

                OxyPlot.LegendPosition oxyPlotEquivalent = (OxyPlot.LegendPosition)Enum.Parse(typeof(OxyPlot.LegendPosition), name);
                Assert.AreEqual(plot.Model.LegendPosition, oxyPlotEquivalent);
            }

            // If we change the graph to a box plot then the several unused properties should be disabled.
            // These are x variable dropdown, x cumulative, x on top, marker size/type checkboxes.

            // First, make sure that these options are sensitive to input and can be changed.
            Assert.IsTrue(seriesView.X.IsSensitive);
            Assert.IsTrue(seriesView.XCumulative.IsSensitive);
            Assert.IsTrue(seriesView.XOnTop.IsSensitive);
            Assert.IsTrue(seriesView.MarkerSize.IsSensitive);
            Assert.IsTrue(seriesView.MarkerType.IsSensitive);

            // Now change series type to box plot.
            GtkUtilities.SelectComboBoxItem(seriesView.SeriesType, "Box", wait: true);
            Assert.AreEqual(SeriesType.Box, series.Type);

            // Ensure the box plot is not white in light theme.
            plot = ReflectionUtilities.GetValueOfFieldOrProperty("plot1", view) as PlotView;
            Assert.NotNull(plot);
            BoxPlotSeries boxPlot = plot.Model.Series.OfType <BoxPlotSeries>().FirstOrDefault();

            Assert.NotNull(boxPlot);

            Assert.AreNotEqual(empty, boxPlot.Fill);
            Assert.AreNotEqual(white, boxPlot.Fill);
            Assert.AreNotEqual(empty, boxPlot.Stroke);
            Assert.AreNotEqual(white, boxPlot.Stroke);

            // The controls should no longer be sensitive.
            Assert.IsFalse(seriesView.XCumulative.IsSensitive);
            Assert.IsFalse(seriesView.XOnTop.IsSensitive);
            Assert.IsFalse(seriesView.MarkerSize.IsSensitive);
            Assert.IsFalse(seriesView.MarkerType.IsSensitive);

            // Change the series type back to scatter.
            GtkUtilities.SelectComboBoxItem(seriesView.SeriesType, "Scatter", wait: true);

            // The controls should be sensitive once more.
            Assert.IsTrue(seriesView.X.IsSensitive);
            Assert.IsTrue(seriesView.XCumulative.IsSensitive);
            Assert.IsTrue(seriesView.XOnTop.IsSensitive);
            Assert.IsTrue(seriesView.MarkerSize.IsSensitive);
            Assert.IsTrue(seriesView.MarkerType.IsSensitive);
        }
Exemple #20
0
    public PlotModel createBoxPlot()
    {
        const int boxes = 16;
        var       plot  = new PlotModel();
        var       items = new Collection <Item>();

        for (int i = 1; i < boxes + 1; i++)
        {
            items.Add(new Item {
                Label = i.ToString()
            });
        }
        plot.Axes.Add(new LinearAxis
        {
            Position        = AxisPosition.Left,
            MajorStep       = 1,
            MinorStep       = 0.25,
            TickStyle       = TickStyle.Crossing,
            AbsoluteMaximum = 5.25,
            AbsoluteMinimum = -0.25
        });
        plot.Axes.Add(new CategoryAxis
        {
            Position        = AxisPosition.Bottom,
            ItemsSource     = items,
            LabelField      = "Label",
            IsTickCentered  = true,
            TickStyle       = TickStyle.None,
            AbsoluteMinimum = -1,
            AbsoluteMaximum = 17,
            IsZoomEnabled   = false
        });
        var lineAnnotation = new LineAnnotation
        {
            Type            = LineAnnotationType.Horizontal,
            Y               = 5,
            LineStyle       = LineStyle.Dash,
            StrokeThickness = 2,
            Color           = OxyColor.FromArgb(50, 0, 0, 0)
        };

        plot.Annotations.Add(lineAnnotation);
        lineAnnotation = new LineAnnotation
        {
            Type            = LineAnnotationType.Horizontal,
            Y               = 1,
            LineStyle       = LineStyle.Dash,
            StrokeThickness = 1.5,
            Color           = OxyColor.FromArgb(50, 0, 0, 0)
        };
        plot.Annotations.Add(lineAnnotation);
        lineAnnotation = new LineAnnotation
        {
            Type            = LineAnnotationType.Horizontal,
            Y               = 4,
            LineStyle       = LineStyle.Solid,
            StrokeThickness = 1.5,
            Color           = OxyColor.FromArgb(50, 0, 0, 0)
        };
        plot.Annotations.Add(lineAnnotation);
        lineAnnotation = new LineAnnotation
        {
            Type            = LineAnnotationType.Horizontal,
            Y               = 2,
            LineStyle       = LineStyle.Solid,
            StrokeThickness = 1.5,
            Color           = OxyColor.FromArgb(50, 0, 0, 0)
        };
        plot.Annotations.Add(lineAnnotation);
        var s1 = new BoxPlotSeries();

        s1.Fill            = OxyColor.FromRgb(0x1e, 0xb4, 0xda);
        s1.StrokeThickness = 1.1;
        s1.WhiskerWidth    = 1;
        var random = new Random();

        for (int i = 0; i < boxes; i++)
        {
            double x      = i;
            var    points = 5 + random.Next(15);
            var    values = new List <double>();
            for (int j = 0; j < points; j++)
            {
                values.Add((random.NextDouble()) * 5);
            }
            values.Sort();
            var    median       = getMedian(values);
            int    r            = values.Count % 2;
            double firstQuartil = getMedian(values.Take((values.Count + r) / 2)); // 25%-Quartil
            double thirdQuartil = getMedian(values.Skip((values.Count - r) / 2)); // 75%-Quartil
            var    iqr          = thirdQuartil - firstQuartil;                    // Quartilabstand
            var    step         = 1.5 * iqr;
            var    upperWhisker = thirdQuartil + step;
            upperWhisker = values.Where(v => v <= upperWhisker).Max();
            var lowerWhisker = firstQuartil - step;
            lowerWhisker = values.Where(v => v >= lowerWhisker).Min();
            var outliers = values.Where(v => v > upperWhisker || v < lowerWhisker).ToList();
            s1.Items.Add(new BoxPlotItem(x, lowerWhisker, firstQuartil, median, thirdQuartil, upperWhisker, outliers));
        }
        plot.Series.Add(s1);
        return(plot);
    }
 public static PlotModel BoxPlotSeries_DateTimeAxis()
 {
     var m = new PlotModel();
     var x0 = DateTimeAxis.ToDouble(new DateTime(2013, 05, 04));
     m.Axes.Add(new DateTimeAxis
     {
         Position = AxisPosition.Bottom,
         Minimum = x0 - 0.9,
         Maximum = x0 + 1.9,
         IntervalType = DateTimeIntervalType.Days,
         MajorStep = 1,
         MinorStep = 1,
         StringFormat = "yyyy-MM-dd"
     });
     var boxPlotSeries = new BoxPlotSeries
     {
         TrackerFormatString = "X: {1:yyyy-MM-dd}\nUpper Whisker: {2:0.00}\nThird Quartil: {3:0.00}\nMedian: {4:0.00}\nFirst Quartil: {5:0.00}\nLower Whisker: {6:0.00}\nMean: {7:0.00}"
     };
     boxPlotSeries.Items.Add(new BoxPlotItem(x0, 10, 14, 16, 20, 22) { Mean = 17, Outliers = new[] { 23.5 }});
     boxPlotSeries.Items.Add(new BoxPlotItem(x0 + 1, 11, 13, 14, 15, 18) { Outliers = new[] { 23.4 }});
     m.Series.Add(boxPlotSeries);
     return m;
 }
Exemple #22
0
        public static PlotModel BoxPlot()
        {
            const int boxes = 10;

            var model = new PlotModel(string.Format("BoxPlot (n={0})", boxes))
            {
                LegendPlacement = LegendPlacement.Outside
            };

            var s1 = new BoxPlotSeries
            {
                Title    = "BoxPlotSeries",
                BoxWidth = 0.3
            };

            var random = new Random();

            for (var i = 0; i < boxes; i++)
            {
                double x      = i;
                var    points = 5 + random.Next(15);
                var    values = new List <double>();
                for (var j = 0; j < points; j++)
                {
                    values.Add(random.Next(0, 20));
                }

                values.Sort();
                var    median       = GetMedian(values);
                int    r            = values.Count % 2;
                double firstQuartil =
                    //TEST  GetMedian(values.Take((values.Count + r) / 2));
                    GetMedian(Alt.EnumerableHelper.Take(values, (values.Count + r) / 2));

                double thirdQuartil =
                    //TEST  GetMedian(values.Skip((values.Count - r) / 2));
                    GetMedian(Alt.EnumerableHelper.Skip(values, (values.Count - r) / 2));

                var iqr          = thirdQuartil - firstQuartil;
                var step         = iqr * 1.5;
                var upperWhisker = thirdQuartil + step;
                upperWhisker =
                    //TEST  values.Where(v => v <= upperWhisker).Max();
                    Alt.EnumerableHelper.Max(Alt.EnumerableHelper.Where(values, v => v <= upperWhisker));

                var lowerWhisker = firstQuartil - step;
                lowerWhisker =
                    //TEST  values.Where(v => v >= lowerWhisker).Min();
                    Alt.EnumerableHelper.Min(Alt.EnumerableHelper.Where(values, v => v >= lowerWhisker));

                var outliers =
                    //TEST  values.Where(v => v > upperWhisker || v < lowerWhisker).ToList();
                    Alt.EnumerableHelper.ToList(Alt.EnumerableHelper.Where(values, v => v > upperWhisker || v < lowerWhisker));

                s1.Items.Add(new BoxPlotItem(x, lowerWhisker, firstQuartil, median, thirdQuartil, upperWhisker, outliers));
            }

            model.Series.Add(s1);
            model.Axes.Add(new LinearAxis(AxisPosition.Left));
            model.Axes.Add(new LinearAxis(AxisPosition.Bottom)
            {
                MinimumPadding = 0.1, MaximumPadding = 0.1
            });
            return(model);
        }
Exemple #23
0
        //bool showXAxis = true, showYAxix = true, isZoomable = true, isMovable = true;
        //IPlotType chart;
        //public bool ShowXAxis
        //{
        //    get => showXAxis;
        //    set
        //    {
        //        if (showXAxis == value) return;
        //        showXAxis = value;
        //    }
        //}
        //public bool ShowYAxix
        //{
        //    get => showYAxix;
        //    set
        //    {
        //        if (showYAxix == value) return;
        //        showYAxix = value;
        //    }
        //}
        //public bool IsZoomable
        //{
        //    get => isZoomable;
        //    set
        //    {
        //        if (isZoomable == value) return;
        //        isZoomable = value;
        //    }
        //}
        //public bool IsMovable
        //{
        //    get => isMovable;
        //    set
        //    {
        //        if (isMovable == value) return;
        //        isMovable = value;
        //    }
        //}

        public async Task Add(PlotModel plotModel)
        {
            this.oxyplotModel       = new OxyPlot.PlotModel();
            this.oxyplotModel.Title = plotModel.Title;
            foreach (var chart in plotModel.Series)
            {
                if (chart is TwoColorArea) //it should be placed before Area if clause
                {
                    var twoColorAreaSeries = new TwoColorAreaSeries
                    {
                        Color  = ChartColor.CastToOxyColor(((TwoColorArea)chart).Color),
                        Color2 = ChartColor.CastToOxyColor(((TwoColorArea)chart).Color2),
                        Limit  = ((TwoColorArea)chart).Limit
                    };
                    foreach (var item in ((TwoColorArea)chart).Data)
                    {
                        twoColorAreaSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(twoColorAreaSeries);
                }
                else if (chart is Area)
                {
                    var areaSeries = new AreaSeries();
                    foreach (var point in ((Area)chart).Data)
                    {
                        areaSeries.Points.Add(point);
                    }
                    this.oxyplotModel.Series.Add(areaSeries);
                }
                else if (chart is TwoColorLine)//it should be placed before line if clause
                {
                    var twoColorLineSeries = new TwoColorLineSeries
                    {
                        Color  = ChartColor.CastToOxyColor(((TwoColorLine)chart).Color),
                        Color2 = ChartColor.CastToOxyColor(((TwoColorLine)chart).Color2),
                        Limit  = ((TwoColorLine)chart).Limit
                    };
                    foreach (var item in ((TwoColorLine)chart).Data)
                    {
                        twoColorLineSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(twoColorLineSeries);
                }
                else if (chart is Line)
                {
                    var lineSeries = new LineSeries
                    {
                        MarkerType   = MarkerType.Circle,
                        MarkerSize   = 4,
                        MarkerStroke = OxyColors.White
                    };

                    foreach (var point in ((Line)chart).Data)
                    {
                        lineSeries.Points.Add(point);
                    }
                    this.oxyplotModel.Series.Add(lineSeries);
                }
                else if (chart is Pie)
                {
                    var pieSeries = new PieSeries();
                    foreach (var slice in ((Pie)chart).Data)
                    {
                        pieSeries.Slices.Add(slice);
                    }
                    this.oxyplotModel.Series.Add(pieSeries);
                }
                else if (chart is Bar)
                {
                    var barSeries = new BarSeries();
                    foreach (var item in ((Bar)chart).Data)
                    {
                        barSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(barSeries);
                }
                else if (chart is ErrorColumn)
                {
                    var errorColumn = new ErrorColumnSeries();
                    foreach (ErrorColumnItem item in ((ErrorColumn)chart).Data)
                    {
                        errorColumn.Items.Add((OxyPlot.Series.ErrorColumnItem)item);
                    }
                    this.oxyplotModel.Series.Add(errorColumn);
                }
                else if (chart is Column)
                {
                    var barSeries = new ColumnSeries();
                    foreach (var item in ((Column)chart).Data)
                    {
                        barSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(barSeries);
                }
                else if (chart is Box)
                {
                    var boxSeries = new BoxPlotSeries();
                    foreach (var item in ((Box)chart).Data)
                    {
                        boxSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(boxSeries);
                }
                else if (chart is Contour)
                {
                    var contourSeries = new ContourSeries
                    {
                        Data = ((Contour)chart).Data,
                        ColumnCoordinates = ((Contour)chart).ColumnCoordinates,
                        RowCoordinates    = ((Contour)chart).RowCoordinates
                    };
                    this.oxyplotModel.Series.Add(contourSeries);
                }
                else if (chart is RectangleBar)
                {
                    var rectangleBarSeries = new RectangleBarSeries
                    {
                        Title = ((RectangleBar)chart).Title
                    };
                    foreach (var item in ((RectangleBar)chart).Data)
                    {
                        rectangleBarSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(rectangleBarSeries);
                }
                else if (chart is CandleStick)
                {
                    var candleStickSeries = new CandleStickSeries();
                    foreach (var item in ((CandleStick)chart).Data)
                    {
                        candleStickSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(candleStickSeries);
                }
                else if (chart is HeatMap)
                {
                    var heatMapSeries = new HeatMapSeries()
                    {
                        Data         = ((HeatMap)chart).Data,
                        X0           = ((HeatMap)chart).X0,
                        X1           = ((HeatMap)chart).X1,
                        Y0           = ((HeatMap)chart).Y0,
                        Y1           = ((HeatMap)chart).Y1,
                        Interpolate  = ((HeatMap)chart).Interpolate,
                        RenderMethod = ((HeatMap)chart).RenderMethod
                    };
                    this.oxyplotModel.Series.Add(heatMapSeries);
                }
                else if (chart is HighLow)
                {
                    var highLowSeries = new HighLowSeries();
                    foreach (var item in ((HighLow)chart).Data)
                    {
                        highLowSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(highLowSeries);
                }
                else if (chart is IntervalBar)
                {
                    var intervalBarSeries = new IntervalBarSeries();
                    foreach (var item in ((IntervalBar)chart).Data)
                    {
                        intervalBarSeries.Items.Add(item);
                    }
                    this.oxyplotModel.Series.Add(intervalBarSeries);
                }
                else if (chart is Scatter)
                {
                    var scatterSeries = new ScatterSeries();
                    foreach (var item in ((Scatter)chart).Data)
                    {
                        scatterSeries.Points.Add(item);
                    }
                    this.oxyplotModel.Series.Add(scatterSeries);
                }
            }
            foreach (var axis in plotModel.Axes)
            {
                this.oxyplotModel.Axes.Add(axis);
            }
        }
Exemple #24
0
        public void Load(string dataType)
        {
            DataType = dataType;

            var regions  = _regionService.GetRegionsByIndex();
            var filtSubs = _computeService.GetFilteredSubjectsByComputeGroup();

            var grp1 = filtSubs[ComputeGroup.GroupOne];
            var grp2 = filtSubs[ComputeGroup.GroupTwo];

            List <List <double> > vtxStrs1 = new List <List <double> >();
            List <List <double> > vtxStrs2 = new List <List <double> >();

            foreach (var r in regions)
            {
                vtxStrs1.Add(new List <double>());
                vtxStrs2.Add(new List <double>());
            }

            // Calc our global and vertex strengths for our groups
            List <double> grp1Vals = CalculateStrength(grp1, dataType, vtxStrs1);
            List <double> grp2Vals = CalculateStrength(grp2, dataType, vtxStrs2);

            // Sig test the verticies
            _rsvms = new List <RegionalStrengthViewModel>();

            for (int i = 0; i < regions.Count; i++)
            {
                var lst1 = vtxStrs1[i];
                var lst2 = vtxStrs2[i];

                double ybt = 0; double ylt = 0; double yrt = 0;
                alglib.studentttest2(lst1.ToArray(), lst1.Count, lst2.ToArray(), lst2.Count, out ybt, out ylt, out yrt);

                RegionalStrengthViewModel rsvm = new RegionalStrengthViewModel
                {
                    ROI             = regions[i],
                    GroupDifference = lst1.Average() - lst2.Average(),
                    PValue          = ybt,
                };

                _rsvms.Add(rsvm);
            }

            int  idx         = 1;
            bool begin       = true;
            var  sortedRsvms = _rsvms.OrderBy(r => r.PValue);

            foreach (var rsvm in sortedRsvms)
            {
                double dIdx = (double)idx;
                double dReg = (double)regions.Count;
                double qval = (dIdx / dReg) * 0.05;

                rsvm.SignificantLevel = qval;

                if (rsvm.PValue < qval && begin)
                {
                    rsvm.Significant = true;
                }
                else
                {
                    begin            = false;
                    rsvm.Significant = false;
                }

                idx++;
            }

            AXPlotModel = LoadPlotModel(_rsvms, r => r.X, r => r.Y);
            SGPlotModel = LoadPlotModel(_rsvms, r => (100 - r.Y), r => r.Z);
            CRPlotModel = LoadPlotModel(_rsvms, r => r.X, r => r.Z);

            double bt = 0; double lt = 0; double rt = 0;

            alglib.mannwhitneyutest(grp1Vals.ToArray(), grp1Vals.Count, grp2Vals.ToArray(), grp2Vals.Count, out bt, out lt, out rt);

            double tbt = 0; double tlt = 0; double trt = 0;

            alglib.studentttest2(grp1Vals.ToArray(), grp1Vals.Count, grp2Vals.ToArray(), grp2Vals.Count, out tbt, out tlt, out trt);

            GrpDiff = (grp1Vals.Average() - grp2Vals.Average()).ToString("0.0000");
            PValue  = "p" + tbt.ToString("0.0000") + " u" + bt.ToString("0.0000");

            var model = new PlotModel()
            {
                IsLegendVisible = false
            };

            model.PlotMargins = new OxyThickness(0, 0, 0, 0);

            model.Axes.Add(new CategoryAxis("", "Group 1", "Group 2"));
            model.Axes.Add(new LinearAxis(AxisPosition.Left)
            {
                MinimumPadding = 0.1, MaximumPadding = 0.1, IntervalLength = 20
            });

            var s1 = new BoxPlotSeries
            {
                Title           = "BoxPlotSeries",
                Fill            = OxyColors.White,
                Stroke          = OxyColors.DarkBlue,
                StrokeThickness = 2,
                OutlierSize     = 2,
                BoxWidth        = 0.4
            };

            s1.Items.Add(MakeBoxPlotItem(0, grp1Vals));
            s1.Items.Add(MakeBoxPlotItem(1, grp2Vals));

            model.Series.Add(s1);
            GlobalPlotModel = model;
        }
 public PlotModel createBoxPlotModel(List<double[]> data, String[] varnames, String title)
 {
     if ((data == null) || (varnames == null))
     {
         return null;
     }
     int nv = data.Count;
     if ((nv < 1) || (varnames.Length < nv))
     {
         return null;
     }
     PlotModel model = null;
     try
     {
         String sText = "";
         for (int i = 0; i < nv; ++i)
         {
             if (i > 0)
             {
                 sText += ", " + varnames[i];
             }
             else
             {
                 sText = varnames[i];
             }
         }// i
         model = new PlotModel(sText) { LegendPlacement = LegendPlacement.Outside };
         var s1 = new BoxPlotSeries { Title = title, BoxWidth = 0.3 };
         double x = 0;
         foreach (var vv in data)
         {
             if (vv == null)
             {
                 continue;
             }
             List<double> values = vv.ToList();
             values.Sort();
             var median = GetMedian(values, false);
             int r = values.Count % 2;
             double firstQuartil = GetMedian(values.Take((values.Count + r) / 2), false);
             double thirdQuartil = GetMedian(values.Skip((values.Count - r) / 2), false);
             var iqr = thirdQuartil - firstQuartil;
             var step = iqr * 1.5;
             var upperWhisker = thirdQuartil + step;
             upperWhisker = values.Where(v => v <= upperWhisker).Max();
             var lowerWhisker = firstQuartil - step;
             lowerWhisker = values.Where(v => v >= lowerWhisker).Min();
             var outliers = values.Where(v => v > upperWhisker || v < lowerWhisker).ToList();
             s1.Items.Add(new BoxPlotItem(x, lowerWhisker, firstQuartil, median, thirdQuartil, upperWhisker, outliers));
             ++x;
         }// ivar
         model.Series.Add(s1);
         model.Axes.Add(new LinearAxis(AxisPosition.Left));
         model.Axes.Add(new LinearAxis(AxisPosition.Bottom) { MinimumPadding = 0.1, MaximumPadding = 0.1 });
     }
     catch (Exception /* ex */)
     {
     }
     return model;
 }