我有下面的代码,它生成一个曲面图,曲面作为网格X,Y的z坐标
该代码还生成一个向量场图,作为相对于同一坐标系X,Y的单独图形
我有没有办法把这两个数字合并成一个数字?向量场是在曲面上还是在曲面图的底部
import numpy as np
import matplotlib.pyplot as plt
import grad_field
# first create the plot of the elevation surface
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
LNG = np.linspace(lngmin,lngmax,samples1)
LAT = np.linspace(latmin,latmax, samples2)
X, Y = np.meshgrid(LNG,LAT)
ax.plot_surface(X, Y, elev_mat)
plt.show()
# now create the vector field plot of the gradients
[gradx,grady] = grad_field.grad_field(elev_mat)
fig1, ax1 = plt.subplots()
ax1.set_title('Arrows scale with plot width, not view')
ax1.quiver(X, Y, gradx, grady, units='xy' ,scale=2, color='red')
plt.show()
您可以通过
plt.subplots(nrows=1, ncols=1)
在彼此的下一个位置创建多个绘图。看看documentation的例子如果要在一个图形中创建多个图形,可以通过
ax.twinx()
或ax.twiny()
共享x轴或y轴相关问题 更多 >
编程相关推荐