Visualizing vehicle data with Python & MatPlotLib

python graph in matplotlib

Recently I attended MongoDB Boston, a conference dedicated to the uses of MongoDB, a NoSQL database. The talks included Mongo’s use for developers, DBAs, architects, and operations professionals.

Here at BlackBoxPi the vehicle data is stored in MySQL, but I’m always looking to experiment with MongoDB. One of the important talks at the conference was the use of MatPlotLib to visualize data. MatPlotLib is an open source graphing toolkit in Python. There’s a gallery of dozens if not hundreds of graph types it can produce. I’ve put together demo code that outputs GPS data into a graph. The script is available in GitHub as part of the server side of the project.

Conceptually, the data is in MySQL on the server. A Python script is fed data from an HTML web form on this site in WordPress. The Python script takes the inputs from a form such as user’s ID and start and end date. It connects to MySQL, runs a query to download summary GPS data such as number of records per day or the N last days of data, then puts this together into a tuple. The tuple stores all the output which is given to a graph created in MatPlotLib. That graph is then saved as a PNG file.

This Python/MatPlotLib proof of concept is now functional. The next step is to come up with some examples, create the HTML forms and DB queries, then allow you to view the graphs it generates. If you have any ideas on what you’d like to see, I’m open to it. Just let me know.

 

Leave a Reply

Your email address will not be published. Required fields are marked *