For 2D plots, using constrained
or tight
layout is generally enough to adjust the size of the axes to fit labels, but none of the default layouts manages to do it for small 3D plots like the one shown below. I’ve been trying to read about transforms to see if I could manually scale down the axes, but I have never used them before and am struggling to understand how to apply them.
Is there a way to reduce the size of a 3D plot to prevent its labels from exceeding the limits of the subplot?
MWE
<code>import numpy as np
import matplotlib.pyplot as plt
if __name__ == "__main__":
x = np.random.uniform(0, 1, 100)
y = np.random.uniform(0, 1, 100)
z = np.random.uniform(0, 1, 100)
fig = plt.figure(facecolor="green", layout="constrained", figsize=(3, 3))
ax = fig.add_subplot(111, projection="3d", proj_type="ortho")
ax.scatter(x, y, z)
plt.show()
</code>
<code>import numpy as np
import matplotlib.pyplot as plt
if __name__ == "__main__":
x = np.random.uniform(0, 1, 100)
y = np.random.uniform(0, 1, 100)
z = np.random.uniform(0, 1, 100)
fig = plt.figure(facecolor="green", layout="constrained", figsize=(3, 3))
ax = fig.add_subplot(111, projection="3d", proj_type="ortho")
ax.scatter(x, y, z)
plt.show()
</code>
import numpy as np
import matplotlib.pyplot as plt
if __name__ == "__main__":
x = np.random.uniform(0, 1, 100)
y = np.random.uniform(0, 1, 100)
z = np.random.uniform(0, 1, 100)
fig = plt.figure(facecolor="green", layout="constrained", figsize=(3, 3))
ax = fig.add_subplot(111, projection="3d", proj_type="ortho")
ax.scatter(x, y, z)
plt.show()