椭球绘制-Python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(1) #定义figure
ax = Axes3D(fig) #将figure变为3D
x1 = np.arange(-10,10,0.2) #定义x1,范围[-10,10],间隔为0.2
x2 = np.arange(-10,10,0.2)
X1,X2 = np.meshgrid(x1,x2) # 生成网格
F = X1**2+X2**2 # 计算平方和
# 绘制3D曲面
ax.plot_surface(X1,X2,F,rstride = 1,cstride = 1,cmap = plt.get_cmap('rainbow'))
# rstride:行之间的跨度,cstride:列之间的跨度,cmap:控制三维曲面的颜色组合
plt.show()