Note
Go to the end to download the full example code.
Plot values¶
Here is an example of how to plot values with color scales. And also to plot an interpolated image.
from pprint import pprint
import numpy as np
import matplotlib.pyplot as plt
from probeinterface import Probe, get_probe
from probeinterface.plotting import plot_probe
Download one probe:
manufacturer = 'neuronexus'
probe_name = 'A1x32-Poly3-10mm-50-177'
probe = get_probe(manufacturer, probe_name)
probe.rotate(23)
fake values
values = np.random.randn(32)
plot with values
fig, ax = plt.subplots()
poly, poly_contour = plot_probe(probe, contacts_values=values,
cmap='jet', ax=ax, contact_kwargs={'alpha' : 1}, title=False)
poly.set_clim(-2, 2)
fig.colorbar(poly)

<matplotlib.colorbar.Colorbar object at 0x72b4593ed0f0>
generated an interpolated image and plot it on top
image, xlims, ylims = probe.to_image(values, pixel_size=4, method='linear')
print(image.shape)
fig, ax = plt.subplots()
plot_probe(probe, ax=ax, title=False)
im = ax.imshow(image, extent=xlims+ylims, origin='lower', cmap='jet')
im.set_clim(-2,2)
fig.colorbar(im)

(127, 67)
<matplotlib.colorbar.Colorbar object at 0x72b44abe6620>
works with several interpolation methods
image, xlims, ylims = probe.to_image(values, num_pixel=1000, method='nearest')
fig, ax = plt.subplots()
plot_probe(probe, ax=ax, title=False)
im = ax.imshow(image, extent=xlims+ylims, origin='lower', cmap='jet')
im.set_clim(-2,2)
fig.colorbar(im)
plt.show()

Total running time of the script: (0 minutes 1.094 seconds)