May 22, 2017 -- SienaSemanticsSurvey -- Code Breakdown -- Cell #8

Information on Counter

Counter: container that keeps track of how many times equivalent values are added.

ScountsS14=coll.Counter(SemanticsS14.iloc[:,3])
                                           ^ locates each student's data, but pulls out the 4th column (name of school)
                      ^creates a collection of how many times student's listed the same school

labels = list(set(SemanticsS14.iloc[:,3])
                      ^ removes duplicates
                ^ creates a list

n = len(labels) 
       ^ gives the length of the list found above
                  ^ becomes representative of size which will be used below to distribute pieces of pie chart according to the size

sizes= []     <-- creates an empty list
for i in range(0,n): sizes.append(ScountS14[labels[i]])
                                                                              ^label at point i
                                        ^adds to the list sizes when i is in range given
              ^ when i is between 0 and the length of the list


EXPLODE ?????   doesn't make a difference when commented out or changed value
should be pulling out one of the pieces of the pie chart from the rest of the circle, but should only be same number of numbers listed as colors listed (including the 0.1 though)
Pie Chart Explode Example

does explode need to be listed within the line "plt.pie(sizes, labels=labels, colors=colors..." ???

The pie chart creation process is repeated for each year ('14, '15, '16, '17) and the number of colors listed/ the number of pieces to the pie chart corresponds to the number of schools that student's recorded as attending in the surveys.

plt.show() displays all four pie charts that were created


Include Legend instead of all the labels trying to print on the graph at once:



Comments

Popular posts from this blog

6/14/17 Notes

6/06/17 Notes (formatting code and searching for a specific person)