matplotlib.pyplot.eventplot#

matplotlib.pyplot.eventplot(positions,*,orientation='horizontal',lineoffsets=1,linelengths=1,linewidths=None,colors=None,alpha=None,linestyles='solid',data=None,**kwargs)[source]#

Plot identical parallel lines at the given positions.

This type of plot is commonly used in neuroscience for representingneural events, where it is usually called a spike raster, dot raster,or raster plot.

However, it is useful in any situation where you wish to show thetiming or position of multiple sets of discrete events, such as thearrival times of people to a business on each day of the month or thedate of hurricanes each year of the last century.

Parameters:
positionsarray-like or list of array-like

A 1D array-like defines the positions of one sequence of events.

Multiple groups of events may be passed as a list of array-likes.Each group can be styled independently by passing lists of valuestolineoffsets,linelengths,linewidths,colors andlinestyles.

Note thatpositions can be a 2D array, but in practice differentevent groups usually have different counts so that one will use alist of different-length arrays rather than a 2D array.

orientation{'horizontal', 'vertical'}, default: 'horizontal'

The direction of the event sequence:

  • 'horizontal': the events are arranged horizontally.The indicator lines are vertical.

  • 'vertical': the events are arranged vertically.The indicator lines are horizontal.

lineoffsetsfloat or array-like, default: 1

The offset of the center of the lines from the origin, in thedirection orthogonal toorientation.

Ifpositions is 2D, this can be a sequence with length matchingthe length ofpositions.

linelengthsfloat or array-like, default: 1

The total height of the lines (i.e. the lines stretches fromlineoffset-linelength/2 tolineoffset+linelength/2).

Ifpositions is 2D, this can be a sequence with length matchingthe length ofpositions.

linewidthsfloat or array-like, default:rcParams["lines.linewidth"] (default:1.5)

The line width(s) of the event lines, in points.

Ifpositions is 2D, this can be a sequence with length matchingthe length ofpositions.

colorscolor or list of color, default:rcParams["lines.color"] (default:'C0')

The color(s) of the event lines.

Ifpositions is 2D, this can be a sequence with length matchingthe length ofpositions.

alphafloat or array-like, default: 1

The alpha blending value(s), between 0 (transparent) and 1(opaque).

Ifpositions is 2D, this can be a sequence with length matchingthe length ofpositions.

linestylesstr or tuple or list of such values, default: 'solid'

Default is 'solid'. Valid strings are ['solid', 'dashed','dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuplesshould be of the form:

(offset,onoffseq),

whereonoffseq is an even length tuple of on and off inkin points.

Ifpositions is 2D, this can be a sequence with length matchingthe length ofpositions.

dataindexable object, optional

If given, the following parameters also accept a strings, which isinterpreted asdata[s] ifs is a key indata:

positions,lineoffsets,linelengths,linewidths,colors,linestyles

**kwargs

Other keyword arguments are line collection properties. SeeLineCollection for a list of the valid properties.

Returns:
list ofEventCollection

TheEventCollection that were added.

Notes

Forlinelengths,linewidths,colors,alpha andlinestyles, ifonly a single value is given, that value is applied to all lines. If anarray-like is given, it must have the same length aspositions, andeach value will be applied to the corresponding row of the array.

Examples

(Sourcecode,2x.png,png)

On this page