Plotting random numbers using matplotlib

The matplotlib library provides a collection of basic plotting-related functions and methods via the pyplot framework. The pyplot framework contains functions for creating figures, drawing plots, setting up titles, setting up axes, and many additional plotting methods. One of the import functions provided by pyplot is figure(). This initializes an empty figure canvas that can be selected for your plot or a set of plots:

fig1 = pyplot.figure(1)

You can similarly create multiple figures by specifying a number as the parameter, that is, figure(2). If a figure with this number already exists, the method activates the existing figure that can then be further used for plotting.

The matplotlib library provides ...

Get Python Programming for Arduino 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.