答案 0 :(得分:1)
您可以使用figure.add_axes
将轴放置在任意位置。
fig = plt.figure()
fig.add_axes([0.1,0.2,0.3,0.4])
在图坐标中将轴放置在x = 0.1,y = 0.2,宽度= 0.3,高度= 0.4。
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_axes([0.4,0.1,0.5,0.6], projection='3d')
X, Y = np.meshgrid(np.arange(-5, 5, 0.25), np.arange(-5, 5, 0.25))
Z = np.sin(np.sqrt(X**2 + Y**2))
surf = ax.plot_surface(X, Y, Z, cmap="plasma")
ax = fig.add_axes([0.3,0.4,0.3,.4])
plt.plot([1,2,3])
plt.show()