我有下面的代码,它生成了一个曲面图,其中一个曲面是相对于网格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()
发布于 2021-05-08 23:20:41
您可以通过plt.subplots(nrows=1, ncols=1)
创建多个彼此相邻/下方的绘图。请看documentation中的示例。
如果要在一个绘图中创建多个绘图,可以通过ax.twinx()
或ax.twiny()
共享x或y轴。
https://stackoverflow.com/questions/67449022
复制相似问题