我想要一个线图(用Axis.plot()绘制),该线图被Axis.plot_surface()生成的表面部分覆盖.我编写了以下脚本:import numpy as npfrom matplotlib import pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dresolution = 100ax = 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.0ax.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 thenI 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 npfrom matplotlib import pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dresolution = 100ax = 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.0ax.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 lineIt shows the plot with red line 这篇关于mplot3d:在`plot_surface()`下隐藏一个线图`plot()`.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-15 12:01