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() 

cone plot

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() 

enter image description here


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -