Unlike with a 2D plot, where putting in a legend automatically places the legend within the axes of the plot, for plot3 I'm finding that the legend is automatically placed outside the bounds of the axes. This creates an ugly amount of unnecessary grey space. To fix this I have to manually drag the legend back into the axes range. This is tedious and unacceptable when generating many such figures within a loop.
How can I force the legend to be placed within the axes bounds?