0

I am trying to add 4 different meshes (roof, ground, 2 walls) to close up a shape in the same figure using plotly

Plotted each seperatley, every mesh works as intended, however, when put together some information is lost

I will try to explain the code in 3 sections:

1 -- Aquiring coordinates data to draw figure

import numpy as np
import plotly.graph_objects as go

def get_data(n=100):
    # === n:number of samples

    x = np.linspace(0, 30, n)
    y = np.linspace(-1, 1, n)
    X, Y = np.meshgrid(x, y)
    Y = Y * np.sqrt(5 / X.max() * X + 4)

    Z = 2 * 1.2 ** (-X) + 1

    # === limit z data to maximum of 2
    Z[ Z > 2] =2

    # === Close the shape from x=0 and x=max
    for i in range(len(Z)):
        Z[i][0] = 0
        Z[i][-1] = 0

    x = X.flatten()
    y = Y.flatten()
    z = Z.flatten()

    # === return 1d and 2d data, for further figure plotting
    return np.array([x,y,z,X,Y,Z], dtype=object)

2 -- Plotting the data

def fig_plot(d, n=100):
    # === plot the data set
    # === d:data, n:number of samples

    fig = go.Figure(data=[go.Mesh3d(x=d[0], y=d[1], z=d[2], name="Roof", opacity=0.50)])

    # === Add other mesh
    fig.add_trace(go.Mesh3d(x=[0, 30, 30, 0], y=[-2, -3, 3, 2], z=[0, 0, 0, 0], name="Floor"))

    fig.add_trace(go.Mesh3d(x=d[3][-1], y=d[4][-1], z=d[5][-1], name="Back Wall", opacity=0.50))
    fig.add_trace(go.Mesh3d(x=d[3][0], y=d[4][0], z=d[5][0], name="Front Wall", opacity=0.50))
    
    # === save file
    fig.write_html("fov_plot.html")
    return

3 -- Running the function

data = get_data(n=100)
fig_plot(data)

figure plotted results

I tried changed the order, for example wall as the main figure, and roof as add trace, but i still get the same missing shape

1 Answers1

0

so by changing the wall slope it works somehow

I changed Y = Y * np.sqrt(5 / X.max() * X + 4) to Y *= np.sqrt(8/X.max()*X +1)