python matplotlib 绘制等高线
"""
绘制等高线
"""
import numpy
as np
import matplotlib
.pyplot
as mp
num
= 500
x
, y
= np
.meshgrid
(np
.linspace
(-3, 3, num
),
np
.linspace
(-3, 3, num
))
print(x
[:4], "-->X")
print(y
[:4], "-->y")
z
= (1 - x
/ 2 + x
** 5 + y
** 3) * np
.exp
(-x
** 2 - y
** 2) * 10
mp
.figure
("Contour", facecolor
="lightgray", figsize
=(8, 6))
mp
.title
("Contour", fontsize
=20)
mp
.contourf
(x
, y
, z
, 10, cmap
="jet")
cnt_r
= mp
.contour
(x
, y
, z
, 10, colors
="b", linewidths
=0.5)
mp
.clabel
(cnt_r
, inline_spacing
=0.1, fmt
="%.2f", fontsize
=8)
mp
.show
()
转载请注明原文地址:https://ipadbbs.8miu.com/read-52395.html