Python | Eventplot using Matplotlib

Here, we are going to learn about the eventplot using matplotlib and its Python implementation.
Submitted by Anuj Singh, on August 06, 2020

In Eventplot, we use to plot identical parallel lines at the given reference position.

Such plots mostly have an application in neuroscience for representing neural events, where it is usually called a spike raster, dot raster, or raster plot. Furthermore, they can be useful in any area where we need to show the position or timings of multiple sets of discrete events. For example, the arrival times of people to an event on each day of the month or the date of hurricanes each year of the last century.

The following figure shows the implementation of the same.

Illustration:

Python | Eventplot using Matplotlib

Python code for eventplot using matplotlib

import matplotlib.pyplot as plt
import numpy as np

data1 = np.random.random([6, 50])

colors1 = ['C{}'.format(i) for i in range(6)]

lineoffsets1 = [-15, -3, 1, -10, 6, 10]
linelengths1 = [5, 2, 1, 1, 3, 1.5]

plt.eventplot(data1, colors=colors1, lineoffsets=lineoffsets1,
                    linelengths=linelengths1)
plt.title('Event Plot')
plt.xlabel('Time(s)')
plt.ylabel('Signal')

Output:

Output is as figure





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.