Book Image

Python Programming for Arduino

Book Image

Python Programming for Arduino

Overview of this book

Table of Contents (18 chapters)
Python Programming for Arduino
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 the plot() method to create line charts. The plot() method takes a list or an array data structure that is made up of integer or floating point numbers as input. If two arrays are used as inputs, plot() utilizes them as values for the x axis and the...