matplotlib绘图_matplotlib 使用极坐标绘图

在使用matplotlib.pyplot的subplot()函数创建图形区域时,可以设定参数projection='polar',或者 polar=True,就可以在极坐标下绘制图形。

52cb5aa089489845de65c7b06b4a27a9.png
import matplotlib as mplimport matplotlib.pyplot as pltimport numpy as npmpl.rcParams["font.sans-serif"] = ["SimHei"]pi = np.pitheta=np.arange(0,2*pi,0.02)#极角,弧度制r1 = theta /6.0 #半径r2 = 1*(1 -np.sin(theta))r3 = 3+ np.cos(7* theta)e = 0.5p= 1.0r4 = e*p / (1 - e*np.cos(theta))ax1= plt.subplot(221, projection='polar')#使用极坐标ax1.plot(theta, r1, "g-")#螺旋线ax2= plt.subplot(222, polar =True)ax2.plot(theta, r2,'r-',lw=2)#心形曲线#ax2.set_rlim(0.6,1.2) # 可设定半径范围#ax2.set_thetalim(pi, 2*pi) # 可设定极角范围ax3= plt.subplot(223, polar =True)#使用极坐标ax3.plot(theta, r3,'b-')ax4= plt.subplot(224, polar =True)#使用极坐标ax4.plot(theta, r4,'m-') #椭圆plt.tight_layout()plt.suptitle("使用极坐标绘图
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值