GridPlot - Maple Help

Statistics

 GridPlot
 generate a grid of plots

 Calling Sequence GridPlot( dataset, options, TabulateOptions )

Parameters

 dataset - Matrix or DataFrame containing 2 or more columns of values options - (optional) equation(s) of the form option=value, where option is one of upper, lower, diagonal, correlation, labels, or plotoptions TabulateOptions - options to be passed to the DocumentTools:-Tabulate command

Options

 • upper : name, procedure, list(procedure, anything); specifies the type of plot to use in the upper triangle of the grid of plots. The default is Statistics:-ScatterPlot. If this is set to none, the upper triangle is empty. If a procedure or Maple command is entered, the upper triangle is filled with the results of using the procedure on the ith and jth columns of data. If a procedure is entered as the first value of a list, subsequent arguments are passed to the procedure.
 • lower : name, procedure, list(procedure, anything); specifies the type of plot to use in the lower triangle of the grid of plots. The default is upper, which uses the same output as the upper triangle. If this is set to none, the lower triangle is empty. If a procedure or Maple command is entered, the lower triangle is filled with the results of using the procedure on the ith and jth columns of data. If a procedure is entered as the first value of a list, subsequent arguments are passed to the procedure.
 • diagonal : name, procedure, list(procedure, anything); specifies the type of plot or value to use on the diagonal of the grid of plots. The default is labels, which uses either the value of the labels option, the DataFrame column names, or a list of values corresponding to the column index value. If a procedure or Maple command is entered, the diagonal is filled with the results of using the procedure on the ith columns of data. In this case, labels are passed as titles to the procedure. If a procedure is entered as the first value of a list, subsequent arguments are passed to the procedure.
 • labels : list; a list of values corresponding to each of the columns of data. If the dataset is stored in a DataFrame, the labels are automatically generated using the column names and can be overridden using the labels option.
 • correlation : list(truefalse, truefalse, truefalse); A three element list containing truefalse values that specify if the values from the Statistics:-CorrelationMatrix command should be used. The default is [false, false, false]. The elements in the list correspond to using the values from the correlation matrix on [ upper, lower, diagonal ] respectively.
 • plotoptions : list(exprseq); A list containing optional arguments of the form, plot attribute = value, to be passed to all plots in GridPlot.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$

The GridPlot command can be used to look for patterns in higher dimensional datasets. In the following example, the columns of a sample data set are plotted against one another in order to look for possible correlation between the columns.

 > $\mathrm{data}≔\mathrm{Sample}\left(\mathrm{Uniform}\left(0,1\right),\left[50,3\right]\right):$
 > $\mathrm{GridPlot}\left(\mathrm{data}\right)$
 ${"Tabulate"}$ (1)

 $1$ $2$ $3$

Global plot options can be passed to all plots in the grid using plotoptions:

 > $\mathrm{GridPlot}\left(\mathrm{data},\mathrm{plotoptions}=\left[\mathrm{symbol}=\mathrm{solidbox},\mathrm{symbolsize}=20,\mathrm{color}="Orange"\right],\mathrm{width}=40\right)$
 ${"Tabulate0"}$ (2)

 $1$ $2$ $3$

The Iris dataset contains measurements in centimeters for several properties of 150 flowers from 3 species of iris. In the following example, the GridPlot command is used to look for patterns between the properties of the flowers.

In the following, the Iris data is imported into a DataFrame.

 > $\mathrm{IrisData}≔\mathrm{Import}\left("datasets/iris.csv",\mathrm{base}=\mathrm{datadir}\right)$
 ${\mathrm{DataFrame}}{}\left({{\mathrm{_rtable}}}_{{36893628743820710364}}{,}{\mathrm{rows}}{=}\left[{1}{,}{2}{,}{3}{,}{4}{,}{5}{,}{6}{,}{7}{,}{8}{,}{9}{,}{10}{,}{11}{,}{12}{,}{13}{,}{14}{,}{15}{,}{16}{,}{17}{,}{18}{,}{19}{,}{20}{,}{21}{,}{22}{,}{23}{,}{24}{,}{25}{,}{26}{,}{27}{,}{28}{,}{29}{,}{30}{,}{31}{,}{32}{,}{33}{,}{34}{,}{35}{,}{36}{,}{37}{,}{38}{,}{39}{,}{40}{,}{41}{,}{42}{,}{43}{,}{44}{,}{45}{,}{46}{,}{47}{,}{48}{,}{49}{,}{50}{,}{51}{,}{52}{,}{53}{,}{54}{,}{55}{,}{56}{,}{57}{,}{58}{,}{59}{,}{60}{,}{61}{,}{62}{,}{63}{,}{64}{,}{65}{,}{66}{,}{67}{,}{68}{,}{69}{,}{70}{,}{71}{,}{72}{,}{73}{,}{74}{,}{75}{,}{76}{,}{77}{,}{78}{,}{79}{,}{80}{,}{81}{,}{82}{,}{83}{,}{84}{,}{85}{,}{86}{,}{87}{,}{88}{,}{89}{,}{90}{,}{91}{,}{92}{,}{93}{,}{94}{,}{95}{,}{96}{,}{97}{,}{98}{,}{99}{,}{100}{,}{101}{,}{102}{,}{103}{,}{104}{,}{105}{,}{106}{,}{107}{,}{108}{,}{109}{,}{110}{,}{111}{,}{112}{,}{113}{,}{114}{,}{115}{,}{116}{,}{117}{,}{118}{,}{119}{,}{120}{,}{121}{,}{122}{,}{123}{,}{124}{,}{125}{,}{126}{,}{127}{,}{128}{,}{129}{,}{130}{,}{131}{,}{132}{,}{133}{,}{134}{,}{135}{,}{136}{,}{137}{,}{138}{,}{139}{,}{140}{,}{141}{,}{142}{,}{143}{,}{144}{,}{145}{,}{146}{,}{147}{,}{148}{,}{149}{,}{150}\right]{,}{\mathrm{columns}}{=}\left[{\mathrm{Sepal Length}}{,}{\mathrm{Sepal Width}}{,}{\mathrm{Petal Length}}{,}{\mathrm{Petal Width}}{,}{\mathrm{Species}}\right]\right)$ (3)

