当前位置:主页 > 软件编程 > Python代码 >

python实现画圆功能

时间:2021-06-20 08:51:20 | 栏目:Python代码 | 点击:

本文实例为大家分享了python实现画圆功能的具体代码,供大家参考,具体内容如下

# -*- coding: utf-8 -*- 
""" 
__author__= 'Du' 
__creation_time__= '2018/1/4 17:30' 
""" 
 
 
import numpy as np 
import matplotlib.pyplot as plt 
 
 
# 该行用于设置chart 的样式,可以注掉 
# plt.style.use("mystyle") 
 
fig = plt.figure(figsize=(8,8)) 
ax = fig.add_subplot(111) 
ax.spines['left'].set_color('none') 
ax.spines['bottom'].set_color('none') 
ax.spines['right'].set_color('none') 
ax.spines['top'].set_color('none') 
ax.set_xticks([]) 
ax.set_yticks([]) 
 
# 实现功能 
theta = np.arange(0, 2 * np.pi + 0.1,2 * np.pi / 1000) 
x = np.cos(theta) 
y = np.sin(theta) 
 
v = np.linspace(0, 10, 100) 
v.shape = (100, 1) 
 
x = v * x 
y = v * y 
 
plt.plot(x, y, color='pink') 
# plt.savefig('ball1.jpg') 
plt.show() 

效果图:

您可能感兴趣的文章:

相关文章