Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MRG: Correct camera view_up when necessary #7187

Merged
merged 2 commits into from
Jan 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion mne/viz/backends/_pyvista.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,20 @@ def _set_3d_view(figure, azimuth, elevation, focalpoint, distance):
if focalpoint is not None:
cen = np.asarray(focalpoint)

# Now calculate the view_up vector of the camera. If the view up is
# close to the 'z' axis, the view plane normal is parallel to the
# camera which is unacceptable, so we use a different view up.
if elevation is None or 5. <= abs(elevation) <= 175.:
view_up = [0, 0, 1]
else:
view_up = [np.sin(phi), np.cos(phi), 0]

position = [
r * np.cos(phi) * np.sin(theta),
r * np.sin(phi) * np.sin(theta),
r * np.cos(theta)]
figure.plotter.camera_position = [
position, cen, [0, 0, 1]]
position, cen, view_up]


def _set_3d_title(figure, title, size=40):
Expand Down