2 Plotting Probabilities Using Matplotlib

 

This section covers:

  • Creating simple plots using Matplotlib.
  • Labeling plotted data.
  • What is a probability distribution?
  • Plotting and comparing multiple probability distributions.

Data plots are among the most valuable tools in any data scientist’s arsenal. Without good visualizations, we are effectively crippled in our ability to gleam insights from our data. Fortunately we have at our disposal the external Python Matplotlib library, which is fully optimized for outputting high-caliber plots and data visualizations.In this section, we will leverage Matplotlib to better comprehend the coin-flip probabilities that we computed in Section One.

2.1  Basic Matplotlib Plots

Lets begin by installing the Matplotlib library.

Note

Call "pip install matplotlib" from the command-line terminal in order to install the Matplotlib library.

Once installation is complete, we’ll proceed to import matplotlib.pyplot, which is the library’s main plot generation module. According to convention, the module is commonly imported using the shortened alias plt.

Listing 2.1. Importing Matplotlib
import matplotlib.pyplot as plt

2.2  Plotting Coin-Flip Probabilities

 
 

2.2.1  Comparing Multiple Coin-Flip Probability Distributions

 
 
 

2.3  Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest