MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_eventplot

Function test_eventplot

lib/matplotlib/tests/test_axes.py:5429–5469  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5427@image_comparison(['eventplot.png', 'eventplot.png'], remove_text=True,
5428 style='_classic_test')
5429def test_eventplot():
5430 np.random.seed(0)
5431
5432 data1 = np.random.random([32, 20]).tolist()
5433 data2 = np.random.random([6, 20]).tolist()
5434 data = data1 + data2
5435 num_datasets = len(data)
5436
5437 colors1 = [[0, 1, .7]] * len(data1)
5438 colors2 = [[1, 0, 0],
5439 [0, 1, 0],
5440 [0, 0, 1],
5441 [1, .75, 0],
5442 [1, 0, 1],
5443 [0, 1, 1]]
5444 colors = colors1 + colors2
5445
5446 lineoffsets1 = 12 + np.arange(0, len(data1)) * .33
5447 lineoffsets2 = [-15, -3, 1, 1.5, 6, 10]
5448 lineoffsets = lineoffsets1.tolist() + lineoffsets2
5449
5450 linelengths1 = [.33] * len(data1)
5451 linelengths2 = [5, 2, 1, 1, 3, 1.5]
5452 linelengths = linelengths1 + linelengths2
5453
5454 fig = plt.figure()
5455 axobj = fig.add_subplot()
5456 colls = axobj.eventplot(data, colors=colors, lineoffsets=lineoffsets,
5457 linelengths=linelengths)
5458
5459 num_collections = len(colls)
5460 assert num_collections == num_datasets
5461
5462 # Reuse testcase from above for a labeled data test
5463 data = {"pos": data, "c": colors, "lo": lineoffsets, "ll": linelengths}
5464 fig = plt.figure()
5465 axobj = fig.add_subplot()
5466 colls = axobj.eventplot("pos", colors="c", lineoffsets="lo",
5467 linelengths="ll", data=data)
5468 num_collections = len(colls)
5469 assert num_collections == num_datasets
5470
5471
5472@image_comparison(['test_eventplot_defaults.png'], remove_text=True,

Callers

nothing calls this directly

Calls 3

figureMethod · 0.80
add_subplotMethod · 0.80
eventplotMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…