Not sure why this simple plot won't show. simply shows an In[*] and won't finish loading the plot. Can't find any info on what the * means. Any help?
import numpy as np
import matplotlib.pyplot as plt
r = np.arange(1,11)
v2 = 1.0/r
font = {'family' : 'serif',
'color' : 'black',
'weight' : 'normal',
'size' : 18,
}
plt.xlabel('$V*$', fontdict = font)
plt.ylabel('$Radii$', fontdict = font)
plt.plot(r,v2,lw=2)
plt.show()
Setting the iPython notebook %matplotlib
magic command here is what you need to display the plot.
Basically, that command tells the notebook which backend to use when plotting with matplotlib
, and sets it to work interactively. You usually will want to set that at the top of your notebook.
There are several options. A common one is
%matplotlib inline
which displays the plots right there in the iPython notebook.
Other options will depend on your system, but can include:
‘gtk’, ‘gtk3’, ‘inline’, ‘nbagg’, ‘notebook’, ‘osx’, ‘qt’, ‘qt4’, ‘qt5’, ‘tk’, ‘wx’
If you just set:
%matplotlib
without a gui option, it will use the default backend on your system (defined in your .matplotlibrc
file).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.