how rotate z-axis of matplotlib figure appears horizontal axis? have created following 3d figure :
i tried adjusting values in
ax.view_init() no matter values used, can't flip z-axis orientation of 3 axes appear ones in following figure:
i thought of changing 3 components of data use x-axis plot z-component of data, inconvenient many of calculations, , more importantly, don't know how use ax.set_aspect keep whole figure in same scale in rectangular box (rectangular because (original) z-component of data spans larger range x , y components).
so how rotate z-axis (by 90 deg)?
edit:
just clarify question. using example used in answer, have following code can generate figure has same scale in 3 axes, , if resize pop-out window, figure still has same aspect ratio 3 axes , same. want, z-axis rotated 90deg appears horizontal (the desired coordinate system 1 shown in above figure of em wave). if switch plotting order of 3 axes, horizontal z-axis (which plotted x-axis), can't use ax.set_aspect change scale.
from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot plt import numpy np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x, y, z = axes3d.get_test_data(0.05) ax.plot_wireframe(x, y, z, rstride=10, cstride=10) ax.set_xlim(-30,30) ax.set_ylim(-30,30) ax.set_zlim(-90,90) ax.set_aspect(3, 'box-forced') plt.show()
can change order of x,y,z values pass plotting function?
using this example:
from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot plt import numpy np fig = plt.figure() ax = fig.add_subplot(111, projection='3d') x, y, z = axes3d.get_test_data(0.05) ax.plot_wireframe(x, y, z, rstride=10, cstride=10) plt.show()
changing input order:
ax.plot_wireframe(x, z, y, rstride=10, cstride=10)
Comments
Post a Comment