0
我打算在matplotlib
中創建一個圖形,左邊是3D表面,右邊是對應的等高線圖。Python Subplot 3d Surface and Heat Map
我使用了subplots
,但它只顯示等值線圖(帶有表面的空白空間)和表面的單獨圖形。
是否可以在一個圖中並排創建這些圖?
編輯:代碼如下:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
import numpy as np
x = np.arange(-5, 5, 0.25)
y = np.arange(-5, 5, 0.25)
x, y = np.meshgrid(x, y)
r = np.sqrt(x**2 + y**2)
z = np.sin(r)
fig, (surf, cmap) = plt.subplots(1, 2)
fig = plt.figure()
surf = fig.gca(projection='3d')
surf.plot_surface(x,y,z)
cmap.contourf(x,y,z,25)
plt.show()
你可以顯示你的代碼,你目前如何做到這一點? –
是的,但顯示所需的輸出 – Serenity
有關於此的[官方示例](https://matplotlib.org/examples/mplot3d/mixed_subplots_demo.html)。如果您遇到執行問題,請參閱[問]和[mcve]。 – ImportanceOfBeingErnest