Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
matplotlib.axes.Axes.eventplot() Function
The Axes.eventplot() function in axes module of matplotlib library is used to plot identical parallel lines at the given positions.
Syntax: Axes.eventplot(self, positions, orientation=’horizontal’, lineoffsets=1, linelengths=1, linewidths=None, colors=None, linestyles=’solid’, *, data=None, **kwargs)
Parameters: This method accept the following parameters that are described below:
- positions : This parameter is the sequence of objects and each value is an event.
- orientation: This parameter is used to controls the direction of the event collections {‘horizontal’, ‘vertical’}.
- lineoffsets: This parameter is the offset of the center of the lines from the origin, in the direction orthogonal to orientation.
- linelengths: This parameter is the total height of the lines.
- linewidths: This parameter is the line width(s) of the event lines, in points.
Returns: This returns the following:
- list: This returns the list of EventCollection objects.
Below examples illustrate the matplotlib.axes.Axes.eventplot() function in matplotlib.axes:
Example #1:
#Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['font.size'] = 8.0 np.random.seed(789680) data1 = np.random.random([6, 50]) colors1 = ['C{}'.format(i) for i in range(6)] lineoffsets1 = np.array([-9, -13, 1, 15, 6, 10]) linelengths1 = [5, 2, 9, 11, 3, 5] fig, axs = plt.subplots() axs.eventplot(data1, colors=colors1, lineoffsets=lineoffsets1, linelengths=linelengths1) axs.set_title('matplotlib.axes.Axes.eventplot Example') plt.show() |
Output:

Example #2:
# Implementation of matplotlib function import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.rcParams['font.size'] = 8.0 np.random.seed(789680) data1 = np.random.gamma(4, size =[60, 50]) lineoffsets1 = 1linelengths1 = 1 fig, [axs1, axs2]= plt.subplots(2, 1) axs1.eventplot(data1, colors ='green', lineoffsets = lineoffsets1, linelengths = linelengths1) axs2.eventplot(data1, colors ='green', lineoffsets = lineoffsets1, linelengths = linelengths1, orientation ='vertical') axs1.set_title('matplotlib.axes.Axes.eventplot Example') plt.show() |

Recommended Posts:
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- Python - Read blob object in python using wand library
- Important differences between Python 2.x and Python 3.x with examples
- Python | PRAW - Python Reddit API Wrapper
- Reading Python File-Like Objects from C | Python
- Python | Merge Python key values to list
- MySQL-Connector-Python module in Python
- Python | Convert list to Python array
- twitter-text-python (ttp) module - Python
- Python | Index of Non-Zero elements in Python list
- Python | Add Logging to Python Libraries
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Add Logging to a Python Script
- Python | Sort Python Dictionaries by Key or Value
- Python | Visualizing O(n) using Python
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- set add() in python
- Python Set | pop()
- Python Try Except
- Python | a += b is not always a = a + b
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

