- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I plot a step function with Matplotlib in Python?
To plot a step function with matplotlib in Python, we can take the following steps −
Create data points for x and y.
Make a step plot using step() method.
To display the figure, use show() method.
Example
import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.array([1, 3, 4, 5, 7]) y = np.array([1, 9, 16, 25, 49]) plt.step(x, y, 'r*') plt.show()
Output
- Related Articles
- How do I plot only a table in Matplotlib?
- How to plot a function defined with def in Python? (Matplotlib)
- How to plot a multivariate function in Python Matplotlib?
- How can I plot a single point in Matplotlib Python?
- How do I plot multiple X or Y axes in Matplotlib?
- How do I plot hatched bars using Pandas and Matplotlib?
- How do I plot Shapely polygons and objects using Matplotlib?
- How to save a plot in Seaborn with Python (Matplotlib)?
- Can I give a border to a line in Matplotlib plot function?
- How do I let my Matplotlib plot go beyond the axes?
- How to a plot stem plot in Matplotlib Python?
- How do I put a circle with annotation in matplotlib?
- How do I print a Celsius symbol with Matplotlib?
- How to plot a 3D density map in Python with Matplotlib?
- How to plot a 2D matrix in Python with colorbar Matplotlib?

Advertisements