How to | Format a Table of Data
Not only can the Wolfram Language perform very complicated data analysis, it can also display these results in a formatted, easy-to-read display that can be used in other documents or presentations. One of the most useful ways to format data is with a table.
First, import some data to work with:
data = Import["ExampleData/classification.tsv"]Put all this information in a table:
Grid[data]Align the text on the left and put extra space between the columns and rows:
Grid[data, Alignment -> Left, Spacings -> {2, 1}]Add a frame and use "Text" as the style for each item:
Grid[data, Alignment -> Left, Spacings -> {2, 1}, Frame -> All, ItemStyle -> "Text"]Emphasize the row and column headings with different backgrounds:
Grid[data, Alignment -> Left, Spacings -> {2, 1}, Frame -> All, ItemStyle -> "Text", Background -> {{Gray, None}, {LightGray, None}}]Any expression can appear as part of a table of data, including graphics:
Grid[{
{"Sine", Plot[Sin[x], {x, -10, 10}, ImageSize -> Small]},
{"Cosine", Plot[Cos[x], {x, -10, 10}, ImageSize -> Small]},
{"Tangent", Plot[Tan[x], {x, -10, 10}, ImageSize -> Small]}}, Frame -> All]Individual items can be made to span multiple rows, columns, or both by using SpanFromLeft, SpanFromAbove, or SpanFromBoth:
Grid[{
{"Plots of Common Trigonometric Functions", SpanFromLeft},
{"Sine", Plot[Sin[x], {x, -10, 10}, ImageSize -> Small]},
{"Cosine", Plot[Cos[x], {x, -10, 10}, ImageSize -> Small]},
{"Tangent", Plot[Tan[x], {x, -10, 10}, ImageSize -> Small]}}, Frame -> All]