cibrrig.plot ============ .. py:module:: cibrrig.plot Attributes ---------- .. autoapisummary:: cibrrig.plot.has_brainbox cibrrig.plot.laser_colors Functions --------- .. autoapisummary:: cibrrig.plot.plot_laser cibrrig.plot._plot_laser_alf cibrrig.plot._plot_laser_intervals cibrrig.plot._plot_laser_log cibrrig.plot._create_ax cibrrig.plot._setup_colorbar cibrrig.plot.plot_projection_line_multicondition cibrrig.plot.plot_projection_line cibrrig.plot._plot_projection_line_2D cibrrig.plot._plot_projection_line_3D cibrrig.plot.plot_projection cibrrig.plot.plot_3D_projection cibrrig.plot.plot_2D_projection cibrrig.plot.plot_polar_average cibrrig.plot.plot_reset_curve cibrrig.plot.plot_sweeps cibrrig.plot.plot_most_likely_dynamics cibrrig.plot.plot_most_likely_dynamics_3D cibrrig.plot._clean_3d_axes cibrrig.plot.clean_polar_axis cibrrig.plot.clean_linear_radial_axis cibrrig.plot.plot_driftmap_with_trace cibrrig.plot.replace_timeaxis_with_scalebar cibrrig.plot.trim_yscale_to_lims cibrrig.plot.plot_peth_and_raster Module Contents --------------- .. py:data:: has_brainbox :value: True .. py:data:: laser_colors .. py:function:: plot_laser(laser_in, **kwargs) Flexibly overlay laser stimulation. :param laser_in: The laser data to be plotted. Can be an AlfBunch object or an array of intervals. :type laser_in: AlfBunch or array-like :param \*\*kwargs: Additional keyword arguments to be passed to the plotting functions. These may include: mode (str): The plotting mode. Options are "shade", "bar", "vline", or any other (defaults to steps). ax (matplotlib.axes.Axes): The axes object to plot on. If None, a new figure and axes will be created. amp_label (str): Label for the amplitude axis when plotting amplitudes. wavelength (int): Laser wavelength in nm, used to determine the color of the plot. alpha (float or array-like): The alpha (transparency) value(s) for shaded areas. color (str or tuple): The color to use for plotting. If not provided, a default color based on wavelength is used. query (str): Query string to filter the data (only used in _plot_laser_log). rotation (int): Rotation angle for text annotations (only used in _plot_laser_log). fontsize (int): Font size for text annotations (only used in _plot_laser_log). Any other keyword arguments accepted by matplotlib plotting functions. :returns: The axes object containing the plot. :rtype: matplotlib.axes.Axes .. rubric:: Notes This function determines the appropriate plotting method based on the input type: - If laser_in is an AlfBunch object with a 'category' key, it calls _plot_laser_log. - If laser_in is an AlfBunch object without a 'category' key, it calls _plot_laser_alf. - For other input types, it calls _plot_laser_intervals. The specific kwargs used may vary depending on which underlying plotting function is called. .. py:function:: _plot_laser_alf(laser_in, **kwargs) Plot laser data from a "laser" AlfBunch. :param laser_in: The AlfBunch object containing laser data. :type laser_in: AlfBunch :param \*\*kwargs: Additional keyword arguments to be passed to _plot_laser_intervals. .. rubric:: Notes This function extracts intervals and amplitudes from the AlfBunch object and calls _plot_laser_intervals with the appropriate parameters. It determines whether to use milliwatts or volts for the amplitude label based on the available keys in laser_in. .. py:function:: _plot_laser_intervals(intervals, amplitudes=None, ax=None, mode='shade', amp_label='', wavelength=473, alpha=0.2, **kwargs) Plot laser intervals from arrays. :param intervals: Array of laser intervals, where each interval is [start_time, end_time]. :type intervals: array-like :param amplitudes: Array of amplitude values corresponding to each interval. :type amplitudes: array-like, optional :param ax: The axes object to plot on. If None, a new figure and axes will be created. :type ax: matplotlib.axes.Axes, optional :param mode: The plotting mode. Options are "shade", "bar", "vline", or any other (defaults to steps). :type mode: str, optional :param amp_label: Label for the amplitude axis when plotting amplitudes. :type amp_label: str, optional :param wavelength: Laser wavelength in nm, used to determine the color of the plot. Default is 473. :type wavelength: int, optional :param alpha: The alpha (transparency) value(s) for shaded areas. Default is 0.2. :type alpha: float or array-like, optional :param \*\*kwargs: Additional keyword arguments to be passed to the plotting functions. :returns: The axes object containing the plot. :rtype: matplotlib.axes.Axes .. rubric:: Notes This function supports multiple plotting modes: - "shade": Shades the intervals on the plot. - "bar": Plots horizontal bars for each interval. - "vline": Plots vertical lines at the start of each interval. - Any other mode defaults to plotting steps of the amplitudes. The function handles color selection based on the wavelength and can use a list of alpha values for varying transparency across intervals. .. py:function:: _plot_laser_log(log, query=None, rotation=45, fontsize=6, **kwargs) Plot laser data from a "log" AlfBunch object. :param log: The AlfBunch object containing laser log data. :type log: AlfBunch :param query: Query string to filter the data. Default is None. :type query: str, optional :param rotation: Rotation angle for text annotations. Default is 45. :type rotation: int, optional :param fontsize: Font size for text annotations. Default is 6. :type fontsize: int, optional :param \*\*kwargs: Additional keyword arguments to be passed to _plot_laser_intervals. :returns: The axes object containing the plot. :rtype: matplotlib.axes.Axes .. rubric:: Notes This function extracts opto data from the log, plots the intervals using _plot_laser_intervals, and adds text annotations for each interval. It handles both milliwatt and voltage amplitudes. .. py:function:: _create_ax(dims, projection=None) Create a new figure and axis. :param dims: Dimensions to plot. :type dims: list :param projection: Type of projection for 3D plots. :type projection: str, optional :returns: Figure and Axes objects. :rtype: tuple .. py:function:: _setup_colorbar(ax, p, vmin, vmax, colorbar_title) Set up a colorbar for the plot. :param ax: The axes object to add the colorbar to. :type ax: Axes :param p: The plot object to create the colorbar from. :param vmin: Minimum value for the colorbar. :type vmin: float :param vmax: Maximum value for the colorbar. :type vmax: float :param colorbar_title: Title for the colorbar. :type colorbar_title: str .. py:function:: plot_projection_line_multicondition(X, tbins, intervals, colors, dims=[0, 1], ax=None, alpha=0.5, lw=1, **kwargs) Plot low-D projection with unique coloring for the given intervals. :param X: Data to plot. :type X: array :param tbins: Time bins. :type tbins: array :param intervals: Start and end times for each condition. :type intervals: array :param colors: Colors for each condition. :type colors: list :param dims: Dimensions to plot. :type dims: list :param ax: Axes to plot on. :type ax: Axes, optional :param alpha: Alpha value for transparency. :type alpha: float :param lw: Line width. :type lw: float :returns: The axes object containing the plot. :rtype: Axes .. py:function:: plot_projection_line(X, cvar=None, dims=[0, 1], cmap='viridis', **kwargs) Plot low-d projection as a line. Optionally :param X: Data to plot. :type X: array :param cvar: Color variable. :type cvar: array, optional :param dims: Dimensions to plot. :type dims: list :param cmap: Colormap to use. :type cmap: str :param \*\*kwargs: Additional keyword arguments. :keyword ax: The axes to plot on. If not provided, a new figure and axes will be created. :kwtype ax: matplotlib.axes.Axes, optional :keyword color: Color of the line if cvar is not provided. Default is "k" (black). :kwtype color: str, optional :keyword alpha: The alpha blending value, between 0 (transparent) and 1 (opaque). Default is 0.5. :kwtype alpha: float, optional :keyword lw: The line width. Default is 0.5. :kwtype lw: float, optional :keyword vmin: Minimum of the colormap range. If not provided, it's inferred from cvar. :kwtype vmin: float, optional :keyword vmax: Maximum of the colormap range. If not provided, it's inferred from cvar. :kwtype vmax: float, optional :keyword colorbar_title: Title for the colorbar. Default is an empty string. :kwtype colorbar_title: str, optional :keyword title: Title for the plot. Only used in 3D plots. Default is an empty string. :kwtype title: str, optional :keyword lims: The x, y, (and z for 3D) limits of the plot as [min, max]. Only used in 3D plots. Default is [-4, 4]. :kwtype lims: list, optional :keyword pane_color: Color of the panes in 3D plots. If None, default matplotlib style is used. :kwtype pane_color: color, optional :keyword plot_colorbar: Whether to plot the colorbar. Only used in 3D plots. Default is True. :kwtype plot_colorbar: bool, optional :returns: The axes object containing the plot. :rtype: Axes .. py:function:: _plot_projection_line_2D(X, cvar=None, dims=[0, 1], cmap='viridis', color='k', ax=None, alpha=0.5, vmin=None, vmax=None, lw=0.5, colorbar_title='', plot_colorbar=True, **kwargs) Plot 2D projection line. :param X: Data to plot. :type X: array :param cvar: Color variable. :type cvar: array, optional :param dims: Dimensions to plot. :type dims: list :param cmap: Colormap to use. :type cmap: str :param color: Color for the line if cvar is None. :type color: str :param ax: Axes to plot on. :type ax: Axes, optional :param alpha: Alpha value for transparency. :type alpha: float :param vmin: Minimum value for colormap. :type vmin: float, optional :param vmax: Maximum value for colormap. :type vmax: float, optional :param lw: Line width. :type lw: float :param colorbar_title: Title for the colorbar. :type colorbar_title: str :param \*\*kwargs: Additional keyword arguments. :returns: The axes object containing the plot. :rtype: Axes .. py:function:: _plot_projection_line_3D(X, cvar=None, dims=[0, 1, 2], cmap='viridis', color='k', ax=None, title='', alpha=0.5, lims=None, pane_color=None, colorbar_title='', plot_colorbar=True, vmin=None, vmax=None, lw=0.5, **kwargs) Plot 3D projection line. :param X: Data to plot. :type X: array :param cvar: Color variable. :type cvar: array, optional :param dims: Dimensions to plot. :type dims: list :param cmap: Colormap to use. :type cmap: str :param color: Color for the line if cvar is None. :type color: str :param ax: 3D axes to plot on. :type ax: Axes3D, optional :param title: Title for the plot. :type title: str :param alpha: Alpha value for transparency. :type alpha: float :param lims: Limits for the axes. :type lims: list :param pane_color: Color for the panes. :param colorbar_title: Title for the colorbar. :type colorbar_title: str :param plot_colorbar: Whether to plot the colorbar. :type plot_colorbar: bool :param vmin: Minimum value for colormap. :type vmin: float, optional :param vmax: Maximum value for colormap. :type vmax: float, optional :param lw: Line width. :type lw: float :param \*\*kwargs: Additional keyword arguments. :returns: The 3D axes object containing the plot. :rtype: Axes3D .. py:function:: plot_projection(X, dims, **kwargs) Plot projection in 2D or 3D. :param X: Data to plot. :type X: array :param dims: Dimensions to plot. :type dims: list :param \*\*kwargs: Additional keyword arguments. :keyword ax: The axes to plot on. If not provided, a new figure and axes will be created. :kwtype ax: matplotlib.axes.Axes, optional :keyword color: The color of the data points or lines. Default is "k" (black) if no color variable (`cvar`) is provided. :kwtype color: str, optional :keyword alpha: Transparency level for the points. Should be between 0 (fully transparent) and 1 (fully opaque). - Default is 0.5. :kwtype alpha: float, optional :keyword lw: Line width for plotting. Applies if plotting a line plot. Default is 0.5. :kwtype lw: float, optional :keyword vmin: Minimum value for the colormap if a color variable (`cvar`) is used. If not specified, it's inferred from `cvar`. :kwtype vmin: float, optional :keyword vmax: Maximum value for the colormap if a color variable (`cvar`) is used. If not specified, it's inferred from `cvar`. :kwtype vmax: float, optional :keyword colorbar_title: Title for the colorbar. Default is an empty string. :kwtype colorbar_title: str, optional :keyword title: Title for the plot. Only used in 3D plots. Default is an empty string. :kwtype title: str, optional :keyword lims: Axis limits for the plot. Should be a list of `[min, max]` values. - Default is [-4, 4] for 3D plots. :kwtype lims: list, optional :keyword pane_color: Background color of the 3D panes in 3D plots. If `None`, default style is used. :kwtype pane_color: str, optional :keyword plot_colorbar: Whether to include a colorbar in the plot. Only applies to 3D plots when `cvar` is used. Default is True. :kwtype plot_colorbar: bool, optional :keyword s: Size of the markers used in the scatter plot. Default is 1. :kwtype s: float, optional :keyword cmap: Colormap to use when plotting with a color variable (`cvar`). Default is "viridis". :kwtype cmap: str, optional :keyword cvar: An array of values used to color the data points. If provided, `cmap` is applied. :kwtype cvar: array-like, optional :keyword s: Size of the markers in the scatter plot. Default is 1. :kwtype s: float, optional :returns: Figure and Axes objects. :rtype: tuple .. py:function:: plot_3D_projection(X, dims=[0, 1, 2], cvar=None, ax=None, title='', s=1, vmin=None, vmax=None, cmap='viridis', c='k', alpha=0.2, lims=None, plot_colorbar=True, colorbar_title='', pane_color=None, **kwargs) Plot 3D projection. :param X: Data to plot. :type X: array :param dims: Dimensions to plot. :type dims: list :param cvar: Color variable. :type cvar: array, optional :param ax: 3D axes to plot on. :type ax: Axes3D, optional :param title: Title for the plot. :type title: str :param s: Size of the markers. :type s: float :param vmin: Minimum value for colormap. :type vmin: float, optional :param vmax: Maximum value for colormap. :type vmax: float, optional :param cmap: Colormap to use. :type cmap: str :param c: Color for the markers if cvar is None. :type c: str :param alpha: Alpha value for transparency. :type alpha: float :param lims: Limits for the axes. :type lims: list :param plot_colorbar: Whether to plot the colorbar. :type plot_colorbar: bool :param colorbar_title: Title for the colorbar. :type colorbar_title: str :param pane_color: Color for the panes. :param \*\*kwargs: Additional keyword arguments. :returns: Figure and Axes3D objects. :rtype: tuple .. py:function:: plot_2D_projection(X, dims=[0, 1], cvar=None, ax=None, title='', s=1, vmin=None, vmax=None, cmap='viridis', c='C1', alpha=0.2, lims=[-4, 4], plot_colorbar=True, colorbar_title='') Plot 2D projection. :param X: Data to plot. :type X: array :param dims: Dimensions to plot. :type dims: list :param cvar: Color variable. :type cvar: array, optional :param ax: Axes to plot on. :type ax: Axes, optional :param title: Title for the plot. :type title: str :param s: Size of the markers. :type s: float :param vmin: Minimum value for colormap. :type vmin: float, optional :param vmax: Maximum value for colormap. :type vmax: float, optional :param cmap: Colormap to use. :type cmap: str :param c: Color for the markers if cvar is None. :type c: str :param alpha: Alpha value for transparency. :type alpha: float :param lims: Limits for the axes. :type lims: list :param plot_colorbar: Whether to plot the colorbar. :type plot_colorbar: bool :param colorbar_title: Title for the colorbar. :type colorbar_title: str :returns: Figure and Axes objects. :rtype: tuple .. py:function:: plot_polar_average(x, y, t, ax=None, t0=None, tf=None, color='k', bins=50, multi='sem', alpha=0.3, **plot_kwargs) Plot covariate `y` as a function of phase `x` on a polar. If t0,tf are arrays, will average over multiple intervals :param x: Phase data with values in the range [-pi, pi]. :type x: 1D numpy array :param y: Signal data to be plotted against `x`. :type y: 1D numpy array :param t: Time data corresponding to `x` and `y`. :type t: 1D numpy array :param ax: The axes object to plot on. If None, a new figure and axes are created. Defaults to None. :type ax: matplotlib.axes.Axes, optional :param t0: Start time(s) for epoch selection. If a list or array, averages over multiple epochs are computed. Defaults to None. :type t0: int, float, or list, optional :param tf: End time(s) for epoch selection, matching the format of `t0`. Defaults to None. :type tf: int, float, or list, optional :param color: Line color(s) for the plot. Defaults to 'k'. :type color: str or list, optional :param bins: Number of bins for the polar histogram. Defaults to 50. :type bins: int, optional :param multi: Specifies the method for calculating the shaded region. Options are 'std' for standard deviation or 'sem' for standard error of the mean. Defaults to 'sem'. :type multi: str, optional :param alpha: Transparency of the shaded region. Defaults to 0.3. :type alpha: float, optional :param \*\*plot_kwargs: Additional keyword arguments passed to `ax.plot`. :returns: A tuple containing: - `f`: The created figure object (or None if `ax` was provided). - `ax`: The axes object used for plotting. - `y_polar_out`: 2D numpy array of the polar data averaged over epochs. - `phase_bins`: Phase bin centers for the plot. :rtype: tuple .. rubric:: Example >>> plot_polar_average(x, y, t, t0=0, tf=10, color='b', bins=30, multi='std') .. py:function:: plot_reset_curve(breaths, events, wavelength=473, annotate=False, norm=True, plot_tgl=True, n_control=100) Plot a reset curve for optogenetic stimulation, showing phase-dependent effects on breathing cycles. :param breaths: Breath timing data with attributes: 'times', 'IBI', and 'duration_sec'. :type breaths: AlfBunch :param events: 1D array of stimulation/event times. :type events: np.ndarray :param wavelength: Wavelength of optogenetic stimulus. Defaults to 473. :type wavelength: int, optional :param annotate: If True, add annotations and color overlays to the plot. Defaults to False. :type annotate: bool, optional :param norm: If True, normalizes time to phase (0-1) for plotting. Defaults to True. :type norm: bool, optional :param plot_tgl: If True, creates a plot; if False, returns computed data. Defaults to True. :type plot_tgl: bool, optional :param n_control: Number of random control points for a control distribution. Defaults to 100. :type n_control: int, optional :returns: - `cycle_stim_time`: Normalized/raw times of stimulation relative to breath onset. - `cycle_duration`: Normalized/raw breath cycle durations following stimulation. - `cycle_stim_time_rand`: Control times for stimulation from random event times. - `cycle_duration_rand`: Control breath cycle durations for random events. :rtype: tuple .. py:function:: plot_sweeps(xt, x, times, pre, post, ax=None, **kwargs) Time-aligns a trace `x` to event times specified in `times`. :param xt: Time values corresponding to the signal trace `x`. :type xt: array-like :param x: Signal trace data to be plotted. :type x: array-like :param times: Event times to align the trace `x` to. :type times: array-like :param pre: Time before each event to start the trace. :type pre: float :param post: Time after each event to end the trace. :type post: float :param ax: Axes to plot on. If None, a new figure and axes will be created. Default is None. :type ax: matplotlib.axes.Axes, optional :param \*\*kwargs: Additional keyword arguments passed to `ax.plot`, such as line style or color. :returns: matplotlib axis :rtype: ax .. py:function:: plot_most_likely_dynamics(model, xlim=(-4, 4), ylim=(-3, 3), nxpts=20, nypts=20, alpha=0.8, ax=None, figsize=(3, 3), colors=[f'C{x}' for x in range(7)], zval=None) Plotting of underlying vector fields from Linderman Lab .. py:function:: plot_most_likely_dynamics_3D(model, xlim=(-4, 4), ylim=(-3, 3), zlim=(-3, 3), nxpts=10, nypts=10, nzpts=10, alpha=0.2, ax=None, figsize=(3, 3), length=0.2, colors=[f'C{x}' for x in range(7)]) Extension of the linderman vectorfield plot to 3D .. py:function:: _clean_3d_axes(ax, title, dims, pane_color, lims=None) Modify 3D axes to be cleaner: Set title set axis labels make limits equal turn off grid set background color :param ax: The 3D axes object to customize. :type ax: matplotlib.axes._subplots.Axes3DSubplot :param title: The title of the plot. :type title: str :param dims: Dimensions to label the axes, corresponding to the 3D data dimensions (e.g., (0, 1, 2) for first three components). :type dims: tuple or list of ints :param pane_color: RGB color to set for the panes (background of each axis). Use None for default color. :type pane_color: tuple or None :param lims: If None, autoscales axes. Axis limits to set for x, y, and z axes (e.g., (-1, 1) to set limits for all axes). :type lims: tuple or list of floats,optional :returns: The modified axes object. :rtype: ax (matplotlib.axes._subplots.Axes3DSubplot) .. rubric:: Example ax = fig.add_subplot(111, projection='3d') _clean_3d_axes(ax, "3D Plot", (0, 1, 2), (0.9, 0.9, 0.9, 0.5), (-1, 1)) .. py:function:: clean_polar_axis(ax) Clean the appearance of a polar plot. Use pi/2 (90 degrees) angular ticks, no internal radial ticks, and set labels to mathtext pi :param ax: The polar axes object to modify. :type ax: matplotlib.projections.polar.PolarAxes .. rubric:: Example ax = plt.subplot(projection='polar') clean_polar_axis(ax) .. py:function:: clean_linear_radial_axis(ax) Clean the appearance of a plot with a range o [-pi,pi] but on a normal, linear axis Sets ticks to every pi/2 interval and uses math text. :param ax: The axes object to modify. :type ax: matplotlib.axes._subplots.AxesSubplot .. rubric:: Example ax = plt.subplot() clean_linear_radial_axis(ax) .. py:function:: plot_driftmap_with_trace(spike_times, spike_depths, trace, trace_times, trace_label='', t0=None, tf=None, depth_lim=(None, None), trace_ylim=(None, None), t_bin=0.01, driftmap_kwargs={}, trace_kwargs={}, figsize=(2, 8), use_scalebar=True, use_colorbar=True, cmap=None, raster_ylabel=None) #TODO: Update documentation #TODO: UPdate to work more intuitively with clusters Works well as a driftmap, but lass good as a rastermap Plot a drift map with an covariate trace above. Built off of ibllib.brainbox.plot.driftmap. This function plots a drift map of spike times and depths, with an overlaid trace such as diaphragm or another continuous signal. :param spike_times: Array of spike times. :type spike_times: array-like :param spike_depths: Array of spike depths corresponding to each spike time. :type spike_depths: array-like :param trace: Continuous signal to overlay on the drift map. Can be multiple columns as long as each row is a timepoint :type trace: array-like :param trace_times: Time points corresponding to the trace signal. :type trace_times: array-like :param trace_label: Label for the trace. Defaults to ''. :type trace_label: str, optional :param t0: Start time for the plot. Defaults to None, which uses the minimum spike time. :type t0: float, optional :param tf: End time for the plot. Defaults to None, which uses the maximum spike time. :type tf: float, optional :param depth_lim: Depth limits for the plot. Defaults to (None, None), which uses the min and max spike depths. :type depth_lim: tuple, optional :param trace_ylim: Y-axis limits for the trace plot. Defaults to (None, None), which uses the min and max trace values. :type trace_ylim: tuple, optional :param driftmap_kwargs: Additional keyword arguments for the drift map plot. Defaults to {}. :type driftmap_kwargs: dict, optional :param trace_kwargs: Additional keyword arguments for the trace plot. Defaults to {}. :type trace_kwargs: dict, optional :param figsize: Figure size for the plot. Defaults to (2, 8). :type figsize: tuple, optional :param use_scalebar: Whether to use a scale bar in the plot. Defaults to True. :type use_scalebar: bool, optional :returns: The axes object containing the drift map. matplotlib.axes._subplots.AxesSubplot: The axes object containing the trace plot. :rtype: matplotlib.axes._subplots.AxesSubplot .. py:function:: replace_timeaxis_with_scalebar(ax, pad=0.025, lw=None, color=None, size=None) Replace the x-axis with a horizontal bar showing the time scale of the plot. :param ax: The axes object to modify. :type ax: matplotlib.axes._subplots.AxesSubplot :param inverted_y: Set true if the plot has 0 at the top :type inverted_y: bool, optional :param pad: Padding between the scale bar and the plot. Defaults to 0.01. :type pad: float, optional :param lw: Line width for the scale bar. Defaults to None, which uses the default line width. :type lw: float, optional :param color: Color for the scale bar. Defaults to None, which uses the default text color. :type color: str, optional :param size: Font size for the scale bar. Defaults to None, which uses the default tick size. :type size: float, optional .. py:function:: trim_yscale_to_lims(ax, ymin, ymax) .. py:function:: plot_peth_and_raster(spike_times, starts, stops=None, pre_time=0.2, post_time=0.2, bin_size=0.01, smoothing=0, error_bars='sem', pethline_kwargs={}, errbar_kwargs={'alpha': 0.5}, eventline_kwargs={'color': plt.rcParams['text.color'], 'ls': '--'}, raster_kwargs={'s': 2, 'marker': '|'}, raster_ylabel='', figsize=(3, 6), subplot_ratio=(1, 5)) Plot a peri-event time histogram and raster plot :param spike_times: spike times :type spike_times: array :param starts: event times :type starts: array :param stops: stop times. Defaults to None. :type stops: array, optional :param pre_time: time before event to plot. Defaults to 0.2. :type pre_time: float, optional :param post_time: time after event to plot. Defaults to 0.2. :type post_time: float, optional :param bin_size: bin size for histogram. Defaults to 0.01. :type bin_size: float, optional :param smoothing: smoothing factor for histogram. Defaults to 0. :type smoothing: float, optional :param error_bars: error bars to plot. Defaults to "sem". :type error_bars: str, optional :param pethline_kwargs: kwargs for the peth line. Defaults to {}. :type pethline_kwargs: dict, optional :param errbar_kwargs: kwargs for the error bars. Defaults to {"alpha": 0.5}. :type errbar_kwargs: dict, optional :param eventline_kwargs: kwargs for the event line. Defaults to {"color": plt.rcParams["text.color"], "ls": "--"}. :type eventline_kwargs: dict, optional :param raster_kwargs: kwargs for the raster plot. Defaults to {'s':2,'marker':'|'}. :type raster_kwargs: dict, optional :param raster_ylabel: ylabel for the raster plot. Defaults to "". :type raster_ylabel: str, optional :param figsize: figure size. Defaults to (3, 6). :type figsize: tuple, optional :param subplot_ratio: ratio of the subplots. Defaults to (1, 5). :type subplot_ratio: tuple, optional :returns: matplotlib axis for the raster and peth plots :rtype: ax_raster, ax_peth