I have a code in python to render a few spheres in python that looks like this:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import random
import mayavi
from mayavi import mlab
N = 4;
diams = .4*np.ones([N]);
xvals = np.arange(N);
yvals = np.zeros(N);
zvals = np.zeros(N);
pts = mlab.points3d(xvals, yvals, zvals, diams, scale_factor=1,transparent=True)
mlab.show()
The default view of the figure adds distortion based on the camera position (farther spheres smaller). I'd like to set the to parallel projection (farther spheres same size) by some command so it renders like this automatically.
I didn't find a straightforward solution with google or the documentation. Thanks!
Try setting fig.scene.parallel_projection = True
or mlab.gcf().scene.parallel_projection = True
in your case.
As a quick example, compare (zoomed in to magnify differences):
import numpy as np
from mayavi import mlab
np.random.seed(1977)
x, y, z = np.random.random((3, 10))
mlab.points3d(x, y, z)
mlab.show()
And when we set an orthogonal projection:
import numpy as np
from mayavi import mlab
np.random.seed(1977)
x, y, z = np.random.random((3, 10))
mlab.points3d(x, y, z)
mlab.gcf().scene.parallel_projection = True
mlab.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With