matplotlib中是否有类似深度缓冲区的内容? [英] Is there something like a depth buffer in matplotlib?

查看:67
本文介绍了matplotlib中是否有类似深度缓冲区的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用matplotlib绘制一些曲线.
但是,由于这些曲线在视口中相互重叠.
因此,仅z顺序在这里无济于事.

I'm trying to plot some curves with matplotlib.
But, since these curve overlap with each other from viewport.
So only z-order can not help here.

我想知道是否有一个功能像matplotlib中的深度缓冲区一样工作.
我正在画这样的东西.
而且红线不应该总是在3D空间中位于顶部.

I wonder if there is a function works like a depth buffer in matplotlib.
I'm plotting something like this.
And the red line should not always on top in 3D space.

推荐答案

我认为在matplotlib中执行此类操作很困难,因为它是具有某些3D绘图功能的2D绘图库.我推荐一些真正的3D绘图库,例如visvis,mayavi,vpython.例如,在visvis中,您可以创建3D曲线,例如:

I think it's difficult to do such things in matplotlib, since it's a 2D plot library with some 3D plot ability. I recommend some real 3D plot library, such as visvis, mayavi, vpython. For example, in visvis, you can create a 3D curve like:

import numpy as np
import visvis as vv
app = vv.use()

f = vv.clf()
a = vv.cla()

angle = np.linspace(0, 6*np.pi, 1000)
x = np.sin(angle)
y = np.cos(angle)
z = angle / 6.0
vv.plot(x, y, z, lw=10)

angle += np.pi*2/3.0
x = np.sin(angle)
y = np.cos(angle)
z = angle / 6.0 - 0.5
vv.plot(x, y, z, lc ="r", lw=10)

app.Run()

mayavi:

import numpy as np
from mayavi import mlab

angle = np.linspace(0, 6*np.pi, 1000)
x = np.sin(angle)
y = np.cos(angle)
z = angle / 6.0

mlab.plot3d(x, y, z, color=(1,0,0), tube_radius=0.1)

angle += np.pi*2/3.0
x = np.sin(angle)
y = np.cos(angle)
z = angle / 6.0 - 0.5
mlab.plot3d(x, y, z, color=(0,0,1), tube_radius=0.1)

mlab.axes()
mlab.show()

这篇关于matplotlib中是否有类似深度缓冲区的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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