这篇文章主要为大家详细介绍了 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()
效果图:
来源: http://www.phperz.com/article/18/0220/363249.html