Matplotlib_plot is not getting generated

Please tell what is the issue in above code. My plot is not getting generated. I have checked the kernel its running properly. Just this code is not getting executed.

There is no error? I just tried and it ran successfully

Its not working for me… I copied and pasted DQ code below that and it was working but just this code is not working…

You need to include this in the notebook:

%matplotlib inline

Provided you are running IPython, the %matplotlib inline will make your plot outputs appear and be stored within the notebook.

According to documentation,

To set this up, before any plotting or import of matplotlib is performed you must execute the %matplotlib magic command . This performs the necessary behind-the-scenes setup for IPython to work correctly hand in hand with matplotlib ; it does not, however, actually execute any Python import commands, that is, no names are added to the namespace.

A particularly interesting backend, provided by IPython, is the inline backend. This is available only for the Jupyter Notebook and the Jupyter QtConsole. It can be invoked as follows:

%matplotlib inline

With this backend, the output of plotting commands is displayed inline within frontends like the Jupyter notebook, directly below the code cell that produced it. The resulting plots will then also be stored in the notebook document.

In the future, please avoid using images to show your code. For those who are willing to help, they have to type every single line of code instead of copying and pasting. Moreover, image resolution may not be clear. Please type your code. Much appreciated.

I tried in matplotlib inline it was still not working but it worked when I pasted fig variable in to line [ 46 ]. Any insight on this ?

Please refer to my post above.

1 Like