Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de03d41

Browse files
authored
Merge pull request #17329 from timhoffm/doc-eventplot
Improve docs of eventplot()
2 parents 93e9641 + 1c7f53c commit de03d41

File tree

2 files changed

+43
-41
lines changed

2 files changed

+43
-41
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,9 +1285,6 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
12851285
"""
12861286
Plot identical parallel lines at the given positions.
12871287
1288-
*positions* should be a 1D or 2D array-like object, with each row
1289-
corresponding to a row or column of lines.
1290-
12911288
This type of plot is commonly used in neuroscience for representing
12921289
neural events, where it is usually called a spike raster, dot raster,
12931290
or raster plot.
@@ -1299,48 +1296,53 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
12991296
13001297
Parameters
13011298
----------
1302-
positions : 1D or 2D array-like object
1303-
Each value is an event. If *positions* is a 2D array-like, each
1304-
row corresponds to a row or a column of lines (depending on the
1305-
*orientation* parameter).
1299+
positions : array-like or list of array-like
1300+
A 1D array-like defines the positions of one sequence of events.
1301+
1302+
Multiple groups of events may be passed as a list of array-likes.
1303+
Each group can be styled independently by passing lists of values
1304+
to *lineoffsets*, *linelengths*, *linewidths*, *colors* and
1305+
*linestyles*.
1306+
1307+
Note that *positions* can be a 2D array, but in practice different
1308+
event groups usually have different counts so that one will use a
1309+
list of different-length arrays rather than a 2D array.
13061310
13071311
orientation : {'horizontal', 'vertical'}, default: 'horizontal'
1308-
The direction of the event collections:
1312+
The direction of the event sequence:
13091313
1310-
- 'horizontal': the lines are arranged horizontally in rows,
1311-
and are vertical.
1312-
- 'vertical': the lines are arranged vertically in columns,
1313-
and are horizontal.
1314+
- 'horizontal': the events are arranged horizontally.
1315+
The indicator lines are vertical.
1316+
- 'vertical': the events are arranged vertically.
1317+
The indicator lines are horizontal.
13141318
13151319
lineoffsets : float or array-like, default: 1
13161320
The offset of the center of the lines from the origin, in the
13171321
direction orthogonal to *orientation*.
13181322
1319-
A sequence must match the dimension of *positions*
1320-
in the direction of *orientation*.
1323+
If *positions* is 2D, this can be a sequence with length matching
1324+
the length of *positions*.
13211325
13221326
linelengths : float or array-like, default: 1
13231327
The total height of the lines (i.e. the lines stretches from
13241328
``lineoffset - linelength/2`` to ``lineoffset + linelength/2``).
13251329
1326-
If a sequence, then *positions* must be 2D and the length
1327-
must match the first dimension of *positions*.
1330+
If *positions* is 2D, this can be a sequence with length matching
1331+
the length of *positions*.
13281332
1329-
linewidths : float or array-like or None, default: None
1330-
The line width(s) of the event lines, in points. If it is None,
1331-
defaults to its rcParams setting.
1333+
linewidths : float or array-like, default: :rc:`lines.linewidth`
1334+
The line width(s) of the event lines, in points.
13321335
1333-
If a sequence, then *positions* must be 2D and the length
1334-
must match the first dimension of *positions*.
1336+
If *positions* is 2D, this can be a sequence with length matching
1337+
the length of *positions*.
13351338
1336-
colors : color or list of colors or None, default: None
1337-
The color(s) of the event lines. If it is None, defaults to its
1338-
rcParams setting.
1339+
colors : color or list of colors, default: :rc:`lines.color`
1340+
The color(s) of the event lines.
13391341
1340-
If a sequence, then *positions* must be 2D and the length
1341-
must match the first dimension of *positions*.
1342+
If *positions* is 2D, this can be a sequence with length matching
1343+
the length of *positions*.
13421344
1343-
linestyles : str or tuple or a sequence of such values, optional
1345+
linestyles : str or tuple or list of such values, default: 'solid'
13441346
Default is 'solid'. Valid strings are ['solid', 'dashed',
13451347
'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples
13461348
should be of the form::
@@ -1350,11 +1352,10 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
13501352
where *onoffseq* is an even length tuple of on and off ink
13511353
in points.
13521354
1353-
If a sequence, then *positions* must be 2D and the length
1354-
must match the first dimension of *positions*.
1355-
1355+
If *positions* is 2D, this can be a sequence with length matching
1356+
the length of *positions*.
13561357
1357-
**kwargs : optional
1358+
**kwargs
13581359
Other keyword arguments are line collection properties. See
13591360
`.LineCollection` for a list of the valid properties.
13601361

lib/matplotlib/collections.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ class EventCollection(LineCollection):
14481448
14491449
The events are given by a 1-dimensional array, usually the position of
14501450
something along an axis, such as time or length. They do not have an
1451-
amplitude and are displayed as vertical or horizontal parallel bars.
1451+
amplitude and are displayed as parallel lines.
14521452
"""
14531453

14541454
_edge_default = True
@@ -1471,8 +1471,9 @@ def __init__(self,
14711471
Each value is an event.
14721472
14731473
orientation : {'horizontal', 'vertical'}, default: 'horizontal'
1474-
The orientation of the **collection** (the event bars are along
1475-
the orthogonal direction).
1474+
The sequence of events is plotted along this direction.
1475+
The marker lines of the single events are along the orthogonal
1476+
direction.
14761477
14771478
lineoffset : float, default: 0
14781479
The offset of the center of the markers from the origin, in the
@@ -1482,11 +1483,11 @@ def __init__(self,
14821483
The total height of the marker (i.e. the marker stretches from
14831484
``lineoffset - linelength/2`` to ``lineoffset + linelength/2``).
14841485
1485-
linewidth : float or None, default: None
1486-
If it is None, defaults to its rcParams setting, in sequence form.
1486+
linewidth : float, default: :rc:`lines.linewidth`
1487+
The line width of the event lines, in points.
14871488
1488-
color : color, sequence of colors or None, default: None
1489-
If it is None, defaults to its rcParams setting, in sequence form.
1489+
color : color or list of colors, default: :rc:`lines.color`
1490+
The color of the event lines.
14901491
14911492
linestyle : str or tuple, default: 'solid'
14921493
Valid strings are ['solid', 'dashed', 'dashdot', 'dotted',
@@ -1497,10 +1498,10 @@ def __init__(self,
14971498
where *onoffseq* is an even length tuple of on and off ink
14981499
in points.
14991500
1500-
antialiased : {None, 1, 2}, optional
1501-
If it is None, defaults to its rcParams setting, in sequence form.
1501+
antialiased : bool, default: :rc:`lines.antialiased`
1502+
Whether to use antialiasing for drawing the lines.
15021503
1503-
**kwargs : optional
1504+
**kwargs
15041505
Other keyword arguments are line collection properties. See
15051506
:class:`~matplotlib.collections.LineCollection` for a list of
15061507
the valid properties.

0 commit comments

Comments
 (0)