While working on exploring a data set you might all definitely need to visualize the different features and for that you will import matplotlib. But while importing matplotlib we sometimes happen to write either %matplotlib inline or %matplotlib notebook in our Jupyter notebook. Let us understand what they do. %matplotlib %matplotlib is one of the magic functions you can use in Jupyter notebook. The magic functions can be used to add some dynamic capabilities to the outputs we get, as in general the output of these plots look more like reports. Writing the above magic function sets up necessary background features for python to work with matplotlib. %matplotlib inline %matplotlib inline is used to display the plots inline and on the next cell below the code which outputs the plot. It is used to store the plots in the notebook itself. So if the next time after saving the work done in the notebook, if you again wish to see the visualizations, it will still be available in the notebook
While working on exploring a data set you might all definitely need to visualize the different features and for that you will import matplotlib. But while importing matplotlib we sometimes happen to write either %matplotlib inline or %matplotlib notebook in our Jupyter notebook. Let us understand what they do.
%matplotlib
%matplotlib is one of the magic functions you can use in Jupyter notebook. The magic functions can be used to add some dynamic capabilities to the outputs we get, as in general the output of these plots look more like reports. Writing the above magic function sets up necessary background features for python to work with matplotlib.
%matplotlib inline
%matplotlib inline is used to display the plots inline and on the next cell below the code which outputs the plot. It is used to store the plots in the notebook itself. So if the next time after saving the work done in the notebook, if you again wish to see the visualizations, it will still be available in the notebook itself. In Jupyter notebook %matplotlib inline is used by default, so no need to exectue it.
Below is the code snippet:
%matplotlib notebook
%matplotlib notebook is used for creating interactive plots. Sometimes while visualization, making interactive plot might be very valuable. Use the above magic function to zoom in or out of the plot, resize the graph, pan the axes of the graph or you can even download the plot which can be very helpful while presenting the report. There is icon on the top right corner of the plot to stop the interaction.
Below is the code snippet:
Sometimes there can be a bug which might not show the plot then you can enter %matplotlib notebook in the second line too.
Comments
Post a Comment
If you have any doubt, let me know in the comment section.