我試圖用matplot lib中繪製一個圖,我沒有得到一個窗口顯示:繪圖窗口沒有出現在matplotlib
我得到這個代碼段從使用matplotlib輪廓一個演示程序。
import matplotlib
import numpy as np
import matplotlib.mlab as mlab
import matplotlib.pyplot as plt
matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'
delta = 0.025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-2.0, 2.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)
# Create a simple contour plot with labels using default colors. The
# inline argument to clabel will control whether the labels are draw
# over the line segments of the contour, removing the lines beneath
# the label
plt.figure()
CS = plt.contour(X, Y, Z)
plt.clabel(CS, inline=1, fontsize=10)
plt.title('Simplest default with labels')
plt.show()
現在我希望plt.show()來顯示一個情節,但很可惜,當我運行程序我沒有看到一個情節,而是得到一個錯誤消息說:
import: unable to grab mouse `': Resource temporarily unavailable @ error/xwindow.c/XSelectWindow/9047.
import: unable to grab mouse `': Resource temporarily unavailable @ error/xwindow.c/XSelectWindow/9047.
import: unable to grab mouse `': Resource temporarily unavailable @ error/xwindow.c/XSelectWindow/9047.
import: unable to grab mouse `': Resource temporarily unavailable @ error/xwindow.c/XSelectWindow/9047.
./plotter.py: line 7: matplotlib.rcParams[xtick.direction]: command not found
./plotter.py: line 8: matplotlib.rcParams[ytick.direction]: command not found
./plotter.py: line 10: delta: command not found
./plotter.py: line 11: syntax error near unexpected token `('
./plotter.py: line 11: `x = np.arange(-3.0, 3.0, delta)'
任何想法上如何解決這個問題?
謝謝你的時間。
如何運行程序? – MattDMo