Skip to content

Commit

Permalink
Fix plot boundary error (#772)
Browse files Browse the repository at this point in the history
* fix plot boundaries in some edge cases
  • Loading branch information
OrtnerMichael committed May 20, 2024
1 parent 22f7bd7 commit 1265aed
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion magpylib/_src/display/traces_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,12 @@ def get_scene_ranges(*traces, zoom=1) -> np.ndarray:
for v, min_, max_ in zip(ranges.values(), *min_max):
v.extend([min_, max_])
if trace3d_found:
# SET 3D PLOT BOUNDARIES
# collect min/max from all elements
r = np.array([[np.nanmin(v), np.nanmax(v)] for v in ranges.values()])
size = np.diff(r, axis=1)
size[size == 0] = 1
m = size.max() / 2
m = 1 if m == 0 else m
center = r.mean(axis=1)
ranges = np.array([center - m * (1 + zoom), center + m * (1 + zoom)]).T
if not traces or not trace3d_found:
Expand Down

0 comments on commit 1265aed

Please sign in to comment.