Transcript for:
Mastering Pie Charts for Data Representation

another kind of chart that we see a lot in real life are pie charts so we're going to take the same data we had in the bar chart example we're going to construct a pie chart with it so we're going to use age groups for the names of the categories and we're going to construct a pie chart with these values here okay so to construct a pie chart it's very similar to a bar chart but some of the the words we use are different so we start off with pi that tells the computer we want to make a pie chart and then it requires two lists of arguments so it requires an X the X are the the size or the the frequencies relative frequencies of each slice of the pie okay tells you how big each slice of the pie is going to be and the labels are the category labels okay when we did bar charts and we plugged in to the bar plot function instead of X we use the word height instead of labels we use the word names okay but it means exactly the same thing here okay the whatever it is this guy just tells you how big that piece is going to be and this says just telling you what to call it okay so we could actually use exactly the same lists of values that we use for the bar plot function okay so for x uh that means let's let's pull over my calculator here calculator uh here we go let's pull over my calculator so we'll take our proportions which again was the 19.11 42.37 and the 37.52 percent so exactly what I did in the bar plot example and combining these three values into a list okay separated with commas and I'm naming the list proportions then I'm going to get my list of labels put my labels in double quotes so the computer knows that these are labels and not something that it should try to understand okay so the first label is children the second label is working age adults the last label is retirees again I started off with the c so I say telling the computer I'm combining these into a list with parentheses so that the computer knows anything in the parenthesis is in the list the labels are between double quotes and after each label I have a comma to say okay now we're going on to the next label okay and then once I have all that done I am naming this list age groups so I could talk about it later so whenever the computer sees the word age groups they'll know ah I know what you're talking about you're talking about that list of labels up there okay and then finally we're going to call that Pi function pi we're going to start with the size of each pie that x value okay this value right here that's the size of each slice that's the proportions okay now I could write x equals proportions we're going to use x as the first argument for a lot of functions in this class so when that happens I like to just leave it off the computer will still understand what you mean as long as it's just that first value it'll understand what you mean sometimes the other values no but the X always comes first so it knows that that's going to be the first one if you want to do x equals that'll work fine now I'm going to leave it off and the computer is going to understand that just fine it'll understand oh that's the first argument that's the first thing you're telling me so that must be what the x is that's the size of each slice okay I will use labels equals for the second one age groups okay so now it knows okay this is the size of each slice and then the label of each slice that's found in the list named age groups okay that's in parentheses this so the computer knows we want to make a pie chart and in parentheses is the information it needs to make that pie chart Okay click evaluate and if you scroll down you have a pie chart the size of each slice is according to the number we picked okay and then you could see that each slice is labeled using the labels we told it to use now um pie charts have their place but in real life bar charts tend to be the the better choice and in most situations there are situations where pie charts are better pie charts are really good with dealing with relative proportions relative frequencies because you can see that it's part of a whole and sometimes it's easy to see with a pie chart when a section makes up 25 or 50 percent of a whole okay but a lot of times in most situations that we need to bar charts of the better choice so so let's take a look at why that might be and there's a great illustration in the book which I'm going to use this one right here so here we have three different pie charts okay and then we have the corresponding data as it would look in bar charts so we have a data for a as a pie chart and a bar chart and this is just an example so the data isn't doesn't mean anything but we just want to see the same data represented as a pie chart and a bar chart okay same data for B and same data for C okay pie chart and bar chart notice in each case the pie charts they all look pretty darn near the same right it's very hard if I look at any one of these pie charts say here is is you know one section one Vigor let me use a different color section one bigger or section two bigger really hard to look at maybe if you stare at it long enough you could come to a conclusion but it's really hard to make that determination if I were to ask you what's the biggest slice of this pie looking at the pie chart you might be able to come up with the right answer but it's a little hard to see right whereas if I look at bar chart we could immediately see that one is the smallest slice five is the biggest slice and we could see uh you know that we're increasing in size going from one to five same's true with the next one here very hard to see what's the biggest slice it's it's slice four it's very hard to tell that but if you look at the bar chart which has using the same data bar chart is much easier to read okay so by pie charts are are commonly used in business and media and all kinds of things but most of the time in real life a bar chart is actually the better tool to use so just you know going forward keep that in mind bar charts tend to be the better choice