forked from SpikeInterface/probeinterface
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_08_more_plotting_examples.py
More file actions
88 lines (68 loc) · 2.7 KB
/
ex_08_more_plotting_examples.py
File metadata and controls
88 lines (68 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"""
More plotting examples
----------------------
Here are some examples to showcase several plotting scenarios.
"""
##############################################################################
# Import
import numpy as np
import matplotlib.pyplot as plt
from probeinterface import Probe, ProbeGroup
from probeinterface.plotting import plot_probe, plot_probegroup
from probeinterface import generate_multi_columns_probe, generate_linear_probe
##############################################################################
# Some examples in 2d
fig, ax = plt.subplots()
probe0 = generate_multi_columns_probe()
plot_probe(probe0, ax=ax)
# give each probe a different color
probe1 = generate_linear_probe(num_elec=9)
probe1.rotate(theta=15)
probe1.move([200, 0])
plot_probe(probe1, ax=ax,
contacts_colors=['red', 'cyan', 'yellow'] * 3)
# prepare yourself for carnival!
probe2 = generate_linear_probe()
probe2.rotate(theta=-35)
probe2.move([400, 0])
n = probe2.get_contact_count()
rand_colors = np.random.rand(n, 3)
plot_probe(probe2, ax=ax, contacts_colors=rand_colors,
probe_shape_kwargs={'facecolor': 'purple', 'edgecolor': 'k', 'lw': 0.5, 'alpha': 0.2})
# and make some alien probes
probe3 = Probe()
positions = [[0, 0], [0, 50], [25, 77], [45, 27]]
shapes = ['circle', 'square', 'rect', 'circle']
params = [{'radius': 10}, {'width': 30}, {'width': 20, 'height': 12}, {'radius': 13}]
probe3.set_contacts(positions=positions, shapes=shapes,
shape_params=params)
probe3.create_auto_shape(probe_type='rect')
probe3.rotate(theta=25)
probe3.move([600, 0])
plot_probe(probe3, ax=ax, contacts_colors=['b', 'c', 'g', 'y'])
ax.set_xlim(-100, 700)
ax.set_ylim(-200, 350)
ax.set_aspect('equal')
##############################################################################
# Some examples in 3d for the romantic who likes flowers...
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')
n = 8
for i in range(n):
probe = generate_multi_columns_probe(num_columns=3,
num_contact_per_column=[8, 9, 8],
xpitch=20, ypitch=20,
y_shift_per_column=[0, -10, 0]).to_3d()
probe.rotate(theta=35, center=[0, 0, 0], axis=[0, 1, 0])
probe.move([100, 50, 0])
probe.rotate(theta=i * 360 / n, center=[0, 0, 0], axis=[0, 0, 1])
plot_probe(probe, ax=ax,
probe_shape_kwargs={'facecolor': ['purple', 'cyan'][i % 2], 'edgecolor': 'k', 'lw': 0.5, 'alpha': 0.2})
probe = generate_linear_probe(num_elec=24, ypitch=20).to_3d()
probe.move([0, 0, -450])
plot_probe(probe, ax=ax)
lims = -450, 450
ax.set_xlim(*lims)
ax.set_ylim(*lims)
ax.set_zlim(*lims)
plt.show()