简体   繁体   English

如果不透明度≠ 1.0,python 中的绘图 3d 表面不透明度错误总是透明

[英]Plotly 3d-surface plot opacity error in python always giving transparent if opacity ≠ 1.0

3d-surface plot of the Ploty (python 3.x, Jupyter) worked properly in my case. Ploty(python 3.x,Jupyter)的 3d 曲面图在我的情况下正常工作。 However, when I set the opacity of the surface, the surface seemed to be transparent and disapear.然而,当我设置表面的不透明度时,表面似乎是透明的并消失了。 In this case, I set the opacity as 0.9.在这种情况下,我将不透明度设置为 0.9。

import plotly.graph_objects as go
import numpy as np
z1 = np.array([
    [8.83,8.89,8.81,8.87,8.9,8.87],
    [8.89,8.94,8.85,8.94,8.96,8.92],
    [8.84,8.9,8.82,8.92,8.93,8.91],
    [8.79,8.85,8.79,8.9,8.94,8.92],
    [8.79,8.88,8.81,8.9,8.95,8.92],
    [8.8,8.82,8.78,8.91,8.94,8.92],
    [8.75,8.78,8.77,8.91,8.95,8.92],
    [8.8,8.8,8.77,8.91,8.95,8.94],
    [8.74,8.81,8.76,8.93,8.98,8.99],
    [8.89,8.99,8.92,9.1,9.13,9.11],
    [8.97,8.97,8.91,9.09,9.11,9.11],
    [9.04,9.08,9.05,9.25,9.28,9.27],
    [9,9.01,9,9.2,9.23,9.2],
    [8.99,8.99,8.98,9.18,9.2,9.19],
    [8.93,8.97,8.97,9.18,9.2,9.18]
    ])
z2 = z1 + 1
z3 = z1 - 1
fig = go.Figure(data=[
    go.Surface(z=z1),
    go.Surface(z=z2, showscale=False, opacity=0.9),
    go.Surface(z=z3, showscale=False, opacity=0.9)
    ])
fig.show()

在此处输入图片说明

If you look at the image above, only trace 0 is shown.如果您查看上图,只会显示跟踪 0。 trace 1 and trace 2 are transparent when I set the opacity to 0.9 and it should not be like this.当我将不透明度设置为 0.9 时,trace 1 和 trace 2 是透明的,它不应该是这样的。 (trace 2 still can be annotated in the image) Anyone has a solution for this issue. (仍然可以在图像中注释trace 2)任何人都有这个问题的解决方案。

Unfortunately, i couldn't reproduce your error while running the same code as yours.不幸的是,在运行与您相同的代码时,我无法重现您的错误。

在此处输入图片说明

other issue might be z2 and z3 values overites to z1.其他问题可能是 z2 和 z3 值覆盖到 z1。 Try to rerun in new environment.尝试在新环境中重新运行。

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

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