python绘制散度垂直剖面图的代码
时间: 2023-04-05 22:04:05 浏览: 659
基于python的散点图绘制与实现
以下是Python绘制散度垂直剖面图的代码:
```python
import numpy as np
import matplotlib.pyplot as plt
# 生成数据
x = np.linspace(-np.pi, np.pi, 100)
y = np.linspace(-np.pi, np.pi, 100)
X, Y = np.meshgrid(x, y)
U = np.cos(X)
V = np.sin(Y)
# 计算散度
div = np.gradient(U, x, axis=1) + np.gradient(V, y, axis=0)
# 绘制散度垂直剖面图
fig, ax = plt.subplots()
c = ax.contourf(X, Y, div, cmap='RdBu')
fig.colorbar(c)
ax.set_title('Divergence Vertical Profile')
plt.show()
```
希望对你有帮助!
阅读全文