Anaconda3.exe
首先,奉上圆的公式:
接着我们使用matplotlib建立画布:
圆面的第一种实现方法:
圆面第一种的效果如下:
圆面的第二种实现方法:
圆面第二种的效果如下:
圆面的第三种实现方法:
圆面第三种的效果如下:
import numpy as npimport 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 * xy = v * yplt.plot(x, y, color='red')plt.show()
import numpy as npimport 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, 2 * np.pi / 100)theta = np.append(theta, [2 * np.pi])x = np.cos(theta)y = np.sin(theta)v = np.linspace(0, 10, 100)for r in v: x1 = r * x y1 = r * y plt.plot(x1, y1)plt.show()
import numpy as npimport matplotlib.pyplot as pltfrom matplotlib import colors# 该行用于设置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, 2 * np.pi / 1000)theta = np.append(theta, [2 * np.pi])v = np.linspace(0, 10, 10)mx = np.max(theta)for tha in theta: x1 = v * np.cos(tha) y1 = v * np.sin(tha) c = tha / mx plt.plot(x1, y1,color=(x1[0], c, y1[0]))plt.show()END