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.stem() Function
The Axes.stem() function in axes module of matplotlib library is used to create a stem plot.
Syntax: Axes.stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, label=None, use_line_collection=False, data=None)
Parameters: This method accept the following parameters that are described below:
- x: This parameter is the sequence of x coordinates of the stems.
- y: This parameter is the sequence of y coordinates of the stem heads.
- linefmt: This parameter is the string defining the properties of the vertical lines.
- markerfmt: This parameter is the string defining the properties of the markers at the stem heads.
- basefmt: This parameter is the string defining the properties of the baseline.
- bottom: This parameter is the y-position of the baseline.
- label: This parameter is the label to use for the stems in legends.
Returns: This returns the following:
- StemContainer: This returns the container which may be treated like a tuple (markerline, stemlines, baseline).
Below examples illustrate the matplotlib.axes.Axes.broken_barh() function in matplotlib.axes:
Example-1:
# Implementation of matplotlib function import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.stem([0.3, 1.5, 2.7], [1, 3.6, 2.7], label ="stem test") ax.legend() ax.set_title('matplotlib.axes.Axes.stem Example') plt.show() |
Output:

Example-2:
# Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np x = np.linspace(0.1, 2 * np.pi, 41) y = np.exp(np.sin(x)) fig, ax = plt.subplots() ax.stem(x, y, linefmt ='grey', markerfmt ='D', bottom = 1.1, use_line_collection = True) ax.set_title('matplotlib.axes.Axes.stem Example') plt.show() |

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Important differences between Python 2.x and Python 3.x with examples
- Python | Set 4 (Dictionary, Keywords in Python)
- Python | Sort Python Dictionaries by Key or Value
- Python | Merge Python key values to list
- Reading Python File-Like Objects from C | Python
- Python | Add Logging to a Python Script
- Python | Add Logging to Python Libraries
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- Python | Visualizing O(n) using Python
- Python | Index of Non-Zero elements in Python list
- Python | Convert list to Python array
- MySQL-Connector-Python module in Python
- Python - Read blob object in python using wand library
- Python | PRAW - Python Reddit API Wrapper
- twitter-text-python (ttp) module - Python
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- Python program to check if the list contains three consecutive common numbers in Python
- Creating and updating PowerPoint Presentations in Python using python - pptx
- How to write an empty function in Python - pass statement?
- Operator Functions in Python | Set 2
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.

