Changeset 14511 for branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs
- Timestamp:
- 12/20/16 15:28:14 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing Enhancements/HeuristicLab.DataPreprocessing/3.4/Content/ScatterPlotContent.cs
r14495 r14511 42 42 ScatterPlot scatterPlot = new ScatterPlot(); 43 43 44 IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)) .Where(x => !double.IsNaN(x) && !double.IsInfinity(x)).ToList();45 IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)) .Where(x => !double.IsNaN(x) && !double.IsInfinity(x)).ToList();44 IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX)); 45 IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY)); 46 46 47 if (xValues.Any()) { 47 var points = xValues.Zip(yValues, (x, y) => new Point2D<double>(x, y)).ToList(); 48 var validPoints = points.Where(p => !double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsInfinity(p.X) && !double.IsInfinity(p.Y)).ToList(); 49 if (validPoints.Any()) { 48 50 try { 49 51 double axisMin, axisMax, axisInterval; 50 ChartUtil.CalculateOptimalAxisInterval( xValues.Min(), xValues.Max(), out axisMin, out axisMax, out axisInterval);52 ChartUtil.CalculateOptimalAxisInterval(validPoints.Min(p => p.X), validPoints.Max(p => p.X), out axisMin, out axisMax, out axisInterval); 51 53 scatterPlot.VisualProperties.XAxisMinimumAuto = false; 52 54 scatterPlot.VisualProperties.XAxisMaximumAuto = false; … … 54 56 scatterPlot.VisualProperties.XAxisMaximumFixedValue = axisMax; 55 57 } catch (ArgumentOutOfRangeException) { } // error during CalculateOptimalAxisInterval 56 }57 if (yValues.Any()) {58 58 try { 59 59 double axisMin, axisMax, axisInterval; 60 ChartUtil.CalculateOptimalAxisInterval( yValues.Min(), yValues.Max(), out axisMin, out axisMax, out axisInterval);60 ChartUtil.CalculateOptimalAxisInterval(validPoints.Min(p => p.Y), validPoints.Max(p => p.Y), out axisMin, out axisMax, out axisInterval); 61 61 scatterPlot.VisualProperties.YAxisMinimumAuto = false; 62 62 scatterPlot.VisualProperties.YAxisMaximumAuto = false; … … 67 67 68 68 if (variableNameGroup == null || variableNameGroup == "-") { 69 List<Point2D<double>> points = new List<Point2D<double>>(); 70 71 for (int i = 0; i < xValues.Count; i++) { 72 Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]); 73 points.Add(point); 74 } 75 76 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points); 69 ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", validPoints); 77 70 scdr.VisualProperties.IsVisibleInLegend = false; 78 71 scatterPlot.Rows.Add(scdr); 79 80 72 } else { 81 73 var groupValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameGroup)); 82 var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(groupValues, (v, c) => new { v.x, v.y, c }).ToList();74 var data = points.Zip(groupValues, (p, g) => new { p, g }); 83 75 foreach (var groupValue in groupValues.Distinct()) { 84 var values = data.Where(x => x.c == groupValue); 85 var row = new ScatterPlotDataRow( 86 variableNameGroup + " (" + groupValue + ")", 87 "", 88 values.Select(v => new Point2D<double>(v.x, v.y))) { 76 var values = data.Where(x => x.g == groupValue).Select(v => v.p); 77 var row = new ScatterPlotDataRow(string.Format("{0} ({1})", variableNameGroup, groupValue), "", values) { 89 78 VisualProperties = { PointSize = 6 } 90 79 };
Note: See TracChangeset
for help on using the changeset viewer.