python - Reverse Z Axis on matplotlib 3D Plot -
how 1 reverse order on z axis of 3d plot (i.e. negative up, , positive down)? following code produces cone base pointing downward; there command (like ax.reverse_zlim3d(true)
or something?) can used change tick order?
the following code plots cone base pointing downward. reverse z-axis order plots base pointing up, ice cream cone, -1 @ top of graph instead of bottom.
from matplotlib import pyplot p mpl_toolkits.mplot3d import axes3d # @unusedimport import numpy np math import pi, cos, sin z = np.arange(0, 1, 0.02) theta = np.arange(0, 2 * pi + pi / 50, pi / 50) fig = p.figure() axes1 = fig.add_subplot(111, projection='3d') zval in z: x = zval * np.array([cos(q) q in theta]) y = zval * np.array([sin(q) q in theta]) axes1.plot(x, y, -zval, 'b-') axes1.set_xlabel("x label") axes1.set_ylabel("y label") axes1.set_zlabel("z label") p.show()
use invert_zaxis
method of axes3d
:
from matplotlib import pyplot p mpl_toolkits.mplot3d import axes3d # @unusedimport import numpy np math import pi, cos, sin z = np.arange(0, 1, 0.02) theta = np.arange(0, 2 * pi + pi / 50, pi / 50) fig = p.figure() axes1 = fig.add_subplot(111, projection='3d') zval in z: x = zval * np.array([cos(q) q in theta]) y = zval * np.array([sin(q) q in theta]) axes1.plot(x, y, -zval, 'b-') axes1.set_xlabel("x label") axes1.set_ylabel("y label") axes1.set_zlabel("z label") axes1.invert_zaxis() p.show()
Comments
Post a Comment