0

I'm using a raspberry pi currently for a engineering project, and am collecting data using the GPIO pins from various sensors. Id like to display this data on a graph. I've used matplotlib to get a graph to show, but for the program to continue you need to close the graph window. I've researched, but can't seem to find a way to make the graph stay open, and have it continually updated with the program running in the background. Is there a way to do this? Or should I try creating a HTML file with a graph in it and have the program open that? Thanks for any help!

2 Answers 2

1

You can use the Plotly Python API to log and stream data to a graph in your browser from your RasPi. You can fork the code from GitHub to setup an online graph like this. The example here is temperature.

Once you've generated your graph, you can embed it as an iframe with this snippet:

<iframe id="igraph" src="https://plot.ly/~abhishek.mitra.963/1/400/250/" 
width="400" height="250" seamless="seamless" scrolling="no"></iframe>

You'll want to swap in your URL in the snippet. You can edit the width and height in the URL string and fields to change how it looks. Here's how it looks:

enter image description here

(Full disclosure: I'm on team Plotly).

Sign up to request clarification or add additional context in comments.

Comments

0

You could show the Graph in another Thread by using the module thread or the module threading (which is an object oriented and more powerful alternative). For more infos on these module have a look the python documentation for thread or threading.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.