擅长:python、mysql、java
<p>跟踪@increment的答案;下面的函数生成一个以0,0为中心的argand图,并缩放到复数集中的最大绝对值。</p>
<p>我使用plot函数并指定了(0,0)中的实线。这些可以通过用<code>ro</code>替换<code>ro-</code>来删除。</p>
<pre><code>def argand(a):
import matplotlib.pyplot as plt
import numpy as np
for x in range(len(a)):
plt.plot([0,a[x].real],[0,a[x].imag],'ro-',label='python')
limit=np.max(np.ceil(np.absolute(a))) # set limits for axis
plt.xlim((-limit,limit))
plt.ylim((-limit,limit))
plt.ylabel('Imaginary')
plt.xlabel('Real')
plt.show()
</code></pre>
<p>例如:</p>
<pre><code>>>> a = n.arange(5) + 1j*n.arange(6,11)
>>> from argand import argand
>>> argand(a)
</code></pre>
<p>产生:
<img src="https://i.stack.imgur.com/UFZIW.png" alt="argand function output graph"/></p>
<p><strong>编辑:</strong></p>
<p>我刚刚意识到还有一个<a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.polar" rel="noreferrer">^{<cd3>}</a>绘图函数:</p>
<pre><code>for x in a:
plt.polar([0,angle(x)],[0,abs(x)],marker='o')
</code></pre>
<p><img src="https://i.stack.imgur.com/4DiuB.png" alt="enter image description here"/></p>