So far we have displayed data as averages and counts.
Now let's look at some other statistical parameters
that we will illustrate as graphics.
We have not yet shown anything about variance
and I think the first thing
that one should look into beyond averages,
is to look at variance or how the data are distributed.
A good way of looking at the distribution of data,
especially if it were to be a continuous variable,
is to look at histograms.
If you are interested in
displaying something more than the average,
maybe the median and the quartiles,
then perhaps boxplots should be our choice.
Using the teaching evaluation data,
we have plotted a histogram
of teaching evaluation scores.
You could see that the mean score is around four,
but then you could see
very low teaching evaluation scores, not many frequently,
but most frequently is the around
the average and then you'd see that
some have lower teaching evaluation scores and
some have fairly high teaching evaluation scores.
The histogram approximates the normal distribution curve.
Essentially you have 3.99 to four as the mean,
the standard deviation of 0.55,
looking at 463 records.
This gives you a good idea of
how your data are distributed.
You can in fact plot
multiple histograms such that
you can see the difference between the subgroups.
Here you have the histograms
overlaid for males and females.
These frequent lower teaching evaluations for females
is likely to influence
the average teaching evaluation score
for females versus the males.
A box plot essentially looks like this.
The thick line in the box represents the median.
The top part of the box is the third quartile.
The bottom part of the box as the first quartile.
The line at the bottom is the minimum value,
and the line at the top is the maximum value.
The range between the first quartile and
the third quartile is called the inter-quartile range.
In this graphic, we have created
the box plots for the age variable.
We can see that the median age of males
is higher than the median age of females.
Also, the maximum age of the males is
higher than the maximum age of females.
To do this in Python,
we use the boxplot function in the Seaborne library.
We will put the gender on the Y axis and
the age of the instructor on the X axis.
You can play around with the X and Y axis.
If you want a horizontal style boxplot for readability,
I like to use vertical boxplots.
We can also add another dimension.
Here we will add tenure.
So those who are tenured are plotted on the right,
and those who were not tenured are plotted on the left.
The blue color represents the female instructors,
and the orange color represents the male instructors.
We can see the differences between male and female.
Instructors, male tenured instructors
are older than male untenured instructors,
whereas female tenured instructors are
younger than female untenured instructors.
To do this in Python,
add the hue argument at the box plot function.
A pie chart is another way of looking at your data.
You can see here in
this graphic that the number of courses taught by
male instructors is larger than the number of
courses taught by female instructors.
To do this in Python,
we will use the matplotlib library.
First we specify the labels,
get the number of courses taught
both by male and females,
and assign it to a size is variable.
Create a subplot, insert the sizes,
labels and percentage to
one decimal place in the pie function,
and print out the pie chart with the show function.