Showing the histogram as a stepped line

Matplotlib allows a number of different histogram types. In this recipe, you will create a stepped line histogram. This is an exact copy of the previous recipes except for a single argument, hist() - histtype='step'.

How to do it…

  1. To create a histogram as a stepped line, begin by importing all the required libraries. To show the matplotlib plots in IPython Notebook, we will use an IPython magic function which starts with %:
    %matplotlib inline
    import pandas as pd
    import numpy as np
    from pymongo import MongoClient
    import matplotlib as mpl
    import matplotlib.pyplot as plt
  2. Next, connect to MongoDB and run a query specifying the five fields to be retrieved from the MongoDB data:
    client = MongoClient('localhost', 27017) ...

Get Python Business Intelligence Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.