matplotlib 3D图上的反向Z轴 [英] Reverse Z Axis on matplotlib 3D Plot

查看:435
本文介绍了matplotlib 3D图上的反向Z轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个人如何颠倒3D图的z轴上的顺序(即负向上,正向下)?下面的代码生成一个圆锥体,其底部指向下方;有没有可以用来更改订单价格顺序的命令(如ax.reverse_zlim3d(True)之类的?)?

How would one reverse the order on the z axis of a 3D plot (i.e. negative is up, and positive is down)? The following code produces a cone with the base pointing downward; is there a command (like ax.reverse_zlim3d(True) or something?) that can be used to change the tick order?

以下代码绘制了一个圆锥形,其底部指向下方.我想反转z轴顺序,以便其绘制时基部朝上,就像蛋卷冰淇淋一样,在图的顶部而不是底部的-1.

The following code plots a cone with the base pointing downward. I would like to reverse the z-axis order so that it plots with the base pointing up, like an ice cream cone, with -1 at the top of the graph instead of the bottom.

from matplotlib import pyplot as p
from mpl_toolkits.mplot3d import Axes3D    # @UnusedImport

import numpy as np
from 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')
for zval in z:
    x = zval * np.array([cos(q) for q in theta])
    y = zval * np.array([sin(q) for 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()

推荐答案

使用

这篇关于matplotlib 3D图上的反向Z轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