@@ -330,11 +330,50 @@ def test_errorbar(self):
330
330
uplims = True , xuplims = True ,
331
331
label = 'Data' )
332
332
333
- @pytest .mark .xfail (reason = "Test for eventplot not written yet" )
334
333
@mpl .style .context ("default" )
335
334
def test_eventplot (self ):
336
- fig , ax = plt .subplots ()
337
- ax .eventplot (...)
335
+ mpl .rcParams ["date.converter" ] = "concise"
336
+
337
+ fig , (ax1 , ax2 , ax3 ) = plt .subplots (3 , 1 , layout = "constrained" )
338
+
339
+ x_dates1 = np .array ([datetime .datetime (2020 , 6 , 30 ),
340
+ datetime .datetime (2020 , 7 , 22 ),
341
+ datetime .datetime (2020 , 8 , 3 ),
342
+ datetime .datetime (2020 , 9 , 14 ),],
343
+ dtype = np .datetime64 ,
344
+ )
345
+
346
+ ax1 .eventplot (x_dates1 )
347
+
348
+ np .random .seed (19680801 )
349
+
350
+ start_date = datetime .datetime (2020 , 7 , 1 )
351
+ end_date = datetime .datetime (2020 , 10 , 15 )
352
+ date_range = end_date - start_date
353
+
354
+ dates1 = start_date + np .random .rand (30 ) * date_range
355
+ dates2 = start_date + np .random .rand (10 ) * date_range
356
+ dates3 = start_date + np .random .rand (50 ) * date_range
357
+
358
+ colors1 = ['C1' , 'C2' , 'C3' ]
359
+ lineoffsets1 = np .array ([1 , 6 , 8 ])
360
+ linelengths1 = [5 , 2 , 3 ]
361
+
362
+ ax2 .eventplot ([dates1 , dates2 , dates3 ],
363
+ colors = colors1 ,
364
+ lineoffsets = lineoffsets1 ,
365
+ linelengths = linelengths1 )
366
+
367
+ lineoffsets2 = np .array ([
368
+ datetime .datetime (2020 , 7 , 1 ),
369
+ datetime .datetime (2020 , 7 , 15 ),
370
+ datetime .datetime (2020 , 8 , 1 )
371
+ ], dtype = np .datetime64 )
372
+
373
+ ax3 .eventplot ([dates1 , dates2 , dates3 ],
374
+ colors = colors1 ,
375
+ lineoffsets = lineoffsets2 ,
376
+ linelengths = linelengths1 )
338
377
339
378
@mpl .style .context ("default" )
340
379
def test_fill (self ):
0 commit comments