Skip to content

Commit

Permalink
[vis] Fix Plotly mesh color
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Holl committed Nov 3, 2024
1 parent 4d36f56 commit d03f7a7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions phi/vis/_dash/_plotly_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def plot(self,
# --- plot mesh ---
cbar = None if not channel(data) or not channel(data).item_names[0] else channel(data).item_names[0][0]
if math.is_nan(data.values).all:
mesh = go.Mesh3d(x=x, y=y, z=z, i=v1, j=v2, k=v3, flatshading=False, opacity=float(alpha))
mesh = go.Mesh3d(x=x, y=y, z=z, i=v1, j=v2, k=v3, flatshading=False, opacity=float(alpha), color=plotly_color(color.native()))
elif data.sampled_at == 'center':
values = reshaped_numpy(data.values, [instance(data.mesh)])
mesh = go.Mesh3d(x=x, y=y, z=z, i=v1, j=v2, k=v3, colorscale='viridis', colorbar_title=cbar, intensity=values, intensitymode='cell', flatshading=True, opacity=float(alpha))
Expand Down Expand Up @@ -656,12 +656,11 @@ def plot(self,
alpha: Tensor,
err: Tensor):
def plot_single_material(data: Field, color, alpha: float):
color = plotly_color(color)
with math.NUMPY:
surf_mesh = geom.surface_mesh(data.geometry)
mesh_data = Field(surf_mesh, math.NAN, 0)
SurfaceMesh3D().plot(mesh_data, figure, subplot, space, min_val, max_val, show_color_bar, color, alpha, err)
math.map(plot_single_material, data, color, alpha, dims=channel(data.geometry) - 'vector')
math.map(plot_single_material, data, color, alpha, dims=channel(data.geometry) - 'vector', unwrap_scalars=False)



Expand Down

0 comments on commit d03f7a7

Please sign in to comment.