@@ -1083,53 +1083,84 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
10831083 linelengths = 1 , linewidths = None , colors = None ,
10841084 linestyles = 'solid' , ** kwargs ):
10851085 """
1086- Plot identical parallel lines at specific positions.
1086+ Plot identical parallel lines at the given positions.
10871087
1088- Plot parallel lines at the given positions. positions should be a 1D
1089- or 2D array-like object, with each row corresponding to a row or column
1090- of lines.
1088+ *positions* should be a 1D or 2D array-like object, with each row
1089+ corresponding to a row or column of lines.
10911090
10921091 This type of plot is commonly used in neuroscience for representing
1093- neural events, where it is commonly called a spike raster, dot raster,
1092+ neural events, where it is usually called a spike raster, dot raster,
10941093 or raster plot.
10951094
10961095 However, it is useful in any situation where you wish to show the
10971096 timing or position of multiple sets of discrete events, such as the
10981097 arrival times of people to a business on each day of the month or the
10991098 date of hurricanes each year of the last century.
11001099
1101- *orientation* : [ 'horizontal' | 'vertical' ]
1102- 'horizontal' : the lines will be vertical and arranged in rows
1103- 'vertical' : lines will be horizontal and arranged in columns
1100+ Parameters
1101+ ----------
1102+ positions : 1D or 2D array-like object
1103+ Each value is an event. If *positions* is a 2D array-like, each
1104+ row corresponds to a row or a column of lines (depending on the
1105+ *orientation* parameter).
1106+
1107+ orientation : {'horizontal', 'vertical'}, optional
1108+ Controls the direction of the event collections:
1109+
1110+ - 'horizontal' : the lines are arranged horizontally in rows,
1111+ and are vertical.
1112+ - 'vertical' : the lines are arranged vertically in columns,
1113+ and are horizontal.
1114+
1115+ lineoffsets : scalar or sequence of scalars, optional, default: 1
1116+ The offset of the center of the lines from the origin, in the
1117+ direction orthogonal to *orientation*.
1118+
1119+ linelengths : scalar or sequence of scalars, optional, default: 1
1120+ The total height of the lines (i.e. the lines stretches from
1121+ ``lineoffset - linelength/2`` to ``lineoffset + linelength/2``).
1122+
1123+ linewidths : scalar, scalar sequence or None, optional, default: None
1124+ The line width(s) of the event lines, in points. If it is None,
1125+ defaults to its rcParams setting.
1126+
1127+ colors : color, sequence of colors or None, optional, default: None
1128+ The color(s) of the event lines. If it is None, defaults to its
1129+ rcParams setting.
11041130
1105- *lineoffsets* :
1106- A float or array-like containing floats.
1131+ linestyles : str or tuple or a sequence of such values, optional
1132+ Default is 'solid'. Valid strings are ['solid', 'dashed',
1133+ 'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples
1134+ should be of the form::
11071135
1108- *linelengths* :
1109- A float or array-like containing floats.
1136+ (offset, onoffseq),
11101137
1111- *linewidths* :
1112- A float or array-like containing floats .
1138+ where *onoffseq* is an even length tuple of on and off ink
1139+ in points .
11131140
1114- *colors*
1115- must be a sequence of RGBA tuples (e.g., arbitrary color
1116- strings, etc, not allowed) or a list of such sequences
1141+ **kwargs : optional
1142+ Other keyword arguments are line collection properties. See
1143+ :class:`~matplotlib.collections.LineCollection` for a list of
1144+ the valid properties.
11171145
1118- *linestyles* :
1119- [ 'solid' | 'dashed' | 'dashdot' | 'dotted' ] or an array of these
1120- values
1146+ Returns
1147+ -------
11211148
1122- For linelengths, linewidths, colors, and linestyles, if only a single
1123- value is given, that value is applied to all lines. If an array-like
1124- is given, it must have the same length as positions, and each value
1125- will be applied to the corresponding row or column in positions.
1149+ A list of :class:`matplotlib.collections.EventCollection` objects that
1150+ were added.
11261151
1127- Returns a list of :class:`matplotlib.collections.EventCollection`
1128- objects that were added.
1152+ Notes
1153+ -----
11291154
1130- kwargs are :class:`~matplotlib.collections.LineCollection` properties:
1155+ For *linelengths*, *linewidths*, *colors*, and *linestyles*, if only
1156+ a single value is given, that value is applied to all lines. If an
1157+ array-like is given, it must have the same length as *positions*, and
1158+ each value will be applied to the corresponding row of the array.
11311159
1132- %(LineCollection)s
1160+ Example
1161+ -------
1162+
1163+ .. plot:: mpl_examples/pylab_examples/eventplot_demo.py
11331164 """
11341165 self ._process_unit_info (xdata = positions ,
11351166 ydata = [lineoffsets , linelengths ],
@@ -1181,6 +1212,15 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
11811212 lineoffsets = [None ]
11821213 if len (colors ) == 0 :
11831214 colors = [None ]
1215+ try :
1216+ # Early conversion of the colors into RGBA values to take care
1217+ # of cases like colors='0.5' or colors='C1'. (Issue #8193)
1218+ colors = mcolors .to_rgba_array (colors )
1219+ except ValueError :
1220+ # Will fail if any element of *colors* is None. But as long
1221+ # as len(colors) == 1 or len(positions), the rest of the
1222+ # code should process *colors* properly.
1223+ pass
11841224
11851225 if len (lineoffsets ) == 1 and len (positions ) != 1 :
11861226 lineoffsets = np .tile (lineoffsets , len (positions ))
0 commit comments