@@ -1184,7 +1184,7 @@ def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
1184
1184
"colors" , "linestyles" ])
1185
1185
@_docstring .dedent_interpd
1186
1186
def eventplot (self , positions , orientation = 'horizontal' , lineoffsets = 1 ,
1187
- linelengths = 1 , linewidths = None , colors = None ,
1187
+ linelengths = 1 , linewidths = None , colors = None , alpha = None ,
1188
1188
linestyles = 'solid' , ** kwargs ):
1189
1189
"""
1190
1190
Plot identical parallel lines at the given positions.
@@ -1246,6 +1246,13 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1246
1246
If *positions* is 2D, this can be a sequence with length matching
1247
1247
the length of *positions*.
1248
1248
1249
+ alpha : float or array-like, default: 1
1250
+ The alpha blending value(s), between 0 (transparent) and 1
1251
+ (opaque).
1252
+
1253
+ If *positions* is 2D, this can be a sequence with length matching
1254
+ the length of *positions*.
1255
+
1249
1256
linestyles : str or tuple or list of such values, default: 'solid'
1250
1257
Default is 'solid'. Valid strings are ['solid', 'dashed',
1251
1258
'dashdot', 'dotted', '-', '--', '-.', ':']. Dash tuples
@@ -1273,8 +1280,8 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1273
1280
1274
1281
Notes
1275
1282
-----
1276
- For *linelengths*, *linewidths*, *colors*, and *linestyles*, if only
1277
- a single value is given, that value is applied to all lines. If an
1283
+ For *linelengths*, *linewidths*, *colors*, *alpha* and *linestyles*, if
1284
+ only a single value is given, that value is applied to all lines. If an
1278
1285
array-like is given, it must have the same length as *positions*, and
1279
1286
each value will be applied to the corresponding row of the array.
1280
1287
@@ -1316,6 +1323,8 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1316
1323
linewidths = [linewidths ]
1317
1324
if not np .iterable (colors ):
1318
1325
colors = [colors ]
1326
+ if not np .iterable (alpha ):
1327
+ alpha = [alpha ]
1319
1328
if hasattr (linestyles , 'lower' ) or not np .iterable (linestyles ):
1320
1329
linestyles = [linestyles ]
1321
1330
@@ -1352,8 +1361,9 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1352
1361
if len (linewidths ) == 1 :
1353
1362
linewidths = np .tile (linewidths , len (positions ))
1354
1363
if len (colors ) == 1 :
1355
- colors = list (colors )
1356
- colors = colors * len (positions )
1364
+ colors = list (colors ) * len (positions )
1365
+ if len (alpha ) == 1 :
1366
+ alpha = list (alpha ) * len (positions )
1357
1367
if len (linestyles ) == 1 :
1358
1368
linestyles = [linestyles ] * len (positions )
1359
1369
@@ -1369,20 +1379,25 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1369
1379
if len (colors ) != len (positions ):
1370
1380
raise ValueError ('colors and positions are unequal sized '
1371
1381
'sequences' )
1382
+ if len (alpha ) != len (positions ):
1383
+ raise ValueError ('alpha and positions are unequal sized '
1384
+ 'sequences' )
1372
1385
if len (linestyles ) != len (positions ):
1373
1386
raise ValueError ('linestyles and positions are unequal sized '
1374
1387
'sequences' )
1375
1388
1376
1389
colls = []
1377
- for position , lineoffset , linelength , linewidth , color , linestyle in \
1390
+ for position , lineoffset , linelength , linewidth , color , alpha_ , \
1391
+ linestyle in \
1378
1392
zip (positions , lineoffsets , linelengths , linewidths ,
1379
- colors , linestyles ):
1393
+ colors , alpha , linestyles ):
1380
1394
coll = mcoll .EventCollection (position ,
1381
1395
orientation = orientation ,
1382
1396
lineoffset = lineoffset ,
1383
1397
linelength = linelength ,
1384
1398
linewidth = linewidth ,
1385
1399
color = color ,
1400
+ alpha = alpha_ ,
1386
1401
linestyle = linestyle )
1387
1402
self .add_collection (coll , autolim = False )
1388
1403
coll ._internal_update (kwargs )
0 commit comments