I've created a figure with this
fig8 = plt.figure()
ax8 = fig8.gca(projection = '3d')
ax8.set_xlim(0,0.8)
It gives me this
enter image description here
My problem is I really need the limit of axis x to be exactly 0.8. It seems that matplotlib always make the axis a little bit longer than the limits that we've set. Any idea?
-
Does this answer your question? Removing axes margins in 3D plotScott– Scott2023年09月19日 02:29:32 +00:00Commented Sep 19, 2023 at 2:29
2 Answers 2
It seems to be hard-coded: https://github.com/matplotlib/matplotlib/blob/master/lib/mpl_toolkits/mplot3d/axis3d.py#L178
If you replace this line by:
deltas = 0*(maxs - mins) / 12.
you get the desired output but labels are now weirdly positioned.
Thanks @Nicolas Rougier for the suggestion
to fix the positions of the labels, instead of changing that line. I kept it and change the two lines below
deltas = (maxs - mins) / 12.
mins = mins
maxs = maxs
It works!!!!