Creating a CrossTab from the Barley Data

Tables are often used very effectively in combination with other charts to add summarized information. For example a plot of a stock price might include a small table of the low and high values for the past year, and maybe a comparison with the industry sector.

The barley-yield data from the Boxplot tutorial is a good candidate for a Cross-tab. The two methods that do this are GroupBy (to collect data into the rows) and SplitBy to spread the values across the columns.

Here it has been summarised by Variety and categorised by Year as a 2-way table. You can summarize or split by up to 2 levels here to create more complex tabulations.

Table3
SharpPlot sp = new SharpPlot();
sp.Heading = "Barley Crosstab";

sp.SplitBy(barleyfarm);
sp.GroupBy(barleyvariety,GroupByFunction.Average);

sp.TableStyle = TableStyles.GridLines;

sp.XLabelFormat = "xxxxxxxxx;";
sp.YCaption = "Average Yield";

sp.ValueTagFormat = "##0.00";
sp.ValueTagStyle = ValueTagStyles.Center;

sp.DrawTable(yield);

See also

Table1 Table2 Table3 Table4