Skip to content

Commit 45fd038

Browse files
committed
separate drawing cell for plotly
1 parent 696fd52 commit 45fd038

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

structuretoolkit/visualize.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,14 @@ def _get_box_skeleton(cell: np.ndarray):
164164
# All 12 two-point lines on the unit square
165165
return all_lines @ cell
166166

167+
def _draw_box_plotly(fig, structure):
168+
cell = get_cell(structure)
169+
data = fig.data
170+
for lines in _get_box_skeleton(cell):
171+
fig = px.line_3d(**{xx: vv for xx, vv in zip(["x", "y", "z"], lines.T)})
172+
fig.update_traces(line_color="#000000")
173+
data = fig.data + data
174+
return go.Figure(data=data)
167175

168176
def _plot3d_plotly(
169177
structure: Atoms,
@@ -223,12 +231,7 @@ def _plot3d_plotly(
223231
),
224232
)
225233
if show_cell:
226-
data = fig.data
227-
for lines in _get_box_skeleton(structure.cell):
228-
fig = px.line_3d(**{xx: vv for xx, vv in zip(["x", "y", "z"], lines.T)})
229-
fig.update_traces(line_color="#000000")
230-
data = fig.data + data
231-
fig = go.Figure(data=data)
234+
fig = _draw_box_plotly(fig, structure)
232235
fig.layout.scene.camera.projection.type = camera
233236
rot = _get_orientation(view_plane).T
234237
rot[0, :] *= distance_from_camera * 1.25

0 commit comments

Comments
 (0)