MVMV
MVMV

Reputation: 37

How to rearrange the axes in a 3D plot?

Here is the code I'm running to plot a 2D ellipse on the "z=10 wall" of the plot:

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
import mpl_toolkits.mplot3d.art3d as art3d

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Draw a circle on the z=10 'wall'
p = Ellipse((0, 0), 6, 3, fill=False)
ax.add_patch(p)
art3d.pathpatch_2d_to_3d(p, z= 10, zdir="z")

ax.set_xlim(-10, 10)
ax.set_ylim(-10, 10)
ax.set_zlim(-10, 10)

plt.show()

However it seems that the depth axis here is considered to be y:

enter image description here

I'd like to have the y axis be what the z axis is right now, the x axis be what the y axis is right now, and the z axis be what the x axis is right now. Would you know how to rearange these axes?

Upvotes: 0

Views: 679

Answers (1)

Karina
Karina

Reputation: 1280

ax.view_init(elev=30, azim=45)

enter image description here

ax.view_init(elev=30, azim=-60)

enter image description here

Upvotes: 1

Related Questions