2010-08-09 91 views

回答

35

下面是一個例子,使用pylab.Circle

import numpy as np 
import matplotlib.pyplot as plt 

e = np.e 
X, Y = np.meshgrid(np.linspace(0, 5, 100), np.linspace(0, 5, 100)) 
F = X ** Y 
G = Y ** X 

fig = plt.figure() 
ax = fig.add_subplot(1, 1, 1) 
circ = plt.Circle((e, e), radius=0.07, color='g') 
plt.contour(X, Y, (F - G), [0]) 
ax.add_patch(circ) 
plt.show() 

enter image description here

here is another example從文檔(雖然不是等高線圖)。

或者,你可以只使用plot

import numpy as np 
import matplotlib.pyplot as plt 

e = np.e 
X, Y = np.meshgrid(np.linspace(0, 5, 100), np.linspace(0, 5, 100)) 
F = X ** Y 
G = Y ** X 

fig = plt.figure() 
ax = fig.add_subplot(1, 1, 1) 
plt.contour(X, Y, (F - G), [0]) 
plt.plot([e], [e], 'g.', markersize=20.0) 
plt.show() 

enter image description here

+0

你能解釋一下第一代碼片段嗎? – 2014-03-31 07:10:38

+0

讓我們一行一行。第一行沒有意義? – unutbu 2014-03-31 11:01:41

+0

'F = X ** Y G = Y ** X ' 這是一個 – 2014-03-31 12:06:29