Skip to content

Commit 631eda8

Browse files
authored
Merge pull request #187 from pyiron/separate_draw_box
[minor] separate drawing cell for plotly
2 parents 696fd52 + 29f5eea commit 631eda8

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

structuretoolkit/visualize.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ def _get_box_skeleton(cell: np.ndarray):
165165
return all_lines @ cell
166166

167167

168+
def _draw_box_plotly(fig, structure, px, go):
169+
cell = structure.cell
170+
data = fig.data
171+
for lines in _get_box_skeleton(cell):
172+
fig = px.line_3d(**{xx: vv for xx, vv in zip(["x", "y", "z"], lines.T)})
173+
fig.update_traces(line_color="#000000")
174+
data = fig.data + data
175+
return go.Figure(data=data)
176+
177+
168178
def _plot3d_plotly(
169179
structure: Atoms,
170180
show_cell: bool = True,
@@ -223,12 +233,7 @@ def _plot3d_plotly(
223233
),
224234
)
225235
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)
236+
fig = _draw_box_plotly(fig, structure, px, go)
232237
fig.layout.scene.camera.projection.type = camera
233238
rot = _get_orientation(view_plane).T
234239
rot[0, :] *= distance_from_camera * 1.25

0 commit comments

Comments
 (0)