English subtitles

← Plotting in Python - Intro to Data Science

Get Embed Code
5 Languages

Showing Revision 5 created 05/24/2016 by Udacity Robot.

  1. All right. Let's take a look at the code
  2. here. So first we create a pandas data frame
  3. called hr_year, that reads in the hr_year.csv file. Then
  4. we just print ggplot where we say that our
  5. data source is going to be the hr_year data
  6. frame. And the variables that we want to plot are
  7. year ID and home runs. Then we add geom
  8. points, with the color red. Then we add geom
  9. lines to the color red and then let's add some
  10. labels so our plot is able to interpret. So we'll title
  11. it total home runs by year. With the x label year
  12. and the y label home runs. We just print this and
  13. we'll generate our chart. Now let's see what this produces.
  14. Here's the plot that this generates. We see that we have
  15. a bunch of points that are red, where we indicate the
  16. number of home runs hit every year. They're connected by red
  17. lines, which gives us some sense of the rate of
  18. change. We have years on the X axis. Home runs on
  19. the Y axis. We have the labels that we put in.
  20. And also the title that we told our plot to show.