Since the data is stored in a DataFrame, the GridPlot command can automatically determine the labels for the diagonal of the grid from the column names. The upper and lower options control the types of plots to show on the upper triangle and lower triangle of the matrix respectively. The width option is passed to the DocumentTools:-Tabulate command, and controls the size of the resulting grid of plots.

 > $\mathrm{GridPlot}\left(\mathrm{IrisData}\left[1..4\right],\mathrm{upper}='\mathrm{ScatterPlot}',\mathrm{lower}=\left['\mathrm{AgglomeratedPlot}',\mathrm{color}="Crimson"\right],\mathrm{plotoptions}=\left[\mathrm{color}="Grey"\right],\mathrm{width}=600,\mathrm{widthmode}=\mathrm{pixels}\right)$
 ${"Tabulate1"}$ (4)

 $\mathrm{Sepal Length}$ $\mathrm{Sepal Width}$ $\mathrm{Petal Length}$ $\mathrm{Petal Width}$

Note that global plot options set by the plotoptions option can be locally overridden by specifying plot options in the upper, lower or diagonal arguments.

Additional options such as width and fillcolor are passed to the DocumentTools:-Tabulate command. This means that custom coloring can be applied to the cells of the grid of plots. In the following example, a custom coloring scheme is first created for the upper triangle of plots and passed to the plots:-pointplot command. Next, a custom coloring scheme is applied to the empty lower triangle of the grid that corresponds to a HeatMap for the CorrelationMatrix of the Iris dataset.

 > $\mathrm{SpeciesColors}≔\mathrm{map}\left(t↦\mathrm{piecewise}\left(t="setosa","DarkGreen",t="versicolor","MediumSlateBlue",t="virginica","MediumVioletRed"\right),\mathrm{convert}\left(\mathrm{IrisData}\left[\mathrm{Species}\right],\mathrm{Vector}\right)\right):$
 > $\mathrm{GridPlot}\left(\mathrm{IrisData}\left[1..4\right],\mathrm{upper}=\left['\mathrm{plots}:-\mathrm{pointplot}',\mathrm{color}=\mathrm{SpeciesColors}\right],\mathrm{diagonal}=\left['\mathrm{Histogram}',\mathrm{style}=\mathrm{polygon}\right],\mathrm{lower}=\mathrm{none},\mathrm{width}=600,\mathrm{widthmode}=\mathrm{pixels},\mathrm{=}\left(\mathrm{fillcolor},\left(T,i,j\right)↦\mathrm{piecewise}\left(j
 ${"Tabulate2"}$ (5)

From using the custom coloring scheme, it can be observed that the cell in the 4th row and 3rd column shows the darkest color. The coloring used colors from white to black to indicate correlation values from 0 to 1, meaning that in this case, there is a higher level of correlation between the Pedal Length and Pedal Width variables.

The correlation option is useful for showing more details on correlation between columns of data and in order to generate corrgrams for multivariate data. For example, if the values from the correlation matrix are used for the lower triangle, the following plot can be generated:

 > $\mathrm{GridPlot}\left(\mathrm{IrisData}\left[1..4\right],\mathrm{upper}=\left['\mathrm{plots}:-\mathrm{pointplot}',\mathrm{color}=\mathrm{SpeciesColors}\right],\mathrm{lower}='x↦\mathrm{Statistics}:-\mathrm{PieChart}\left(\left[""=\mathrm{abs}\left(x\right),""=1-\mathrm{abs}\left(x\right)\right],\mathrm{color}=\left["CornflowerBlue","WhiteSmoke"\right],\mathrm{title}=\mathrm{evalf}\left[3\right]\left(x\right),\mathrm{size}=\left[100,100\right]\right)',\mathrm{correlation}=\left[\mathrm{false},\mathrm{true},\mathrm{false}\right],\mathrm{width}=600,\mathrm{widthmode}=\mathrm{pixels}\right)$
 ${"Tabulate3"}$ (6)

 $\mathrm{Sepal Length}$ $\mathrm{Sepal Width}$ $\mathrm{Petal Length}$ $\mathrm{Petal Width}$

Compatibility

 • The Statistics[GridPlot] command was introduced in Maple 2016.
 • For more information on Maple 2016 changes, see Updates in Maple 2016.