protected override void Context() { base.Context(); _pdfFileName = "ScatterPlots"; _settings.DeleteWorkingDir = true; _settings.SaveArtifacts = true; _figureCounter = 0; var colors = new List <Color> { Color.Blue, Color.Red }; _objectsToReport.Add(new Chapter("Scatter Plots")); var axisOptions = getAxisOptions(); var plotOptions1 = getPlotOptions(Color.Blue.Name); var plotOptions2 = getPlotOptions(Color.Red.Name); var coordinatesMale = new List <Coordinate> { new Coordinate(0F, 5F), new Coordinate(2F, 15F), new Coordinate(4F, 8F), new Coordinate(7F, 4F), new Coordinate(12F, 24F) }; var coordinatesFemale = new List <Coordinate> { new Coordinate(0F, 10F), new Coordinate(2F, 12F), new Coordinate(0F, 11F), new Coordinate(3F, 9F), new Coordinate(6F, 8F), new Coordinate(7F, 7F), new Coordinate(14F, 27F) }; var boxplot1 = new Plot(coordinatesMale, plotOptions1) { LegendEntry = "Male" }; var boxplot2 = new Plot(coordinatesFemale, plotOptions2) { LegendEntry = "Female" }; var plotItem = new TeXReporting.Items.Plot(colors, axisOptions, new List <Plot> { boxplot1, boxplot2 }, new Text("Test Figure")); _objectsToReport.Add(new Section("Simple Scatter Plot")); _objectsToReport.Add(plotItem); _figureCounter++; }
private static TEXPlot createLegendPlotBasedOn(TEXPlot plot) { var dummyOptions = plot.Options.Clone(); dummyOptions.IsLegendPlot = true; dummyOptions.ShowInLegend = true; return(new TEXPlot(new List <Coordinate>(), dummyOptions) { LegendEntry = plot.LegendEntry }); }
private static GroupPlot getGroupPlot(List <Color> colors, LegendOptions.LegendPositions legendPosition, int columns) { var axisOptionsForGroup = getAxisOptionsForGroup(); var plotOptions1 = getBoxPlotOptions(15F, 20F, 25F, 30F, 35F, 1F, Color.Blue.Name); var plotOptions2 = getBoxPlotOptions(26F, 31F, 34F, 41F, 44F, 1F, Color.Red.Name); var plotOptions3 = getBoxPlotOptions(18F, 22F, 27F, 32F, 38F, 2F, Color.Blue.Name); var plotOptions4 = getBoxPlotOptions(27F, 31F, 35F, 39F, 47F, 2F, Color.Red.Name); var coordinates = new List <Coordinate> { new Coordinate(0F, 5F) }; var boxplot1 = new Plot(coordinates, plotOptions1); var boxplot2 = new Plot(coordinates, plotOptions2); var boxplot3 = new Plot(new List <Coordinate>(), plotOptions3); var boxplot4 = new Plot(new List <Coordinate>(), plotOptions4); var groupOptions = getGroupOptions(legendPosition, columns); var groupedPlots = new List <IBasePlot>(); var plots = new List <Plot> { boxplot1, boxplot2, boxplot3, boxplot4 }; var axisOptionsForPlotWithoutGroupLines = getAxisOptionsForPlot(); var axisOptionsForPlot = getAxisOptionsForPlot(); axisOptionsForPlot.GroupLines.Add(new AxisOptions.GroupLine(1F, 2F, "All", 1)); axisOptionsForPlot.GroupLines.Add(new AxisOptions.GroupLine(1F, 2F, "Total", 2)); var groupedPlot1 = new BasePlot(new AxisOptions(NoConverter.Instance) { IsEmptyGroupPlot = true }, new List <Plot>()); var groupedPlot2 = new BasePlot(axisOptionsForPlotWithoutGroupLines, plots); var groupedPlot3 = new BasePlot(axisOptionsForPlot, plots); groupedPlots.Add(groupedPlot1); groupedPlots.Add(groupedPlot2); groupedPlots.Add(groupedPlot3); groupedPlots.Add(groupedPlot3); var plotItem = new GroupPlot(colors, axisOptionsForGroup, groupOptions, groupedPlots, new Text("Test Figure With Grouped Plots")) { Position = FigureWriter.FigurePositions.H }; return(plotItem); }
protected override void Context() { base.Context(); _pdfFileName = "BoxPlots"; _settings.DeleteWorkingDir = true; _settings.SaveArtifacts = true; _figureCounter = 0; var colors = new List <Color> { Color.Blue, Color.Red }; _objectsToReport.Add(new Chapter("Box Plots")); var axisOptions = getAxisOptions(); var plotOptions1 = getBoxWhiskerPlotOptions(15F, 20F, 25F, 30F, 35F, 1F, Color.Blue.Name); var plotOptions2 = getBoxWhiskerPlotOptions(26F, 31F, 34F, 41F, 44F, 1F, Color.Red.Name); var plotOptions3 = getBoxWhiskerPlotOptions(18F, 22F, 27F, 32F, 38F, 2F, Color.Blue.Name); var plotOptions4 = getBoxWhiskerPlotOptions(27F, 31F, 35F, 39F, 47F, 2F, Color.Red.Name); var coordinates = new List <Coordinate> { new Coordinate(0F, 5F) }; var boxplot1 = new Plot(coordinates, plotOptions1) { LegendEntry = "Male" }; var boxplot2 = new Plot(coordinates, plotOptions2) { LegendEntry = "Female" }; var boxplot3 = new Plot(new List <Coordinate>(), plotOptions3); var boxplot4 = new Plot(new List <Coordinate>(), plotOptions4); var plotItem = new TeXReporting.Items.Plot(colors, axisOptions, new List <Plot> { boxplot1, boxplot2, boxplot3, boxplot4 }, new Text("Test Figure")); _objectsToReport.Add(new Section("Simple Box Plot")); _objectsToReport.Add(plotItem); _figureCounter++; }
private void PlotFigures(string chapterName, List <Coordinate> coordinates, Text chapterTitle = null) { if (chapterTitle == null) { chapterTitle = new Text(chapterName); } _objectsToReport.Add(new Chapter(chapterName, chapterTitle)); var colors = new List <Color>() { Color.Blue, Color.Red }; var axisOptions = new AxisOptions(NoConverter.Instance) { Title = "Test Title", XLabel = "X Axis", YLabel = "Y Axis", YMode = AxisOptions.AxisMode.log, LogTicksWithFixedPoint = true, XAxisPosition = AxisOptions.AxisXLine.bottom, YAxisPosition = AxisOptions.AxisYLine.left, LegendOptions = new LegendOptions { LegendPosition = LegendOptions.LegendPositions.NorthWest }, YMajorGrid = true }; var plotOptions1 = new PlotOptions { LineStyle = PlotOptions.LineStyles.Solid, Marker = PlotOptions.Markers.Triangle, Color = Color.Blue.Name, ErrorBars = true, ShadedErrorBars = true, Thickness = PlotOptions.Thicknesses.UltraThick }; var plot1 = new Plot(coordinates, plotOptions1) { LegendEntry = "legend entry 1" }; var plotItem = new TeXReporting.Items.Plot(colors, axisOptions, new List <Plot> { plot1 }, new Text("Test Figure")); var plotOptions2 = new PlotOptions { LineStyle = PlotOptions.LineStyles.DashDotted, Marker = PlotOptions.Markers.Circle, Color = Color.Red.Name, ErrorBars = true, ThicknessSize = Helper.Length(2, Helper.MeasurementUnits.pt), MarkSize = Helper.Length(3, Helper.MeasurementUnits.pt), MarkColor = Color.Blue.Name, MarkFillColor = String.Format("{0}!{1}", Color.Blue.Name, 20) }; var plot2 = new Plot(coordinates, plotOptions2) { LegendEntry = "0123456789 0123456789 0123456789 0123456789 0123456789 0123456789" }; var plotItem2 = new TeXReporting.Items.Plot(colors, axisOptions, new List <Plot> { plot2 }, new Text("Test Figure 2")); // Two Ordinates Plot var axisOptionsY1 = new AxisOptions(NoConverter.Instance) { EnlargeLimits = true, Title = "Test Title", XLabel = "X Axis", YLabel = "Y Axis", YMin = 0, XTickMin = 2F, XTickMax = 3F, MinorXTickNum = 1, MinorYTickNum = 1, BackgroundColor = "blue!10", YMode = AxisOptions.AxisMode.normal, XAxisPosition = AxisOptions.AxisXLine.bottom, YAxisPosition = AxisOptions.AxisYLine.left, YMajorGrid = true }; var axisOptionsY2 = new AxisOptions(DefaultConverter.Instance) { YLabel = "Y2 Axis", YAxisPosition = AxisOptions.AxisYLine.right, YAxisArrow = false, YScaledTicks = false, YMode = AxisOptions.AxisMode.log, LegendOptions = new LegendOptions { FontSize = LegendOptions.FontSizes.scriptsize, LegendAlignment = LegendOptions.LegendAlignments.left, LegendPosition = LegendOptions.LegendPositions.OuterNorthWest, RoundedCorners = true, Columns = 1, //TextWidth = Helper.GetWidthInPercentageOfTextWidth(30) }, XAxisPosition = AxisOptions.AxisXLine.none }; var plotTwoOrdinates = new PlotTwoOrdinates(colors, axisOptionsY1, new List <Plot> { plot1 }, axisOptionsY2, new List <Plot> { plot2 }, new Text("Test Two Ordinates")); var axisOptionsY3 = new AxisOptions(DefaultConverter.Instance) { YLabel = "Y3 Axis", YAxisPosition = AxisOptions.AxisYLine.right, YAxisArrow = false, YScaledTicks = true, YMin = 0, YDiscontinuity = AxisOptions.Discontinuities.parallel, YMode = AxisOptions.AxisMode.normal, LegendOptions = new LegendOptions { FontSize = LegendOptions.FontSizes.scriptsize, LegendAlignment = LegendOptions.LegendAlignments.left, LegendPosition = LegendOptions.LegendPositions.OuterNorthEast, RoundedCorners = true, Columns = 1, //TextWidth = Helper.GetWidthInPercentageOfTextWidth(30) }, XAxisPosition = AxisOptions.AxisXLine.none }; var plot3 = new Plot(new List <Coordinate> { new Coordinate(2.5F, 5F) }, new PlotOptions { Marker = PlotOptions.Markers.Triangle }) { LegendEntry = "Points" }; var plotThreeOrdinates = new PlotThreeOrdinates(colors, axisOptionsY1, new List <Plot> { plot1 }, axisOptionsY2, new List <Plot> { plot2 }, axisOptionsY3, new List <Plot> { plot3 }, new Text("Test Three Ordinates")); _objectsToReport.Add(new Section("Simple Figure 1")); var axisOptionsNormal = new AxisOptions(NoConverter.Instance) { Title = "Test Title", XLabel = "X Axis", YLabel = "Y Axis", YMode = AxisOptions.AxisMode.normal, LogTicksWithFixedPoint = true, XAxisPosition = AxisOptions.AxisXLine.bottom, YAxisPosition = AxisOptions.AxisYLine.left, LegendOptions = new LegendOptions { LegendPosition = LegendOptions.LegendPositions.NorthWest }, YMajorGrid = true }; var plotItemNormal = new TeXReporting.Items.Plot(plotItem.Colors, axisOptionsNormal, plotItem.Plots, new Text("Test Figure with normal scaled Y-Axis")); _objectsToReport.Add(plotItemNormal); _figureCounter++; _objectsToReport.Add(new Section("Simple Figure 2")); _objectsToReport.Add(plotItem); _figureCounter++; _objectsToReport.Add(new Section("Simple Figure 3")); _objectsToReport.Add(plotItem2); _figureCounter++; _objectsToReport.Add(new Section("Two Ordinates Figure")); _objectsToReport.Add(plotTwoOrdinates); _figureCounter++; _objectsToReport.Add(new Section("Three Ordinates Figure")); _objectsToReport.Add(plotThreeOrdinates); _figureCounter++; }
protected override void Context() { base.Context(); _pdfFileName = "BarPlots"; _settings.DeleteWorkingDir = true; _settings.SaveArtifacts = true; _figureCounter = 0; var colors = new List <Color> { Color.Blue, Color.Red }; _objectsToReport.Add(new Chapter("Bar Plots")); var plotOptions1 = getPlotOptions(Color.Blue.Name); var plotOptions2 = getPlotOptions(Color.Red.Name); var coordinates1 = new List <Coordinate> { new Coordinate(1F, 5F), new Coordinate(2F, 10F), new Coordinate(3F, 5F) }; var barplot1 = new Plot(coordinates1, plotOptions1) { LegendEntry = "Male" }; var coordinates2 = new List <Coordinate> { new Coordinate(1F, 3F), new Coordinate(2F, 8F), new Coordinate(3F, 9F) }; var barplot2 = new Plot(coordinates2, plotOptions2) { LegendEntry = "Female" }; // simple bar plot var barPlotOptionsSideBySide = new BarPlotOptions { BarPlotType = BarPlotOptions.BarPlotTypes.SideBySide, Width = "0.45", Shift = Helper.Length(2, Helper.MeasurementUnits.pt), NodesNearCoords = true }; _objectsToReport.Add(new Section("Simple Bar Plot")); _objectsToReport.Add(new BarPlot(colors, getAxisOptions(LegendOptions.LegendPositions.OuterNorthEast), barPlotOptionsSideBySide, new List <Plot> { barplot1, barplot2 }, new Text("Test Figure"))); _figureCounter++; _objectsToReport.Add(new Section("Simple Bar Plot With Legend Inside")); _objectsToReport.Add(new BarPlot(colors, getAxisOptions(LegendOptions.LegendPositions.NorthEast), barPlotOptionsSideBySide, new List <Plot> { barplot1, barplot2 }, new Text("Test Figure"))); _figureCounter++; // simple stacked bar plot var barPlotOptionsStacked = new BarPlotOptions { BarPlotType = BarPlotOptions.BarPlotTypes.Stacked, Width = "0.9" }; _objectsToReport.Add(new Section("Simple Stacked Bar Plot")); _objectsToReport.Add(new BarPlot(colors, getAxisOptions(LegendOptions.LegendPositions.OuterNorthEast), barPlotOptionsStacked, new List <Plot> { barplot1, barplot2 }, new Text("Test Figure"))); _figureCounter++; _objectsToReport.Add(new Section("Simple Stacked Bar Plot With Legend Inside")); _objectsToReport.Add(new BarPlot(colors, getAxisOptions(LegendOptions.LegendPositions.NorthEast), barPlotOptionsStacked, new List <Plot> { barplot1, barplot2 }, new Text("Test Figure"))); _figureCounter++; // simple interval bar plot var barPlotOptionsInterval = new BarPlotOptions { BarPlotType = BarPlotOptions.BarPlotTypes.Interval, TickLabelIntervalBoundaries = true }; // add dummy coordinate var coordinatesInt1 = new List <Coordinate>(coordinates1); var coordinatesInt2 = new List <Coordinate>(coordinates2); coordinatesInt1.Add(new Coordinate(4F, 0F)); coordinatesInt2.Add(new Coordinate(4F, 0F)); var barplotInt1 = new Plot(coordinatesInt1, plotOptions1) { LegendEntry = "Male" }; var barplotInt2 = new Plot(coordinatesInt2, plotOptions2) { LegendEntry = "Female" }; _objectsToReport.Add(new Section("Simple Interval Bar Plot")); _objectsToReport.Add(new BarPlot(colors, getAxisOptionsForInterval(LegendOptions.LegendPositions.OuterNorthEast), barPlotOptionsInterval, new List <Plot> { barplotInt1, barplotInt2 }, new Text("Test Figure"))); _figureCounter++; _objectsToReport.Add(new Section("Simple Interval Bar Plot With Legend Inside")); _objectsToReport.Add(new BarPlot(colors, getAxisOptionsForInterval(LegendOptions.LegendPositions.NorthEast), barPlotOptionsInterval, new List <Plot> { barplotInt1, barplotInt2 }, new Text("Test Figure"))); _figureCounter++; // simple stacked interval bar plot var barPlotOptionsIntervalStacked = new BarPlotOptions { BarPlotType = BarPlotOptions.BarPlotTypes.IntervalStacked, TickLabelIntervalBoundaries = true }; _objectsToReport.Add(new Section("Simple Stacked Interval Bar Plot")); _objectsToReport.Add(new BarPlot(colors, getAxisOptionsForInterval(LegendOptions.LegendPositions.OuterNorthEast), barPlotOptionsIntervalStacked, new List <Plot> { barplotInt1, barplotInt2 }, new Text("Test Figure"))); _figureCounter++; _objectsToReport.Add(new Section("Simple Stacked Interval Bar Plot With Legend Inside")); _objectsToReport.Add(new BarPlot(colors, getAxisOptionsForInterval(LegendOptions.LegendPositions.NorthEast), barPlotOptionsIntervalStacked, new List <Plot> { barplotInt1, barplotInt2 }, new Text("Test Figure"))); _figureCounter++; }
private List <Plot> getPlots(CurveChart chart, AxisTypes yAxisType) { var plots = new List <Plot>(); var xAxis = chart.Axes.First(x => x.AxisType == AxisTypes.X); var yAxis = chart.Axes.First(x => x.AxisType == yAxisType); var xUnit = xAxis.Dimension.Unit(xAxis.UnitName); var yUnit = yAxis.Dimension.Unit(yAxis.UnitName); foreach (var curve in chart.Curves) { if (!curve.Visible) { continue; } if (curve.yAxisType != yAxisType) { continue; } if (!isCurveCompatibleToYAxis(curve, yAxis)) { continue; } var coordinates = new List <Coordinate>(); var plotOptions = new PlotOptions(); DataColumn geometricErr = null; if (curve.yData.ContainsRelatedColumn(AuxiliaryType.GeometricStdDev)) { geometricErr = curve.yData.GetRelatedColumn(AuxiliaryType.GeometricStdDev); plotOptions.ErrorBars = true; plotOptions.ErrorType = PlotOptions.ErrorTypes.geometric; } DataColumn arithmeticErr = null; IDimension arithmeticErrDim = null; if (curve.yData.ContainsRelatedColumn(AuxiliaryType.ArithmeticStdDev)) { arithmeticErr = curve.yData.GetRelatedColumn(AuxiliaryType.ArithmeticStdDev); arithmeticErrDim = _dimensionFactory.MergedDimensionFor(arithmeticErr); plotOptions.ErrorBars = true; plotOptions.ErrorType = PlotOptions.ErrorTypes.arithmetic; } DataColumn geometricMeanPop = null; IDimension geometricMeanPopDim = null; if (curve.yData.ContainsRelatedColumn(AuxiliaryType.GeometricMeanPop)) { geometricMeanPop = curve.yData.GetRelatedColumn(AuxiliaryType.GeometricMeanPop); geometricMeanPopDim = _dimensionFactory.MergedDimensionFor(geometricMeanPop); plotOptions.ErrorBars = false; plotOptions.ErrorType = PlotOptions.ErrorTypes.geometric; plotOptions.ShadedErrorBars = true; plotOptions.Opacity = getOpacityFor(Constants.RANGE_AREA_OPACITY); } DataColumn arithmeticMeanPop = null; IDimension arithmeticMeanPopDim = null; if (curve.yData.ContainsRelatedColumn(AuxiliaryType.ArithmeticMeanPop)) { arithmeticMeanPop = curve.yData.GetRelatedColumn(AuxiliaryType.ArithmeticMeanPop); arithmeticMeanPopDim = _dimensionFactory.MergedDimensionFor(arithmeticMeanPop); plotOptions.ErrorBars = false; plotOptions.ErrorType = PlotOptions.ErrorTypes.arithmetic; plotOptions.ShadedErrorBars = true; plotOptions.Opacity = getOpacityFor(Constants.RANGE_AREA_OPACITY); } plotOptions.Color = curve.Color.Name; plotOptions.ThicknessSize = Helper.Length(convertLineThickness(curve.LineThickness), Helper.MeasurementUnits.pt); plotOptions.MarkSize = Helper.Length(convertLineThickness(curve.LineThickness), Helper.MeasurementUnits.pt); plotOptions.Marker = getMarker(curve.Symbol); plotOptions.LineStyle = getLineStyle(curve.LineStyle); IDimension xDimension = _dimensionFactory.MergedDimensionFor(curve.xData); IDimension yDimension = _dimensionFactory.MergedDimensionFor(curve.yData); for (var i = 0; i < curve.xData.Values.Count; i++) { var xValue = convertToUnit(xUnit, xDimension, curve.xData.Values[i]); var yValue = convertToUnit(yUnit, yDimension, curve.yData.Values[i]); var coordinate = new Coordinate(xValue, yValue); if (geometricMeanPop != null) { var yError = curve.yData.Values[i]; yValue = convertToUnit(yUnit, geometricMeanPopDim, geometricMeanPop.Values[i]); coordinate = new Coordinate(coordinate.X, yValue) { errY = yError }; } if (arithmeticMeanPop != null) { var yError = yValue; yValue = convertToUnit(yUnit, arithmeticMeanPopDim, arithmeticMeanPop.Values[i]); coordinate = new Coordinate(coordinate.X, yValue) { errY = yError }; } if (geometricErr != null) { coordinate.errY = geometricErr.Values[i]; } if (arithmeticErr != null) { coordinate.errY = convertToUnit(yUnit, arithmeticErrDim, arithmeticErr.Values[i]); } if (xAxis.NumberMode == NumberModes.Relative) { var max = curve.xData.Values.Max(); max = convertToUnit(xUnit, xDimension, max); coordinate = new Coordinate(coordinate.X / max * 100, coordinate.Y) { errY = coordinate.errY }; } if (yAxis.NumberMode == NumberModes.Relative) { var max = curve.yData.Values.Max(); if (geometricMeanPop != null) { max = geometricMeanPop.Values.Max(); max = convertToUnit(yUnit, geometricMeanPopDim, max); } if (arithmeticMeanPop != null) { max = arithmeticMeanPop.Values.Max(); max = convertToUnit(yUnit, arithmeticMeanPopDim, max); } coordinate = new Coordinate(coordinate.X, coordinate.Y / max * 100) { errY = coordinate.errY == null ? null : (arithmeticErr != null | arithmeticMeanPop != null) ? coordinate.errY / max * 100 : coordinate.errY }; } coordinates.Add(coordinate); } var plot = new Plot(coordinates, plotOptions) { LegendEntry = curve.Name }; // if all coordinates are nan, no plot can be created, so skip this plot if (!coordinates.All(c => float.IsNaN(c.X)) && !coordinates.All(c => float.IsNaN(c.Y))) { plots.Add(plot); } } return(plots); }
protected override void Context() { base.Context(); _pdfFileName = "RangePlots"; _settings.DeleteWorkingDir = true; _settings.SaveArtifacts = true; _figureCounter = 0; var colors = new List <Color> { Color.Blue, Color.Red }; _objectsToReport.Add(new Chapter("Range Plots")); var axisOptions = getAxisOptions(); var coordinatesMale = new List <Coordinate> { new Coordinate(0F, 5F) { errY = 0.4F, errY2 = 0.5F }, new Coordinate(2F, 15F) { errY = 0.4F, errY2 = 0.1F }, new Coordinate(4F, 8F) { errY = 1.4F, errY2 = 1.5F }, new Coordinate(7F, 4F) { errY = 0.4F, errY2 = 0.2F }, new Coordinate(12F, 24F) { errY = 0.4F, errY2 = 0.5F } }; var coordinatesFemale = new List <Coordinate> { new Coordinate(0F, 10F) { errY = 0.4F, errY2 = 0.5F }, new Coordinate(2F, 12F) { errY = 1.4F, errY2 = 1.3F }, new Coordinate(4F, 11F) { errY = 2.4F, errY2 = 1.5F }, new Coordinate(5F, 9F) { errY = 0.8F, errY2 = 0.7F }, new Coordinate(6F, 8F) { errY = 0.4F, errY2 = 0.1F }, new Coordinate(7F, 7F) { errY = 0.4F, errY2 = 0.1F }, new Coordinate(14F, 27F) { errY = 3.4F, errY2 = 2.5F } }; var plotRangeMale = new Plot(coordinatesMale, getPlotOptions(Color.Blue.Name, true, false)); var plotMale = new Plot(coordinatesMale, getPlotOptions(Color.Blue.Name, false, true)) { LegendEntry = "Male" }; var plotRangeFemale = new Plot(coordinatesFemale, getPlotOptions(Color.Red.Name, true, false)); var plotFemale = new Plot(coordinatesFemale, getPlotOptions(Color.Red.Name, false, true)) { LegendEntry = "Female" }; var plotItem = new TeXReporting.Items.Plot(colors, axisOptions, new List <Plot> { plotRangeMale, plotMale, plotRangeFemale, plotFemale }, new Text("Test Figure")); _objectsToReport.Add(new Section("Simple Range Plot")); _objectsToReport.Add(plotItem); _figureCounter++; }