Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib plotting is not working in google colab

I wanted to use matplotlib in colab but it didn't work. As this link says I tried both %matplotlib inline and %matplotlib notebook but they both didn't work. But can I ask why this link plots are working well? It seems it's just using normal matplotlib with %matplotlib inline. I want to know the difference.

like image 867
June Yoon Avatar asked Sep 14 '20 13:09

June Yoon


3 Answers

According to colab docs:

In the IPython notebook, you also have the option of embedding graphics directly in the notebook, with two possible options:

%matplotlib notebook will lead to interactive plots embedded within the notebook.

%matplotlib inline will lead to static images of your plot embedded in the notebook.

like image 93
Anup Tiwari Avatar answered Nov 12 '22 06:11

Anup Tiwari


Plotting from an IPython notebook

The IPython notebook is a browser-based interactive data analysis tool that can combine narrative, code, graphics, HTML elements, and much more into a single executable document.

Plotting interactively within an IPython notebook can be done with the %matplotlib command, and works in a similar way to the IPython shell. In the IPython notebook, you also have the option of embedding graphics directly in the notebook, with two possible options:

  • %matplotlib notebook will lead to interactive plots embedded within the notebook

  • %matplotlib inline will lead to static images of your plot embedded in the notebook

like image 28
Sunil Vora Avatar answered Nov 12 '22 07:11

Sunil Vora


Selecting a GPU from the hardware accelaration tab solved the issue for me.

Go into Edit > Notebook Settings > Select GPU in the drop-down.

like image 3
Nathan Dos Santos Nunes Avatar answered Nov 12 '22 06:11

Nathan Dos Santos Nunes