matplotlib plotting is not working in google colab

11,110

Solution 1

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.

Solution 2

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

Share:
11,110
June Yoon
Author by

June Yoon

Updated on June 25, 2022

Comments

  • June Yoon
    June Yoon almost 2 years

    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.

  • June Yoon
    June Yoon over 3 years
    I tried both but they didn't work. My question is why, nonetheless, that this link plots are working correctly.
  • June Yoon
    June Yoon over 3 years
    I wrote some more detail to the question. Please read again.