mathplotlib imshow complex 2D array

后端 未结 4 1735
心在旅途
心在旅途 2021-02-05 16:32

Is there any good way how to plot 2D array of complex numbers as image in mathplotlib ?

It makes very much sense to map magnitude of complex number as \"brightness\" or

4条回答
  •  心在旅途
    2021-02-05 17:21

    The library mpmath uses matplotlib to produce beautiful images of the complex plane. On the complex plane you usually care about the poles, so the argument of the function gives the color (hence poles will make a spiral). Regions of extremely large or small values are controlled by the saturation. From the docs:

    By default, the complex argument (phase) is shown as color (hue) and the magnitude is show as brightness. You can also supply a custom color function (color). This function should take a complex number as input and return an RGB 3-tuple containing floats in the range 0.0-1.0.

    Example:

    import mpmath
    mpmath.cplot(mpmath.gamma, points=100000)
    

    enter image description here

    Another example showing the zeta function, the trivial zeros and the critical strip:

    import mpmath
    mpmath.cplot(mpmath.zeta, [-45,5],[-25,25], points=100000)
    

    enter image description here

提交回复
热议问题