These are my configurations using matplotlib for my plotting figures
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax_tl = fig.add_subplot(211, projection='3d')
ax_br = fig.add_subplot(221, projection='3d')
ax_Y0 = fig.add_subplot(212, projection='3d')
ax_Y1 = fig.add_subplot(222, projection='3d')
I tried many different combinations of fig.add_plot()
first argument and drew inspiration from this document.
Im currently considering just to plot them separately if its not worth the hassle.
So the question is, how do I plot a 2 x 2 three dimensional figure of scatter based subplots in python to make them evenly spread out across the figure? My current code makes the plots squished together
CodePudding user response:
This should do what you want:
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
spec = gridspec.GridSpec(ncols=2, nrows=2, figure=fig)
ax_tl = fig.add_subplot(spec[0, 0], projection='3d')
ax_br = fig.add_subplot(spec[0, 1], projection='3d')
ax_Y0 = fig.add_subplot(spec[1, 0], projection='3d')
ax_Y1 = fig.add_subplot(spec[1, 1], projection='3d')