brainbox.plot_base
Functions
Function to add vertical and horizontal reference lines to matplotlib axis |
|
Rearranges data on channels so it matches geometry of probe. |
|
Function to create matplotlib plot from ImagePlot object |
|
Function to create matplotlib plot from LinePlot object |
|
Function to create matplotlib plot from ProbePlot object |
|
Function to create matplotlib plot from ScatterPlot object. |
|
General function for preparing x y scatter plot with third variable encoded by colour of points |
Classes
- class DefaultPlot(plot_type, data)[source]
Bases:
object
- add_lines(pos, orientation, lim=None, style='--', width=3, color='k')[source]
Method to specify position and style of horizontal or vertical reference lines
- Parameters:
pos – position of line
orientation – either ‘v’ for vertical line or ‘h’ for horizontal line
lim – extent of lines
style – line style
width – line width
color – line colour
- Returns:
- set_labels(title=None, xlabel=None, ylabel=None, zlabel=None, clabel=None)[source]
Set labels for plot
- Parameters:
title – title
xlabel – x axis label
ylabel – y axis label
zlabel – z axis label
clabel – cbar label
- Returns:
- set_xlim(xlim=None)[source]
Set xlim values
- Parameters:
xlim – xlim values (min, max) supports tuple, list or np.array of len(2). If not
specified will compute as min, max of y data
- set_ylim(ylim=None)[source]
Set ylim values
- Parameters:
ylim – ylim values (min, max) supports tuple, list or np.array of len(2). If not
specified will compute as min, max of y data
- set_zlim(zlim=None)[source]
Set zlim values
- Parameters:
zlim – zlim values (min, max) supports tuple, list or np.array of len(2). If not
specified will compute as min, max of z data
- class ImagePlot(img, x=None, y=None, cmap=None)[source]
Bases:
DefaultPlot
- class ProbePlot(img, x, y, cmap=None)[source]
Bases:
DefaultPlot
- class ScatterPlot(x, y, z=None, c=None, cmap=None, plot_type='scatter')[source]
Bases:
DefaultPlot
- set_color(color=None)[source]
Color of scatter points.
- Parameters:
color – string e.g ‘k’, single RGB e,g [0,0,0] or np.array of RGB. In the latter case
must give same no. of colours as datapoints i.e. len(np.array(RGB)) == len(data[‘x’]) :return:
- set_marker_size(marker_size=None)[source]
Size of each scatter point
- Parameters:
marker_size – int or np.array of int. In the latter case must give same no. of
marker_size as datapoints i.e len(np.array(marker_size)) == len(data[‘x’]) :return:
- set_marker_type(marker_type=None)[source]
Shape of each scatter point
- Parameters:
marker_type
- Returns:
- set_line_color(line_color=None)[source]
Colour of edge of scatter point
- Parameters:
line_color – string e.g ‘k’ or RGB e.g [0,0,0]
- Returns:
- class LinePlot(x, y)[source]
Bases:
ScatterPlot
- add_lines(ax, data, **kwargs)[source]
Function to add vertical and horizontal reference lines to matplotlib axis
- Parameters:
ax – matplotlib axis
data – dict of plot data
kwargs – matplotlib keywords arguments associated with vlines/hlines
- Returns:
- plot_image(data, ax=None, show_cbar=True, fig_kwargs={}, line_kwargs={}, img_kwargs={})[source]
Function to create matplotlib plot from ImagePlot object
- Parameters:
data – ImagePlot object, either class or dict
ax – matplotlib axis to plot on, if None, will create figure
show_cbar – whether or not to display colour bar
fig_kwargs – dict of matplotlib keywords associcated with plt.subplots e.g can be
fig size, tight layout etc. :param line_kwargs: dict of matplotlib keywords associated with ax.hlines/ax.vlines :param img_kwargs: dict of matplotlib keywords associated with matplotlib.imshow :return: matplotlib axis and figure handles
- plot_scatter(data, ax=None, show_cbar=True, fig_kwargs={}, line_kwargs={}, scat_kwargs=None)[source]
Function to create matplotlib plot from ScatterPlot object. If data[‘colors’] is given for each data point it will override automatic colours that would be generated from data[‘data’][‘c’]
- Parameters:
data – ScatterPlot object, either class or dict
ax – matplotlib axis to plot on, if None, will create figure
show_cbar – whether or not to display colour bar
fig_kwargs – dict of matplotlib keywords associcated with plt.subplots e.g can be
fig size, tight layout etc. :param line_kwargs: dict of matplotlib keywords associated with ax.hlines/ax.vlines :param scat_kwargs: dict of matplotlib keywords associated with matplotlib.scatter :return: matplotlib axis and figure handles
- plot_probe(data, ax=None, show_cbar=True, make_pretty=True, fig_kwargs={}, line_kwargs={})[source]
Function to create matplotlib plot from ProbePlot object
- Parameters:
data – ProbePlot object, either class or dict
ax – matplotlib axis to plot on, if None, will create figure
show_cbar – whether or not to display colour bar
make_pretty – get rid of spines on axis
fig_kwargs – dict of matplotlib keywords associcated with plt.subplots e.g can be
fig size, tight layout etc. :param line_kwargs: dict of matplotlib keywords associated with ax.hlines/ax.vlines :return: matplotlib axis and figure handles
- plot_line(data, ax=None, fig_kwargs={}, line_kwargs={})[source]
Function to create matplotlib plot from LinePlot object
- Parameters:
data – LinePlot object either class or dict
ax – matplotlib axis to plot on
fig_kwargs – dict of matplotlib keywords associcated with plt.subplots e.g can be
fig size, tight layout etc. :param line_kwargs: dict of matplotlib keywords associated with ax.hlines/ax.vlines :return: matplotlib axis and figure handles
- scatter_xyc_plot(x, y, c, cmap=None, clim=None, rgb=False)[source]
General function for preparing x y scatter plot with third variable encoded by colour of points
- Parameters:
x
y
c
cmap
clim
rgb – Whether to compute rgb (set True when preparing pyqtgraph data)
- Returns:
- arrange_channels2banks(data, chn_coords, depth=None, pad=True, x_offset=1)[source]
Rearranges data on channels so it matches geometry of probe. e.g For Neuropixel 2.0 rearranges channels into 4 banks with checkerboard pattern
- Parameters:
data – data on channels
chn_coords – local coordinates of channels on probe
depth – depth location of electrode (for example could be relative to bregma). If none
given will stay in probe local coordinates :param pad: for matplotlib implementation with NonUniformImage we need to surround our data with nans so that it shows as finite display :param x_offset: spacing between banks in x direction :return: list, data, x position and y position for each bank