**Heads up!** To view this whole video, sign in with your Courses account or enroll in your free 7-day trial.
Sign In
Enroll

Preview

Start a free Courses trial

to watch this video

Let's take a look at some of the more common chart types you will come across and the reasons you would choose one over another.

#### Further Reading

Welcome back.
0:00

Now that we have seen a little
bit about how Matplotlib works,
0:01

let's talk briefly about
different chart types.
0:05

As we work through
the rest of this course,
0:07

you will get a better sense of how and
when to use each type.
0:10

Charts come in a wide
range of visual styles and
0:13

are used to represent different things.
0:16

Matpotlib supports a lot of options.
0:18

Line, bar, pie, scatter plot,
histogram, box plot,
0:22

heat maps and candlestick charts
are some of the more common charts.
0:26

In this course,
we'll be showcasing scatter, histogram and
0:32

box plots with Matplotlib.
0:36

I'll touch on some of the others as well,
and
0:38

included links in the teachers notes
to other charts for further reading.
0:40

Let's talk about the when's and
why's of some of these chart types.
0:44

A line chart is used to identify trends or
patterns in data and
0:49

commonly used for
exploring trends over time.
0:53

They can be used to compare multiple
groups by using different lines.
0:56

For example, the total sales of several
products over a period of time.
0:59

A bar chart is most effective when
comparing categories of data.
1:04

They can also be used, like a line chart,
for tracking changes over time.
1:08

When used in this fashion they, are best
applied to large changes in the data.
1:12

A bar chart will have two axes.
1:17

One typically with numerical data and
the other with a category.
1:20

For example,
1:23

the number of different types of apples
sold each week at a farmers' market.
1:24

Or for a time example, the total
population of the world since 1000 BCE.
1:29

A pie chart is best used when comparing
parts of a whole at a snapshot in time,
1:34

instead of a change over time.
1:39

A pie chart would answer questions like,
what is
1:41

the percentage of each type of apples
sold last week at our farmer's market.
1:44

A pie chart will easily show that,
for example, 23% were red delicious,
1:49

18% were golden delicious and
15% were granny Smith.
1:54

Scatter plots are similar to line charts
in that they both have a horizontal and
1:59

vertical axis.
2:04

However, scatter plots are used
to show how much one variable is
2:04

impacting by another or is correlation.
2:09

We use scatter plots to show
relationships between values.
2:12

The plotter points are markers, can be
different sizes to showcase importance,
2:16

and different color to show
specific data buckets.
2:21

It allows us to quickly visualize
the distribution of the data and
2:24

notice any outliers.
2:28

We can see if there's a positive,
negative, or
2:29

non-existent correlation between data
based on the scatter plot results.
2:32

Histograms look like bar charts,
however, looks can be deceiving as they
2:37

are not the same, and
are indeed used for different purposes.
2:42

Histograms are used to show distributions
of variables while bar charts
2:45

are used to compare the variables.
2:50

Unlike a bar chart a histogram
won't have gaps between data.
2:52

Empty values may be possible however
if there are no data points for
2:56

particular value.
3:00

In a histogram chart, the data
are split into different intervals or
3:02

bends, to show the frequency of
distribution of continuous data.
3:06

This allows for the inspection
of the data distribution, and
3:10

will show outliers or skewed data.
3:15

When using a histogram,
choosing an appropriate number of bins and
3:17

their width is important for
meaningful and accurate reporting.
3:21

Box plots, sometimes called box and
whisker plots.
3:25

Combine the functionality,
the bar chart, with a histogram.
3:29

They allow for the quick examination of
and comparison between different sets of
3:33

data while displaying statistical
information about the data.
3:38

It allows for
visualizing the minimum first quartile,
3:42

medium, third quartile, and
maximum values of a data set.
3:45

Wow, that's a lot like a high
school statistics class.
3:49

Put more simply it allows us to
see the overall distribution,
3:53

central value and
variability of a data set.
3:57

Much like a histogram choosing
the number of bins and
4:00

their width is an important
consideration for reporting.
4:03

Finally, I'd also like to briefly touch
on heatmaps and candlestick charts.
4:07

Or we won't be using them in this course.
4:12

You're likely to come across them.
4:14

A heatmap is a chart in which the area
inside recognized boundaries is shaded in
4:16

proportion to the data being represented.
4:20

For example you could have a heatmap
representing population density.
4:23

Countries with higher populations will be
represented with different colors than
4:27

countries with lower populations.
4:31

Candlestick charts are heavily
used in a financial sector.
4:33

While they bear resemblance to box charts,
that where their similarities end.
4:37

Each candlestick will typically show
one day of price movement of a stock,
4:41

currency or derivative.
4:46

It's like a combination of a line and
bar chart showing
4:47

an overtime trend while also showing
the daily information for the data.
4:51

Specifically they show the open,
close, high, and low values for
4:55

security and are a cornerstone
of financial technical analysis.
5:00

Wow, that's a lot of charting options, and
5:04

it only scratches the surface of
the charts available in Matplotlib.
5:07

It's also just the beginning of
the when and why to use each chart.
5:11

Choosing the chart type is predominantly
determined by the questions about your
5:15

data and how to best represent your
data for the intended audience.
5:19

In addition to picking
the proper chart type,
5:23

there is one other aspect of reporting
that is important to remember, scale.
5:25

This is the value you mark on the axis
to show the relationship between
5:30

the units that are being measured.
5:34

Often, we may want to utilize multiple
chart types to showcase our data.
5:36

When doing so, we need to keep
scale in mind across our charts, so
5:40

that our data biz efforts
aren’t misleading.
5:44

We’ll examine this a bit more as we look
at more charting options with matplotlib.
5:47

Now is a good time to take a short break.
5:51

Get up and stretch a bit before we
look at a real world dataset and
5:54

see how to visualize it,
using a variety of charts.
5:57

You need to sign up for Treehouse in order to download course files.

Sign up