This is my first time using stackoverflow. mplot3d seems to automatically centre the camera around the centre of mass of everything that has been plotted on the axis such that everything is always in view. In my basic example I plot a sphere of radius 10 centred at (0, 0, 10), mplot3d automatically centres the camera at (0, 0, 10) so the sphere always fills the plot. Is there any way I can disable this behavour so the camera remains centred at (0, 0, 0) or better still, manually lock the camera centre position to a set of coordinates?
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d
fig = plt.figure(figsize=(5,5))
sphere = fig.add_subplot(111, projection="3d")
phi = np.linspace(0, 2 * np.pi, 20)
theta = np.linspace(0, np.pi, 20)
xpt = 10 * np.outer(np.cos(phi), np.sin(theta))
ypt = 10 * np.outer(np.sin(phi), np.sin(theta))
zpt = 10 * np.outer(np.ones(np.size(phi)), np.cos(theta))
zpt = zpt+10
sphere.plot_surface(xpt, ypt, zpt, color="#00f3ff", alpha=1)
sphere.view_init(azim=0, elev=0)
sphere.disable_mouse_rotation()
plt.show()
Output demo:
If not can anybody suggest any other packages with similar 3d plotting capabilities that will give me more control?