In[]:=

(*loadthe"StatisticalPlots"packagewhichcontainsthedefinitionsofvariousstatisticalplotssuchasStemLeafPlot,PairwiseScatterPlot,etc.*)<<"StatisticalPlots`";

For the first few examples in this notebook, we shall make use of the schoolkids dataset provided below:

In[]:=

schoolkids=

;

In[]:=

(*extractsimplevaluelistsfromthedatasetforheightandweigtcolumns*)heightList=Values[Normal[schoolkids[All,4]]];weightList=Values[Normal[schoolkids[All,5]]];

### Stem and Leaf Plot

Stem and Leaf Plot

In[]:=

StemLeafPlot[heightList]

Out[]=

| ||||||||

Stem units: 10 |

### Pie Charts

Pie Charts

In[]:=

ndxAgeVar=3;age11=Select[schoolkids,#[[ndxAgeVar]]11&];age12=Select[schoolkids,#[[ndxAgeVar]]12&];age13=Select[schoolkids,#[[ndxAgeVar]]13&];age14=Select[schoolkids,#[[ndxAgeVar]]14&];age15orOlder=Select[schoolkids,#[[ndxAgeVar]]>=15&];ageLists={age11,age12,age13,age14,age15orOlder};

In[]:=

ageLists

Out[]=

,

,

,

,

In[]:=

ageListWithLabels=Table[Labeled[Length[ageLists[[i]]],"age"<>If[i<5,ToString[10+i],"15+"]],{i,1,Length[ageLists]}];

In[]:=

PieChart[ageListWithLabels,PlotLabel"Pie Chart for age"]

Out[]=

### Box and Whisker Plots

Box and Whisker Plots

In[]:=

(*BoxWhiskerchartwithOutliersandMeanDiamondoptions*)BoxWhiskerChart[heightList,{"Outliers",{"MeanDiamond"}},PlotLabel"Box Whisker Chart for Height"]

Out[]=

In[]:=

(*BoxWhiskerchartforHeightandWeight*)BoxWhiskerChart[{heightList,weightList},{"Outliers",{"MeanDiamond"}},ChartLabels{"height","weight"},BarOriginLeft,PlotLabel"Box Whisker Charts for Height and Weight"]

Out[]=

### Histograms

Histograms

In[]:=

histPlot0=Histogram[heightList,PlotLabel"Histogram for Height"]

### PDF Plots

PDF Plots

### Scatter Plots

Scatter Plots

We could have constructed the same list of data pairs by combining the heightList and weightList lists we defined at the outset:

We use Mathematica’s ListPlot function to render the scatter plot.

In the following example, we create a scatterplot with tooltips. When you hover your cursor over a point in the scatter plot, you will see the name of the child associated with that point appear in a tooltip.

### Contour Plot (aka ListPlot3D)

Contour Plot (aka ListPlot3D)

In this example, we use the lake dataset provided by SAS Institute. We converted the lake.csv file provided by SAS into a Mathematica dataset. You can find other SAS datasets at this link:

https://support.sas.com/documentation/onlinedoc/viya/examples.htm

https://support.sas.com/documentation/onlinedoc/viya/examples.htm

We shall use the ListPlot3D function to create a rotatable contour plot. The ListPlot3D function is just one of the many functions that allow you to dynamically interact with the plot itself. You can rotate the image using your mouse. Click on the plot with your mouse button (on Windows, click with your left mouse button). While you continue to hold down the button, move your mouse left to right and up and down. You can rotate the plot in any direction you desire.

### Dendrogram

Dendrogram

The povertyData dataset is based on Rouncefield, “The Statistics of Poverty and Inequality” (1995), Journal of Statistics Education v .3, n .2 .

Description: Birth rates, death rates, and infant death rates for 33 countries in millions per country.

Description: Birth rates, death rates, and infant death rates for 33 countries in millions per country.

### Array Plot (aka Cell Plot)

Array Plot (aka Cell Plot)

The histlevels dataset below is based on Cole, J.W.L. and Grizzle, J.E. (1966), “Applications of Multivariate Analysis of Variance to Repeated Measures Experiments,” Biometrics, 22, 810 -828.

Description: Sixteen dogs are randomly assigned to four groups. (One animal is removed from the analysis due to a missing value for one dependent variable.) The dogs receive either morphine or trimethaphan. Histamine levels are measured at 4 different times.

Description: Sixteen dogs are randomly assigned to four groups. (One animal is removed from the analysis due to a missing value for one dependent variable.) The dogs receive either morphine or trimethaphan. Histamine levels are measured at 4 different times.

The only problem with the plot is that we would like to display labels along the x axis. We can do this using the FrameTicks option.

Suppose we want to rotate the labels on the x axis. We can do this as follows.

### Pairwise Scatter Plot

Pairwise Scatter Plot

The PairwiseScatterPlot function does not operate on datasets. Therefore, the input we provide to the function must be an ordinary list.

The only problem with the plot is that the labels on the bottom need to be rotated. We remedy this problem as follows.

The PairwiseScatterPlot function assumes that the tick values on the y axis are in descending order. I.e., tick value at top of y axis > tick value at bottom of y axis. Thus, when we make ticks for y axis, we reverse the order of the solvent names when we call our helper function. This puts “1-Octanol” at the top of the y axis and Hexane at the bottom of the y axis (the origin) which is the order in which we want them to appear on the y axis.