2018-09-15更新
今天发现sympy依赖的库mpmath里也有很多数学函数,其中也有在复平面绘制二维图的函数cplot,具体例子如下

from mpmath import *def f1(z):return zdef f2(z):return z**3def f3(z):return (z**4-1)**(1/4)def f4(z):return 1/zdef f5(z):return atan(z)def f6(z):return sqrt(z)cplot(f1)
cplot(f2)
cplot(f3)
cplot(f4)
cplot(f5)
cplot(f6)

参照matlab绘制复变函数的例子,使用python实现绘制复变函数图像,网上还没搜到相关的文章,在这里分享出来供大家学习。

'''
参照matlab绘制复变函数的例子,创建函数cplxgrid,cplxmap,cplxroot
'''
# 1.导入相关库
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import *# 2.创建函数
def cplxgrid(m):'''Return polar coordinate complex grid.Parameters----------m: intReturns----------z: ndarray,with shape (m+1)-by-(2*(m+1))'''m = mr = np.arange(0,m).reshape(m,1) / mtheta = np.pi * np.arange(-m,m) / mz = r * np.exp(1j * theta)return zdef cplxroot(n=3,m=20):'''cplxroot(n): renders the Riemann surface for the n-th rootcplxroot(): renders the Riemann surface for the cube root.cplxroot(n,m): uses an m-by-m grid.  Default m = 20.Use polar coordinates, (r,theta).Use polar coordinates, (r,theta).Parameters----------n: n-th rootm: intReturns----------None: Plot the Riemann surface'''m = m+1r = np.arange(0,m).reshape(m,1) / mtheta = np.pi * np.arange(-n * m, n * m) / mz = r * np.exp(1j * theta)s = r * (1/n) * np.exp(1j * theta / n)fig = plt.figure()ax = fig.add_subplot(111,projection='3d')# ax.plot_surface(np.real(z),np.imag(z),np.real(s),color = np.imag(s))ax.plot_surface(np.real(z),np.imag(z),np.real(s),cmap = plt.cm.hsv)ax.set_xlim((-1,1))ax.set_ylim((-1,1))ax.set_xlabel('Real')ax.set_ylabel('Imag')ax.set_xticks([])ax.set_yticks([])ax.set_zticks([])ax.set_autoscalez_on(True)#z轴自动缩放   ax.grid('on')plt.show()def cplxmap(z,cfun):'''Plot a function of a complex variable.Parameters----------z: complex planecfun: complex function to plotReturns----------None: Plot the surface of complex function'''blue = 0.2x = np.real(z)y = np.imag(z)u = np.real(cfun)v = np.imag(cfun)M = np.max(np.max(u))#复变函数实部最大值m = np.min(np.min(u))#复变函数实部最大值s = np.ones(z.shape)fig = plt.figure()ax = fig.add_subplot(111,projection='3d')# 投影部分用线框图surf1 = ax.plot_wireframe(x,y,m*s,cmap=plt.cm.hsv)surf2 = ax.plot_surface(x,y,u,cmap=plt.cm.hsv)#绘制复变函数1/z时会出错,ValueError: Axis limits cannot be NaN or Inf# ax.set_zlim(m, M)   ax.set_xlim((-1,1))ax.set_ylim((-1,1))ax.set_xlabel('Real')ax.set_ylabel('Imag')ax.set_xticks([])ax.set_yticks([])ax.set_zticks([])ax.set_autoscalez_on(True)#z轴自动缩放ax.grid('on')plt.show()def _test_cplxmap():'''测试cplxmap函数'''z = cplxgrid(30)w1 = zw2 = z**3w3 = (z**4-1)**(1/4)w4 = 1/zw5 = np.arctan(2*z)w6 = np.sqrt(z)w = [w1,w2,w3,w4,w5,w6]for i in w:cplxmap(z,i)def _test_cplxroot():'''测试cplxroot函数'''cplxroot(n=2)cplxroot(n=3)cplxroot(n=4)cplxroot(n=5)if __name__ == '__main__':_test_cplxmap()_test_cplxroot()

