这篇文章主要介绍了用python画圆代码含turtle,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。
本文实例为大家分享了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