当前位置: 移动技术网 > IT编程>脚本编程>Python > Python实现的圆形绘制(画圆)示例

Python实现的圆形绘制(画圆)示例

2018年02月06日  | 移动技术网IT编程  | 我要评论

姚振华简历,周韦彤 跳水,天使的安排

本文实例讲述了Python实现的圆形绘制。分享给大家供大家参考,具体如下:

# -*- coding:utf-8 -*-
#! python3
import numpy as np
import matplotlib.pyplot as plt
# ==========================================
# 圆的基本信息
# 1.圆半径
r = 2.0
# 2.圆心坐标
a, b = (0., 0.)
# ==========================================
# 方法一:参数方程
theta = np.arange(0, 2*np.pi, 0.01)
x = a + r * np.cos(theta)
y = b + r * np.sin(theta)
fig = plt.figure() 
axes = fig.add_subplot(111) 
axes.plot(x, y)
axes.axis('equal')
plt.title('www.jb51.net')
# ==========================================
# 方法二:标准方程
x = np.arange(a-r, a+r, 0.01)
y = b + np.sqrt(r**2 - (x - a)**2)
fig = plt.figure() 
axes = fig.add_subplot(111) 
axes.plot(x, y) # 上半部
axes.plot(x, -y) # 下半部
plt.axis('equal')
plt.title('www.jb51.net')
# ==========================================
plt.show()

运行效果:

.

更多关于Python相关内容可查看本站专题:《》、《》、《》、《》、《》及《》

希望本文所述对大家Python程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网