Issue
I'm trying to create a word cloud using Repl.it by following this towards data science article. However, I'm getting an error with %matplotlib inline (underlined in red). How do I fix this?
# Import packages
import matplotlib.pyplot as plt
%matplotlib inline
# Define a function to plot word cloud
def plot_cloud(wordcloud):
# Set figure size
plt.figure(figsize=(40, 30))
# Display image
plt.imshow(wordcloud)
# No axis details
plt.axis("off");
Solution
The reason you're getting an error is you're using what are called magic commands (and not to be confused with magic method which is an informal synonym for special method). More specifically in this case line magics. There are also cell magics.
Line (and cell) magics are not common to all of python but rather to ipython and (by extension) jupyter notebooks.
To create a word cloud in a notebook that isn't on your own desktop, you'll need a platform that is able to run an notebook. Something like binder or Google Colaboratory though there certainly others.
Answered By - hrokr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.