0

I want to have a wide 3d plot inside my Jupyter Notebook. I have tried almost everything I have found, but when using the 3D axes, the plot seems to be bound by a 1:1 square.

How do I make the 3D plot fill the whole subplot? I'd like the 3D "viewport" to be as wide as the 2D plot.

You can see that the regular 2D plot is scaled as it should.

Example code:

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

plt.rcParams["axes.facecolor"] = "cyan"
plt.rcParams["figure.facecolor"] = "yellow"

fig1=plt.figure(figsize=(8,5))
ax11=fig1.add_subplot(211,projection='3d')
ax12=fig1.add_subplot(212)
ax11.set_box_aspect(aspect = (4,2,1))

Current output

I've tried set_box_aspect() but that only changes the aspect ratio of the graph area inside the square bounding box. I have tested both the 'inline' and 'notebook' backends of Jupyter Notebook.

I've also tried setting %config InlineBackend.print_figure_kwargs={'bbox_inches': 'tight'} but that did not resolve the issue of scaling the cyan bounding square in my example.

EDIT: Downgrading from matplotlib 3.5.1 to 3.2.2 (as suggested in: matplotlib: fit 3d plot into the fixed-sized figure) seems to produce wanted results. However, could I somehow reproduce this in 3.5.1 ?

0 Answers0