Now You Code 1: Simple Plotting

In this first now you code, you will execute some simple plotting in matplotlib and plot.ly

In most cases you will be writing 1-2 lines of code. you will spend the majority of time looking through the documentation here:

Also try interactive help: help(eye_df.plot) for pandas and help(eye_df.iplot) for plot.ly


In [ ]:
import pandas as pd
import plotly as py
import matplotlib as plt
import cufflinks as cf
%matplotlib inline

In [ ]:
# setup the credentials
# Sign up for a FREE plot.ly account and get your API credentials. https://plot.ly/settings/api

py.tools.set_credentials_file(username='????', api_key='????')

In [ ]:
eye_data = [ {'Eye Color' : 'Blue', 'Count' : 190 }, {'Eye Color' : 'Brown', 'Count' : 245 },
            {'Eye Color' : 'Green', 'Count' : 64 }, {'Eye Color' : 'Hazel', 'Count' : 93 } ]
eye_df = pd.DataFrame(eye_data)
eye_df

In [ ]:
hair_df =  pd.DataFrame( {'Hair Color' :pd.Series( ['Black', 'Blond', 'Brown', 'Red'], name='Hair Color'), 
                           'Count' : pd.Series( [108, 125, 286, 73], name = 'Count')} )
hair_df

In [ ]:
# plot a vertical bar chart of hair colors using pandas / matplotlib
# Hair color names on the X axis, and chart title of "Counts of Hair Colors"

In [ ]:
# plot the EXACT same thing using plotly / cufflinks

In [ ]:
# next, plot a pie chart of EYE COLORS using pandas / matplotlib
# make sure to set the labels on the pie to 'Blue', 'Brown' etc...

In [ ]:
# plot the same pie chart with plot.ly

In [ ]:
# In this last step you will plot a scatter plot with both pandas and plotly / cufflinks
#let's get the data:
cars = pd.read_csv('https://raw.githubusercontent.com/mafudge/datasets/master/cars/weight-vs-mpg.csv')
cars.sample(5)

In [ ]:
# plot use pandas / matplotlib to plot a scatter of weight vs mpg for cars

In [ ]:
# Use cufflinks to plot a scatter here.

: Reflection

Reflect upon your experience completing this assignment. This should be a personal narrative, in your own voice, and cite specifics relevant to the activity as to help the grader understand how you arrived at the code you submitted. Things to consider touching upon: Elaborate on the process itself. Did your original problem analysis work as designed? How many iterations did you go through before you arrived at the solution? Where did you struggle along the way and how did you overcome it? What did you learn from completing the assignment? What do you need to work on to get better? What was most valuable and least valuable about this exercise? Do you have any suggestions for improvements?

To make a good reflection, you should journal your thoughts, questions and comments while you complete the exercise.

Keep your response to between 100 and 250 words.

--== Write Your Reflection Below Here ==--