Matplotlib installation

Thank you, matplotlib installation was successful, but I could not plot using it.
from matplotlib import pyplot as plt

Could you attach the python script you are using? If there are any API keys in your code, please hide them.

I have only bolt API

You need to convert the response which is a json object appropriately such as by using


You may then use plt.plot(actual_val)

Also, please remove the second image in your previous post and reset you API keys immediately.

still getting errors

Store the values of actual_val to a list by appending into it everytime new value is read.

list_name=[ ]
while True:

At the end plot the list and use to display the plot. The above method may lead to opening multiple plot windows.

still getting the same error

Sorry, I didn’t realise you were using a server edition on your virtual machine. To view the plot you’ll require a GUI, whereas you are using a command line.
You may either use Windows or follow the below procedure to install a Desktop environment for Ubuntu.

I’ll advise you use either Gnome 2, unity or xfce if you want to use Ubuntu.

A cleaner way would be to download the desktop version of ubuntu and install it on your virtual machine, but the above method should also work.

Note: please remove the images with API keys in your previous posts and reset the keys if you haven’t.

@pankajkumar.p Then, I think Raspberry Pi would be a better option. The same code can run in Raspberry Pi, right?

Any system that has a GUI and support for matplotlib/python should work just fine.

Operating systems for Raspberry Pi such as the official Raspbian OS also have CLI(minimal) and GUI(full) versions.

I tried it using raspberry pi and plot window appeared but there is no plot inside it
please help me

dd ds

Did you get multiple plots or just a single plot?

single plot window with no graph

Print actual_val to see if you’re getting anything on the terminal.

did plt.plot(actual_val) without Matplotlib installation
still got the same blank plot

Try something like this and check the output on the terminal

list_name=[ ]
while True:

@pankajkumar.p only 1st reading is being printed and plot window appears without any graph as before


To plot the graph there must be at-least two data points in the list . You can check this code

Since there is no display environment available thats why output will be save in graph.png file.

@rahul.singh1 when I am using ax.plot(actual_val) or plt.plot(actual_val) after print(list_name) or print(actual_val), even though I get empty plot , I see my reading printed in the terminal.
But while using ax.plot(list_name) or plt.plot(list_name) I see only my first reading printed and again the empty plot. I think while trying to print list_name, my ‘while True’ loop gets stuck after the first loop. Can you give an example to get graph from data from analog sensor at A0 ?(real time with delay 10)

Hi @swethatsunil.mec,

I think you need to add the pause for each loop. Check this link

Do let me know in case you need any other information.