Skip to content

[minor] separate drawing cell for plotly #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions structuretoolkit/visualize.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ def _get_box_skeleton(cell: np.ndarray):
return all_lines @ cell


def _draw_box_plotly(fig, structure, px, go):
cell = structure.cell
data = fig.data
for lines in _get_box_skeleton(cell):
fig = px.line_3d(**{xx: vv for xx, vv in zip(["x", "y", "z"], lines.T)})
fig.update_traces(line_color="#000000")
data = fig.data + data
return go.Figure(data=data)


def _plot3d_plotly(
structure: Atoms,
show_cell: bool = True,
Expand Down Expand Up @@ -223,12 +233,7 @@ def _plot3d_plotly(
),
)
if show_cell:
data = fig.data
for lines in _get_box_skeleton(structure.cell):
fig = px.line_3d(**{xx: vv for xx, vv in zip(["x", "y", "z"], lines.T)})
fig.update_traces(line_color="#000000")
data = fig.data + data
fig = go.Figure(data=data)
fig = _draw_box_plotly(fig, structure, px, go)
fig.layout.scene.camera.projection.type = camera
rot = _get_orientation(view_plane).T
rot[0, :] *= distance_from_camera * 1.25
Expand Down
Loading