Progress Log 59 (Python 3): Histograms – .hist(x, bins=), Customization – append, .fill_between(), .xlabel(), .ylabel(), .title(), .yticks()

I’m taking a course entitled “Introduction to Python for Data Science” by Microsoft at edX and all of the concepts described below come from that course.

 

Histograms

  • .hist(x, bins=): To build a histogram where x = list of values you want to build a histogram for and bins = how many bins the data should be divided into.

 

Lab

 

 

Customization

  • To append more data to your array, add the data points between the square brackets as we did for pop and year and then add them to the current array for pop and year.
  • .fill_between() fills in the area under the graph. 0 means to fill in until  0. Color = means you can choose a color to fill in with.
  • .xlabel() is used to label the x-axis.
  • .ylabel() is used to label the y-axis.
  • .title() is used to create a title for your graph.
  • .yticks() is used to determine at what value the y-axis begins and how much it is incrementing by. You can also label these values if you are working in, say, billions as we are here.

 

Compare this to our previous line chart which contained the same information:

 

Lab

 

Leave a Comment