python/Matplotlib绘制复变函数图像相关推荐

  1. python matplotlib绘制 3D图像专题 (三维柱状图、曲面图、散点图、曲线图合集)

    python matplotlib 绘制3D图表 文章目录 1. 绘制3D柱状图 2. 绘制3D曲面图 ① 示例1 ② 示例2 3.绘制3D散点图 4. 绘制3D曲线图       ʚʕ̯•͡˔•̯᷅ ...

  2. matplotlib绘制3D图像

    用Axes3D类创建3d ax import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3Dfig = plt.fig ...

  3. Python matplotlib 绘制量场图

    复习回顾 matplotlib 是基于Python语言的开源项目,pyplot提供一系列绘制2D图形的方法.随着版本的迭代,matplotlib 模块也支持绘制3D图形mplot3d工具包,制作动态图 ...

  4. 不愧是摸鱼高手Python matplotlib 绘制频谱图都会,能怪老板不管

    复习回顾 matplotlib 是Python专门用来绘制渲染的模块,其底层主要分为脚本层.美工层和后端.脚本层为我们提供常见图形绘制如折线.柱状.直方.饼图.以往文章 这么详细的Python mat ...

  5. Python matplotlib 绘制等高线图

    前言 我们在往期对matplotlib.pyplot()方法学习,到现在我们已经会绘制折线图.柱状图.散点等常规的图表啦(往期的内容如下,大家可以方便查看往期内容) python入门到进阶,爬虫数据分 ...

  6. Python matplotlib绘制直方图

    Python matplotlib绘制直方图 前面的文章介绍了使用matplotlib绘制折线图.散点图和柱状图,柱状图参考:https://blog.csdn.net/weixin_43790276 ...

  7. Python+matplotlib绘制函数曲线查找函数极值

    推荐图书: <Python程序设计基础(第2版)>,ISBN:9787302490562,董付国,清华大学出版社,第16次印刷,清华大学出版社2019年度畅销图书 图书详情: 配套资源:用 ...

  8. Python实现绘制函数图像——以Sigmoid函数为例

    在深度学习的研究中,我们经常需要知道激活函数(阶跃函数)的图像,以此判断该神经网络的阈值,并更好的去对权重进行调整.但对于某些复杂的复合函数而言,我们非常困难手画出它的函数图像,这样不仅费时费力,而且 ...

  9. python实现绘制函数图像

    目录 python实现绘制二次函数图像 python实现绘制三维函数图像 python实现绘制二次函数图像 import matplotlib.pyplot as plt import numpy a ...

  10. Python matplotlib绘制散点图

    Python matplotlib绘制散点图 上篇文章介绍了使用matplotlib绘制折线图,参考:https://blog.csdn.net/weixin_43790276/article/det ...

最新文章

  1. 从工业云到工业互联网平台演进的五个阶段
  2. 最小安装虚拟机命令行安装图形化
  3. Applese 的回文串(加一个字符的回文)
  4. 论文浅尝 | 基于常识知识图谱感知和图注意力机制的对话生成
  5. 【Spring】Spring boot的ApplicationContextAware 实现获取service
  6. Mac 切换仓库地址后每次都要重新输入密码
  7. 自动化测试基础篇--Selenium多窗口、句柄问题
  8. 【.md格式文件编辑器】几款主流好用的markdown编辑器介绍
  9. 《理财市场情绪监测系统》代码实现【1】之行业词库
  10. 【STM32-FatFs】FAT文件系统原理
  11. Centos修复boot分区
  12. QCC3040---uart configuration
  13. Linux如何用link命令停网卡,如何使用 ethtool 命令管理以太网卡 | Linux 中国
  14. 基于Bootstrap垂直响应的jQuery时间轴特效
  15. 思科警告:旗下某些产品可能存在无法修补的WannaCrypt漏洞
  16. 亚商投资顾问 早餐FM/0928 养老金抵扣个税优惠来了
  17. [luogu]P1600 天天爱跑步[LCA]
  18. 【20保研】北京大学信息工程学院关于举办 “2019年全国优秀大学生夏令营”的通知...
  19. php下载文件并重命名,通过php下载文件并重命名
  20. 基于nodemailer使用阿里云企业邮箱发送邮件(526错误的解决)

热门文章

  1. 旗舰手机的拍照芯片(上)
  2. java中的传参是什么意思_Java中参数传递是传值还是传址?
  3. 双11临近,电脑无缘无故的弹出了双11天猫广告,必须追踪到底
  4. JavaScript事件代理(事件委托)
  5. Ubuntu Server 18.04配置无线Wifi网卡
  6. SAP采购订单价格与信息记录价格不匹配
  7. 计算机和游戏建立不了连接,如何建立局域网我们寝室的电脑想连接起来玩游戏我们每个人都有网号我 爱问知识人...
  8. ios13.5.1降级_升级iOS 14尝鲜后 无法降级iOS13.5.1?
  9. 安卓开发日记APP史上最详细(SharedPreferences+Room)
  10. 2021年转行软件测试能有前景吗?