示例#1
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var f         = new ThreeSigmaOutliersFinder(_points.Select(p => p.Y));
            var outliersY = f.Find();

            f = new ThreeSigmaOutliersFinder(_points.Select(p => p.X));
            var outliersX = f.Find();

            _points = new ScatterPointCollection(_points.Where(p => outliersY.Contains(p.Y) == false));
            _points = new ScatterPointCollection(_points.Where(p => outliersX.Contains(p.X) == false));

            ResetCanvas();
            Draw();
        }
示例#2
0
        private void DrawPoints(ScatterPointCollection points, bool drawOutliers)
        {
            IEnumerable <double> outliersY = new Double[0];
            IEnumerable <double> outliersX = new Double[0];

            if (drawOutliers)
            {
                var f = new ThreeSigmaOutliersFinder(points.Select(p => p.Y));
                outliersY = f.Find();
                f         = new ThreeSigmaOutliersFinder(points.Select(p => p.X));
                outliersX = f.Find();
            }

            var calculator = new ScatterplotCalculator(points);

            foreach (var p in points)
            {
                var color = new ColorPicker().Pick(p.Group);
                var brush = new SolidColorBrush(color);

                var ellipse = new Ellipse()
                {
                    Fill = brush, Height = 10, Width = 10
                };

                if (Math.Abs(p.SubGroup) > 1)
                {
                    ellipse.Stroke          = new SolidColorBrush(new ColorPicker().RevertColor(color));
                    ellipse.StrokeThickness = 2;
                }

                if (outliersY.Contains(p.Y))
                {
                    ellipse.Height = 20;
                    ellipse.Width  = 20;
                }

                if (outliersX.Contains(p.X))
                {
                    ellipse.Height = 20;
                    ellipse.Width  = 20;
                }

                Canvas.SetLeft(ellipse, CanvasCalculator.GetX(p.X) - 5);
                Canvas.SetTop(ellipse, CanvasCalculator.GetY(p.Y) - 5);
                ellipse.DataContext = p;
                mainCanvas.Children.Add(ellipse);
            }
        }