Matplotlib for SNMP results

In our first example, namely matplotlib_1.py, we will import the dates module besides pyplot. We will use the matplotlib.dates module instead of Python standard library dates module because the way we use the module is how Matplotlib will convert the date value internally into the float that is required.

  import matplotlib.pyplot as plt  import matplotlib.dates as dates
Matplotlib provides sophisticated date plotting capabilities; you'll find more information on this at http://matplotlib.org/api/dates_api.html.

We will create two empty lists, each representing the x axis and y axis values. Note that on line 12, we used the built-in eval() Python to read the input as a dictionary instead of a default string:

 x_time ...

Get Mastering Python Networking 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.