Return to Video

Plotting in Python - Intro to Data Science

  • 0:00 - 0:02
    All right. Let's take a look at the code
  • 0:02 - 0:06
    here. So first we create a pandas data frame
  • 0:06 - 0:11
    called hr_year, that reads in the hr_year.csv file. Then
  • 0:11 - 0:13
    we just print ggplot where we say that our
  • 0:13 - 0:16
    data source is going to be the hr_year data
  • 0:16 - 0:18
    frame. And the variables that we want to plot are
  • 0:18 - 0:22
    year ID and home runs. Then we add geom
  • 0:22 - 0:26
    points, with the color red. Then we add geom
  • 0:26 - 0:28
    lines to the color red and then let's add some
  • 0:28 - 0:31
    labels so our plot is able to interpret. So we'll title
  • 0:31 - 0:35
    it total home runs by year. With the x label year
  • 0:35 - 0:39
    and the y label home runs. We just print this and
  • 0:39 - 0:43
    we'll generate our chart. Now let's see what this produces.
  • 0:43 - 0:46
    Here's the plot that this generates. We see that we have
  • 0:46 - 0:48
    a bunch of points that are red, where we indicate the
  • 0:48 - 0:51
    number of home runs hit every year. They're connected by red
  • 0:51 - 0:53
    lines, which gives us some sense of the rate of
  • 0:53 - 0:56
    change. We have years on the X axis. Home runs on
  • 0:56 - 1:00
    the Y axis. We have the labels that we put in.
  • 1:00 - 1:02
    And also the title that we told our plot to show.
Title:
Plotting in Python - Intro to Data Science
Description:

05-20 Plotting in Python

more » « less
Video Language:
English
Team:
Udacity
Project:
ud359: Intro to Data Science
Duration:
01:04

English subtitles

Revisions Compare revisions