简体   繁体   English

Matplotlib-多个表面图,错误的重叠

[英]Matplotlib - multiple surface plots, wrong overlapping

I am currently plotting two completely different datasets into one 3D surface plot. 我目前正在将两个完全不同的数据集绘制到一个3D表面图中。 When I am plotting each one independently, everything works fine. 当我独立绘制每个图时,一切正常。 However, as soon as I plot them in one, the visualization is strange. 但是,一旦我将它们绘制成一张,可视化效果就很奇怪。 I do the plotting the following way: 我通过以下方式进行绘制:

fig = plt.figure(figsize=(20,10))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X,Y,Z, color=color, antialiased=True)
(get new X,Y, Z values)
ax.plot_surface(X,Y,Z, color=color, antialiased=True)
ax.view_init(30, 360)

The output is the following: 输出如下:

输出

As you can see, the blue data is correct, but the green one is somehow in the backside and not correctly visualized. 如您所见,蓝色的数据是正确的,但是绿色的数据却在背面,并且无法正确显示。 If I plot the green one alone, it works perfectly. 如果我单独绘制绿色,则效果很好。

Changing the order of plotting (or playing around with zorder) does not change anything. 更改绘图顺序(或使用zorder进行播放)不会更改任何内容。

Hope someone can help! 希望有人能帮忙!

Matplotlib is just a 2d plotting library. Matplotlib只是一个二维绘图库。 3d plots are achieved by projecting the 3d surface onto the image plane. 通过将3d表面投影到图像平面上即可获得3d图。

If you have multiple 3d surfaces, it will turn each into a 2d shape, and then calculate a single height for each shape, and show then in that order. 如果有多个3d曲面,它将把每个曲面变成2d形状,然后为每个形状计算一个高度,然后按该顺序显示。

As far as I'm aware, the zorder option doesn't work, and all it would is change the order of the surfaces anyway. 据我所知,zorder选项不起作用,它所要做的只是改变表面的顺序。

If you're really unlucky, the grey boxes that make up the axis grids can get plotted above your surface too. 如果您真的很倒霉,组成轴网格的灰色框也可以绘制在表面上方。 That's even more annoying. 更令人讨厌。

Of you must use matplotlib, then i guess you could split up your surface into lots of smaller ones, but you're going to encounter a pretty big performance bit doing this, and you'll to override the values in the legend too. 您必须使用matplotlib,然后我想您可以将其表面拆分为许多较小的表面,但是这样做会遇到相当大的性能问题,并且您还将覆盖图例中的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM