Skip to content
KnowledgeCity

Python: Finding Distribution of Data with Histograms

Plot a distribution of data with histograms.
Preview the first lesson free — get full access to all 3 lessons.
Course: On-Demand
Intermediate Provider Brian Higgins  3 Lessons ·  20m  in Arabic, German, English, Spanish, French, Portuguese, Chinese 

Course Description

In these lessons you will use the Numpy library to generate a random normal distribution to visualize with a histogram. We’ll go over specifying the mean, standard deviation, and number of random values in order to generate unique data for differentiating between plots. You’ll learn how to use the Pyplot sub library of the Matplotlib library to create histograms and generate subplots, and we’ll show you how to add styling to a histogram like labels, titles, a grid, and a legend.

You will also learn to generate several histogram subplots on the same graph, including how to position multiple histograms on a plot with rows and columns and color each individually. Finally, you will learn how to use the Scipy library to generate the kernel density estimation (kde) line (best fit plot) above a histogram.

What You'll Learn

  • Generate random normal distribution data using the Numpy library by specifying the mean, standard deviation, and number of random values
  • Create histograms using the Pyplot sub-library of Matplotlib
  • Style histograms by adding labels, titles, a grid, and a legend
  • Generate and position multiple histogram subplots on the same graph using rows and columns, coloring each individually
  • Add a kernel density estimation (kde) best-fit line above a histogram using the Scipy library

Key Takeaways

  • The Numpy library is used to generate random normal distribution data by specifying the mean, standard deviation, and number of random values.
  • Specifying different parameters generates unique data that helps differentiate between plots.
  • Matplotlib's Pyplot sub-library is used to create histograms and generate subplots.
  • Multiple histogram subplots can be positioned on the same graph using rows and columns, with each colored individually.
  • The Scipy library generates the kernel density estimation (kde) line as a best-fit plot above a histogram.

Frequently Asked Questions

What libraries does this course use?

The course uses the Numpy library to generate random data, the Pyplot sub-library of Matplotlib to create histograms and subplots, and the Scipy library to generate the kernel density estimation (kde) best-fit line.

What will I learn about styling histograms?

You will learn how to add styling to a histogram such as labels, titles, a grid, and a legend.

Does this course cover plotting multiple histograms together?

Yes. You will learn to generate several histogram subplots on the same graph, including how to position multiple histograms with rows and columns and color each one individually.

What lessons are included in this course?

The lessons are: Generating Random Data and First Histogram; Histogram Options; and Adding a Best Fit Line: Subplot by Group.

What skills does this course help me build?

This course builds skills in Computational Statistics, Data Visualization, Histograms, Numeric Distribution, Probability Distribution, and Statistical Graphics.