matplotlib 等高线图日志zlog⁡z在复平面CC

计算科学 有限差分 数值分析 麻木的 网格生成
2021-12-22 14:36:49

我尝试在对数上使用 Python 的 matplotlib,这就是我得到的,一种星爆模式。由于角度在θ=0θ=2π, 轮廓假设这两个点之间有一条轮廓线。这里实际上是0=2π

或许可以用和语句来代替matplotlib.pyplot.contour轮廓线。meshgridnumpy.where

上的等高线图logzz[1,1]+i[1,1]

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize']=4,4

plt.contour(
    np.arange(-1,1,0.01),
    np.arange(-1,1,0.01), 
    np.angle(t[...,None] + 1j*t[None,...]) , 
    levels = 2*np.pi*np.arange(-1,1,0.025)
)

在此处输入图像描述

等高线在负虚轴处累积iR0

t = np.arange(-1,1,0.025)
plt.contour(t,t, np.angle(t[...,None] + 1j*t[None,...]) , levels = 2*np.pi*np.arange(-1,1,0.025))

L = 0.25
plt.xlim([-L,L])
plt.ylim([-L,L])

在此处输入图像描述


代码检查

import inspect
print inspect.getsource(plt.contour)

@_autogen_docstring(Axes.contour)
def contour(*args, **kwargs):
    ax = gca()
    # allow callers to override the hold state by passing hold=True|False
    washold = ax.ishold()
    hold = kwargs.pop('hold', None)
    if hold is not None:
        ax.hold(hold)
    try:
        ret = ax.contour(*args, **kwargs)
        draw_if_interactive()
    finally:
        ax.hold(washold)
    if ret._A is not None: sci(ret)
    return ret

 

print inspect.getsource(plt.Axes.contour)

def contour(self, *args, **kwargs):
    if not self._hold:
        self.cla()
    kwargs['filled'] = False
    return mcontour.QuadContourSet(self, *args, **kwargs)

 

最后可以调用包含实际源代码的函数:

import matplotlib
print inspect.getsource(matplotlib.contour.QuadContourSet)
0个回答
没有发现任何回复~