I am trying to rotate a 3D scatter plot so that it looks like a 2D scatter plot of the same but rotated data.
I tried to adjust the rotation wit some fixed amount but that seems to not be enough. My question is what the correct way for my goal is. Maybe there is even a conversion function that i have not found in the api.

def main():
points = [[-0.5, 0.5, 0.5], [0, -0.5, 0.5], [0.5, 0, 0]]
points = np.array(points)
# I have some rotation. this comes from an other software in radian.
# I only need two of the rotations, Z and either x or y
degree = [0, 30, -60]
rotation = np.deg2rad(degree)
rx, ry, rz = rotation
rotated = rotate(rotated, rx, ry, rz) # 3D rotation mat
# Plot 2D: rotated points, Just ignore z
#...
ax3.scatter(rotated[:, 0], rotated[:, 1])
degree = np.rad2deg(rotation)
dx, dy, dz = degree
azim, elev = rotation2mpl(dx, dy, dz)
# Plot 3D and adjust view
#...
ax2.scatter3D(points[:, 0], points[:, 1], points[:, 2])
ax2.view_init(azim=azim, elev=elev)
def rotation2mpl(dx, dy, dz):
# ???
return azimuth, elevation

I have a list of points and two rotation angles. Either around Z and X or around Z and Y. With this i produce a set of rotated point via constructing the rotation matrices and multiplying that with my points.

Now i want to not rotate the points myself but use the rotation of matplotlib to achieve the same result. For that i need to convert my rotation angles to azimuth and elevation as used in matplitlibs view_init function.
The problem is that the documentation of view_init is very sparse. I’m not sure what ranges the values have, in which direction the rotations are and in which order the rotations are applied.

Unfortunately, I’m not sure it will be possible to replicate completely arbitrary rotations, because we only provide two (and a half?) degrees of freedom.

The vertical_axis argument determines which way is ‘up’. The elevation argument is angle in degrees from the plane perpendicular to the vertical axis (thus ±90°). The azimuth is rotation around the vertical axis, so ±180°, but I’m not sure where it starts.

See the diagrams and videos in this PR (which adds the third degree of freedom, but is not released yet):

@quantum.analyst Thank you for the information. I had already found the two linked resources and i have already found a solution in the mean time.

For me it is enough to add 90 degrees to both of my angles and then invert the azimuth angle (-azimuth % 360). My azimuth is in the range of 0, 360 and my elevation in 0, 180. When rotating my points the azimuth is used for a rotation around z and the elevation is used for a rotation around x. I also have the z and x rotations in reverse order from what you find on for example Wikipedia.