Skip to content

Commit

Permalink
added cedalion.plots.plot_montage3D
Browse files Browse the repository at this point in the history
  • Loading branch information
emiddell committed Nov 27, 2023
1 parent a9202e5 commit 43abb10
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/cedalion/plots.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import matplotlib.pyplot as p
import xarray as xr


def plot_montage3D(amp: xr.DataArray, geo3d: xr.DataArray):
f = p.figure()
ax = f.add_subplot(projection="3d")
colors = ["r", "b", "gray"]
sizes = [20, 20, 2]
for i, (type, x) in enumerate(geo3d.groupby("type")):
ax.scatter(x[:, 0], x[:, 1], x[:, 2], c=colors[i], s=sizes[i])

for i in range(amp.sizes["channel"]):
src = geo3d.loc[amp.source[i], :]
det = geo3d.loc[amp.detector[i], :]
ax.plot([src[0], det[0]], [src[1], det[1]], [src[2], det[2]], c="k")

# if available mark Nasion in yellow
if "Nz" in geo3d.label:
ax.scatter(
geo3d.loc["Nz", 0], geo3d.loc["Nz", 1], geo3d.loc["Nz", 2], c="y", s=25
)

ax.view_init(elev=30, azim=145)
p.tight_layout()

0 comments on commit 43abb10

Please sign in to comment.