I got this error in my python script:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from utils import progress_bar_downloader
import os
#Hosting files on my dropbox since downloading from google code is painful
#Original project hosting is here: https://code.google.com/p/hmm-speech-recognition/downloads/list
#Audio is included in the zip file
link = 'https://dl.dropboxusercontent.com/u/15378192/audio.tar.gz'
dlname = 'audio.tar.gz'
if not os.path.exists('./%s' % dlname):
progress_bar_downloader(link, dlname)
os.system('tar xzf %s' % dlname)
else:
print('%s already downloaded!' % dlname)
I want use matplotlib but it gives syntax error, I tried sudo apt-get install python-matplotlib
Why matplotlib inline is used. You can use the magic function %matplotlib inline to enable the inline plotting, where the plots/graphs will be displayed just below the cell where your plotting commands are written. It provides interactivity with the backend in the frontends like the jupyter notebook.
So %matplotlib inline is only necessary to register this function so that it displays in the output. Running import matplotlib. pyplot as plt also registers this same function, so as of now it's not necessary to even use %matplotlib inline if you use pyplot or a library that imports pyplot like pandas or seaborn.
What Does Matplotlib Mean? Matplotlib is a plotting library available for the Python programming language as a component of NumPy, a big data numerical handling resource. Matplotlib uses an object oriented API to embed plots in Python applications.
if you are not using Jupyter IPython notebook, just comment out (or delete) the line, everything will work fine and a separate plot window will be opened if you are running your python script from the console.
However, if you are using Jupyter IPython notebook, the very first python code cell in your notebook should have the line "%matplotlib inline" for you to be able to view any plot.
"%matplotlib inline" isn't valid python code, so you can't put it in a script.
I assume you're using a Jupyter notebook? If so, put it in the first cell and all should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With