ref: https://matplotlib.org/api/_as_gen/matplotlib.pyplot.contour.html
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 10.0, 0.1)
y = np.arange(0, 10.0, 0.1)
X, Y = np.meshgrid(x, y) # 生成x-y网格图
Z = X**1.5 + Y**1.5
plt.figure()
CS = plt.contour(X, Y, Z, levels=6) # 设置距离
plt.clabel(CS, inline=1, fontsize=10, fmt='%d ℃') # 设置标签
plt.savefig('Temp.png', dpi=300, bbox_inches='tight')
plt.show()
Temp.png
网友评论