Tag Archives: Matplotlib

Python with Arduino LESSON 10: Installing Drawnow to Allow Live Plotting with Matplotlib

Our objective with this series of lessons is to plot live data coming from arduino using Python and Matplotlib. We have taken a few lessons to get familiar with Matplotlib, and we have built a circuit to stream live data from arduino to python. We need to install one more library to enable Matplotlib to plot live sensor data in real time. The magic library is called drawnow. The bad news is that this library is hard to install on windows. The good news it that PIP installs it very easy. So, if you have not done so already, you need to go to Python with Arduino LESSON 6 and install PIP. PIP makes it very easy to install drawnow.

Python with Arduino LESSON 8: Introduction to Graphing with Matplotlib

While it is cool to create 3D visuals using vPython to represent our data coming from arduino, sometimes we want to make more quantitative graphs and charts from the data. To do this, we need to learn how to create graphs in Python. We do this using the library Matplotlib. We learned how to install and download this library in Python with Arduino LESSON 7: If you have not installed the library yet, make sure to go back and do in as shown in LESSON 7.

With the library installed, we are ready to learn Matplotlib. The video takes you through an introductory tutorial with step-by-step instructions. The code below is a sample of how to plot a sin and cos wave. You can watch the video, and then play around with the parameters to become familiar with this library.

 

Python with Arduino LESSON 7: Installing Matplotlib for Graphing

In this video we provide step-by-step instructions on how to install Matplotlib. Hopefully you have been following our lessons, and have already installed Python 2.7, the 32 bit version. If you stay on the same path as me as far as libraries and software versions, all my tutorials should work easily for you. In order for matplotlib to work, you need to have the numpy library installed. In Python with Arduino LESSON 2 we installed the vPython library. If you installed the vPython library, you already have numpy, as that was part of the vPython installation. If you have not already installed vPython, you should review that lesson now and do that.

Now, to install matplotlib, go to this page:

https://github.com/matplotlib/matplotlib/downloads/

If you are following my lessons and software versions, you will want to install this version, which should be towards the top of the page:

matplotlib-1.2.0.win32-py2.7.exe — Binary installer for 32-bit Windows, built using python.org’s 2.7 and Numpy 1.6.2

When the file downloads, then click on it and then follow the simple installation instructions.

Once it is installed you can test things with this simple program, which should plot a sine wave.