mplot3d:在`plot_surface()`下隐藏一个线图`plot()`. [英] mplot3d: Hiding a line plot `plot()` under a `plot_surface()`

查看:73
本文介绍了mplot3d:在`plot_surface()`下隐藏一个线图`plot()`.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此描述的问题不再存在于最新版本的matplotlib(2.1.1,于2019年9月10日进行编辑):最肯定的是自那时以来已修复的错误

我想要一个线图(用Axis.plot()绘制),该线图被Axis.plot_surface()生成的表面部分覆盖.我编写了以下脚本:

import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

resolution = 100
ax = plt.gca(projection="3d")
x, y = np.meshgrid( np.linspace(-1.0, 1.0, resolution) ,
                    np.linspace(-1.0, 1.0, resolution) )
phi = (1.0 - x)*(1.0 - y) / 4.0
ax.plot([-1.0,1.0], [-1.0,1.0], [0.0,0.0], color="red")
ax.plot_surface(x, y, p linewidth=0, antialiased=False)
plt.show()

,并确保在调用plot_surface()之前先调用plot().但是,线图似乎始终具有最高的"zindex",并在表面上绘制.这是我得到的:

这里是我想要的:

如何获得此结果? (不使用Gimp ...)

解决方案

我更改了.

ax.plot_surface(x, y, p linewidth=0, antialiased=False)

具有:

ax.plot_surface(x, y, p linewidth=0, antialiased=True)

然后我看到整个红线 它用红线显示了情节

Edit: the problem I describe here no longer shows with current versions of matplotlib (2.1.1, edit made on 10 Sep 2019): most certainly a bug that has been fixed since then

I want to have a line plot (drawn with Axis.plot()) that is partially covered by the surface generated by Axis.plot_surface(). I wrote the following script:

import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

resolution = 100
ax = plt.gca(projection="3d")
x, y = np.meshgrid( np.linspace(-1.0, 1.0, resolution) ,
                    np.linspace(-1.0, 1.0, resolution) )
phi = (1.0 - x)*(1.0 - y) / 4.0
ax.plot([-1.0,1.0], [-1.0,1.0], [0.0,0.0], color="red")
ax.plot_surface(x, y, phi, linewidth=0, antialiased=False)
plt.show()

and made sure to have the call to plot() before the one to plot_surface(). Nevertheless, it seems that the line plot always has the highest "zindex" and gets plotted over the surface. Here is what I obtain:

Here is what I would like to have instead:

How do I achieve this result? (Without using Gimp…)

解决方案

I changed.

ax.plot_surface(x, y, phi, linewidth=0, antialiased=False)

with:

ax.plot_surface(x, y, phi, linewidth=0, antialiased=True)

and then I saw the whole red line It shows the plot with red line

这篇关于mplot3d:在`plot_surface()`下隐藏一个线图`plot()`.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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