3D 画图,只能使用 add_subplot
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(6.4*3, 4.8*1.1))
ax2d = fig.add_subplot(1, 3, 1)
ax2d.scatter(S_2d[:, 0], S_2d[:, 1], s=1)
ax2d.set_title('State distribution')
ax2d.set_xlabel('State[0]')
ax2d.set_ylabel('State[1]')
# ax2d.set_box_aspect(4.8/6.4)
ax3dsp = fig.add_subplot(1, 3, 2, projection='3d')
ax3dsp.scatter(S_2d[:, 0], S_2d[:, 1], dataset_P, s=1, c='g')
ax3dsp.scatter(S_2d[:, 0], S_2d[:, 1], 0, s=1, c='b')
ax3dsp.set_xlabel('State[0]')
ax3dsp.set_ylabel('State[1]')
ax3dsp.set_zlabel('Policy')
ax3dsp.set_title(r'State $\to$ Policy')
ax3dsv = fig.add_subplot(1, 3, 3, projection='3d')
ax3dsv.scatter(S_2d[:, 0], S_2d[:, 1], dataset_V, s=1, c='g')
ax3dsv.scatter(S_2d[:, 0], S_2d[:, 1], dataset_V.min(), s=1, c='b')
ax3dsv.set_xlabel('State[0]')
ax3dsv.set_ylabel('State[1]')
ax3dsv.set_zlabel('Value')
ax3dsv.set_title(r'State $\to$ Value')
fig.tight_layout()
plt.savefig('./svp.png')