绘制想象与真实价值观

时间:2014-02-23 05:51:10

标签: python

我有一个包含实部和虚部的复数值列表。

我想绘制虚数值(在y轴上),域限制从-1到+1与实数值(在x轴上),域限制从-10到10。

我该如何做到这一点?

提前致谢。

1 个答案:

答案 0 :(得分:0)

使用matplotlib

values = [
    -19.5-1.22j, -19-0.3j, -18.5+0.68j, -18+1.5j, -17.5+1.96j, -17+1.92j,
    -16.5+1.42j, -16+0.58j, -15.5-0.42j, -15-1.3j, -14.5-1.86j, -14-1.98j,
    -13.5-1.6j, -13-0.84j, -12.5+0.14j, -12+1.08j, -11.5+1.76j, -11+2j,
    -10.5+1.76j, -10+1.08j, -9.5+0.16j, -9-0.82j, -8.5-1.6j, -8-1.98j,
    -7.5-1.88j, -7-1.32j, -6.5-0.44j, -6+0.56j, -5.5+1.42j, -5+1.92j,
    -4.5+1.96j, -4+1.52j, -3.5+0.7j, -3-0.28j, -2.5-1.2j, -2-1.82j,
    -1.5-2j, -1-1.68j, -0.5-0.96j, 0j, 0.5+0.96j, 1+1.68j,
    1.5+2j, 2+1.82j, 2.5+1.2j, 3+0.28j, 3.5-0.7j, 4-1.52j,
    4.5-1.96j, 5-1.92j, 5.5-1.42j, 6-0.56j, 6.5+0.44j, 7+1.32j,
    7.5+1.88j, 8+1.98j, 8.5+1.6j, 9+0.82j, 9.5-0.16j, 10-1.08j,
    10.5-1.76j, 11-2j, 11.5-1.76j, 12-1.08j, 12.5-0.14j, 13+0.84j,
    13.5+1.6j, 14+1.98j, 14.5+1.86j, 15+1.3j, 15.5+0.42j, 16-0.58j,
    16.5-1.42j, 17-1.92j, 17.5-1.96j, 18-1.5j, 18.5-0.68j, 19+0.3j, 19.5+1.22j,
]

import matplotlib.pyplot as plt
x = [min(max(v.real, -10), 10) for v in values]
y = [min(max(v.imag, -1), 1) for v in values]
plt.plot(x, y)
plt.show()

enter image description here