DocumentTools
Tabulate
insert a worksheet Table from a Matrix, Vector, Array, DataFrame, record, list, or list of lists
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Tabulate( M, opts )
M
-
{Array,Matrix,Vector,DataFrame,list,list(list),record}
opts
(optional) ; one or more keyword options as described below
alignment: identical(left,right,center):=center ; The horizontal alignment of the Table in the worksheet. The default value is center.
color: {list(nonnegint),symbol,string,appliable}:=[0,0,0] ; The foreground color for text. The passed value can be either a specified color acceptable to ColorTools:-Color, or a procedure which returns such. A list of nonnegative integers is interpreted as RGB values in a 24-bit 3-channel color space. In the case of a supplied procedure the passed arguments will be M, i, j for the cell in row i and column j. The default value is [0,0,0] which corresponds to black.
exterior: identical(all,none):=all ; Indicates how exterior borders are shown.
fillcolor: {list(nonnegint),symbol,string,appliable}:=[255,255,255] ; The background fill color for the Table cells. The passed value can be either a specified color acceptable to ColorTools:-Color, or a procedure which returns such. A list of nonnegative integers is interpreted as RGB values in a 24-bit 3-channel color space. In the case of a supplied procedure the passed arguments will be M, i, j for the cell in row i and column j. If the first argument to Tabulate is not a DataFrame then the default value for fillcolor is [255,255,255] which corresponds to white. If the first argument to Tabulate is a DataFrame then the default value for fillcolor is a procedure which returns [210,230,255] for the first column or row, and [255,255,235] otherwise.
interior: identical(all,none):=all ; Indicates how internal borders are shown.
output: identical(XML,inline); Specifies whether to insert the formatted output or return the raw XML structure.
plotcomponents: truefalse ; Indicates whether plots are inserted within Plot Components. The default is false. When this option is false plot entries that are not part of expression sequences are inlined within individual Table cells.
recordformat: identical(table,section); Specifies the layout format used for records
typesetting: identical(standard,extended); Specifies the typesetting level. By default the current value returned by interface(typesetting) is used.
weights: {list(nonnegint),Vector(nonnegint)} ; Relative weights for the Table's columns' widths. By default all columns have equal weight.
width: And(realcons,nonnegative):=100.0 ; Indicates the displayed width of the Table as a percentage of the worksheet's width in the case of option widthmode=percentage, or as the number or pixels in the case that option widthmode=pixels. The default is 100% of the displayed worksheet's width.
widthmode: identical(percentage,pixels):=percentage ; Whether the width option's value is interpreted as a percentage of the worksheet's width or as a number of pixels.
The Tabulate command constructs and inserts a worksheet Table from a Matrix, Vector, one or two dimensional Array, DataFrame, list, or list of lists.
The return value of the command is the identity of the inserted parent Table, as a string. The display of the returned value can be suppressed by terminating the statement with a full colon.
Calls to the Tabulate command cannot be nested within each other unless used with the option output=XML and other DocumentTools commands to construct your own content.
Expressions are inserted as typeset 2-D Math, and can be operated upon using context-sensitive operations in the Context Panel.
The inserted Tables will be removed by the main menu action Edit->Remove Output. Pasted copies of the inserted Tables are not removed.
This command inserts the assembly of Tables and Embedded Components into the worksheet using the InsertContent facility. The inserted content is placed after any usual output of the Execution Group in which this command is called. Each Execution Group allows for only one inserted result to exist at any given time. Multiple calls to commands which utilize the InsertContent facility made within the same Execution Group will result in each successive inserted assembly replacing any assembly inserted earlier for that Execution Group.
with⁡DocumentTools:
By default the inserted Table takes 100% of the width of the worksheet.
Tabulate⁡a,b,c,d:
a
b
c
d
In the next example the width of the Table is 50% of the width of the worksheet. That width ratio is maintained when the worksheet is maximized or manually resized.
Tabulate⁡a,b,c,d,width=50:
Column Vectors produce a Table with entries stacked vertically.
Tabulate⁡Vectorcolumn⁡a,b,c,d,width=20:
The initial width can also be specified as pixels, under default zoom. In this case the Table will zoom along with the worksheet, under magnification.
M≔LinearAlgebra:-RandomMatrix⁡6,2
M≔
Tabulate⁡M,widthmode=pixels,width=100:
−32
99
−74
29
−4
44
27
92
8
−31
69
67
2-D and 3-D plot entries are inlined by default.
A≔plot⁡sin⁡xx,Sum⁡f⁡i,i=1..N,plot3d⁡y2⁢sin⁡x,x=−π..π,y=−2..2:
Tabulate⁡A,width=60:
∑i=1N⁡f⁡i
Plot entries can be inserted optionally within Plot Components, as opposed to being inlined.
Tabulate⁡A,width=60,plotcomponents:
The interior or exterior Table borders can optionally be hidden.
Tabulate⁡M,widthmode=pixels,width=100,exterior=none:
Tabulate⁡A,width=60,interior=none:
The fillcolor option can be used to specify a background fill color, including the case of 3-D plot entries.
Tabulate⁡plot3d⁡y2⁢sin⁡x,x=−π..π,y=−2..2,axis=color=cyan,orientation=55,75,0,fillcolor=black,width=400,widthmode=pixels:
The color option can be used to specify a foreground color.
Tabulate⁡Example text.,color=red,fillcolor=LightYellow,width=30:
Example text.
Tabulate⁡Example text.,color=#FF0000,fillcolor=LightYellow,width=30:
A≔LinearAlgebra:-RandomMatrix⁡3,4:header≔a|b|c|d:
Tabulate⁡header,A,width=40,`=`⁡fillcolor,T,i,jj↦`if`⁡i=1,cyan,white:
−38
33
57
−76
−18
−98
−72
87
−77
−93
−2
Tabulate⁡A,width=40,`=`⁡fillcolor,T,i,j↦`if`⁡irem⁡j,2=1,cyan,white:
P≔ColorTools:-GetPalette⁡css:T≔table⁡seq⁡ColorDescription⁡c=c,c=P,=ColorTools:-Color⁡White:M≔ArrayTools:-Reshape⁡Vector⁡indices⁡T,nolist,seq⁡,i=1..3⋅6−numelems⁡T,6,3%T
Tabulate⁡M,width=60,`=`⁡color,M,i,j↦`if`⁡0.4<Luma⁡TMi,j,Black,240,240,240,`=`⁡fillcolor,M,i,j↦ToRGB24⁡TMi,j:
Maroon
Green
Orange
Lime
White
Olive
Yellow
Silver
Red
Black
Teal
Blue
Navy
Fuchsia
Gray
Aqua
Purple
One additional level of nested lists is supported. Note that the middle entry in the following example is represented with an inner Table.
L≔Some text,y2⁢sin⁡x,x=−π..π,y=−2..2,plot3d⁡y2⁢sin⁡x,x=−π..π,y=−2..2:
Tabulate⁡L:
Some text
y2⁢sin⁡x
x=−π..π
y=−2..2
The Table can be inserted as left-aligned in the worksheet. The relative widths of the Table columns can be specified using the weights option.
Tabulate⁡L,width=60,alignment=left,weights=3,3,7:
The level of typesetting of expression entries can be forced.
Tabulate⁡π,Γ,sqrt⁡2,diff⁡f⁡x,x,BesselJ⁡0,x,width=50,typesetting=standard:
π
GAMMA
2
ⅆⅆx⁢f⁡x
BesselJ⁡0,x
Tabulate⁡π,Γ,sqrt⁡2,diff⁡f⁡x,x,BesselJ⁡0,x,width=40,typesetting=extended:
Γ
ⅆⅆxf⁡x
The fillcolor has a different default for a DataFrame, which can be overridden.
genus≔Rubus,Vitis,Fragaria:energy≔220,288,136:carbohydrates≔11.94,18.1,7.68:total_tons≔543421,58500118,4594539:top_producer≔Russia,China,USA:DF≔DataFrame⁡energy|carbohydrates|total_tons|top_producer|genus,columns=Energy,Carbohydrates,`Total Tons`,`Top Producer`,Genus,rows=Raspberry,Grape,Strawberry,datatypes=integer,float,integer,anything,string
DF≔
Tabulate⁡DF,width=600,widthmode=pixels:
Energy
Carbohydrates
Total Tons
Top Producer
Genus
Raspberry
220
11.9399999999999995
543421
Russia
Rubus
Grape
288
18.1000000000000014
58500118
China
Vitis
Strawberry
136
7.67999999999999972
4594539
USA
Fragaria
lens≔4+max⁡op⁡`~`length⁡RowLabels⁡DF,`~``+`⁡4,` $`,op⁡`~`length⁡ColumnLabels⁡DF:
Tabulate⁡DF,width=add⁡lens⋅6,widthmode=pixels,weights=lens,`=`⁡fillcolor,M,i,j↦`if`⁡i=1andj≠1,LightBlue,`if`⁡j=1andi≠1,LightGreen,White:
The Tabulate command provides an alternative to plots:-display as a mechanism for displaying Arrays of plots in a tabular form. In particular it provides the additional functionality to specify the visibility of Table borders and the Table dimensions and alignment.
A≔Array⁡plot⁡sin⁡x,x=−π..π,size=200,200,plot⁡sin⁡x,x=−π..π,size=200,200,scaling=constrained,plot⁡cos⁡x,x=−π..π,size=200,200,plot⁡cos⁡x,x=−π..π,size=200,200,scaling=constrained:
plots:-display⁡A
Tabulate⁡A,width=700,widthmode=pixels,interior=none:
The return value of the command is the identity of the inserted Table and this can be used to modify the Table after insertion.
A≔Array⁡plot⁡sin⁡x,x=−π..π,size=300,200,scaling=constrained,plot⁡cos⁡x,x=−π..π,size=300,200,scaling=constrained:
Tabulate⁡A,width=700,widthmode=pixels:
str1≔Tabulate⁡A,width=700,widthmode=pixels:
str1
Tabulate21
SetProperty⁡str1,exterior,none;SetProperty⁡str1,interior,none
The Tabulate command can format nested records
R≔Record⁡shape=cube,size,color:
R:-size≔Record⁡width=12,height=16,depth=8:
R:-color≔Record⁡R=CC,G=CC,B=EE:
Tabulate⁡R:
shape
cube
size
width
12
height
16
depth
color
R
CC
G
B
EE
Tabulate⁡R,recordformat=section:
The DocumentTools[Tabulate] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
The output and typesetting options were introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
The DocumentTools[Tabulate] command was updated in Maple 2018.
The M parameter was updated in Maple 2018.
The recordformat option was introduced in Maple 2018.
For more information on Maple 2018 changes, see Updates in Maple 2018.
See Also
Array
DataFrame
DataFrame:-Tabulate
list
Matrix
Plot Components
plot/arrayplot
Record
Table
Download Help Document