- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 to plot a line in Matplotlib with an interval at each data point?
To plot a line in Matplotlib with an interval at each data point, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Make an array of means and standard deviations.
- Plot means using plot() method.
- Fill the area between means+stds and means-stds, alpha=0.7 and color='yellow'.
- To display the figure, use show() method.
Example
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True means = np.array([3, 5, 1, 8, 4, 6]) stds = np.array([1.3, 2.6, 0.78, 3.01, 2.32, 2.9]) plt.plot(means, color='red', lw=7) plt.fill_between(range(6), means - stds, means + stds, alpha=.7, color='yellow') plt.show()
Output
- Related Articles
- How to plot one single data point in Matplotlib?
- How to plot a smooth line with matplotlib?
- How to plot a line graph from histogram data in Matplotlib?
- How to plot 1D data at a given Y-value with PyLab using Matplotlib?
- How to animate a line plot in Matplotlib?
- Line plot with arrows in Matplotlib
- How to draw an average line for a scatter plot in MatPlotLib?
- How to plot a line (polygonal chain) with matplotlib with minimal smoothing?
- How to plot a 3D continuous line in Matplotlib?
- How to plot a gradient color line in matplotlib?
- How to plot a point on 3D axes in Matplotlib?
- How to make a 4D plot with Matplotlib using arbitrary data?
- How to add a single data point in an Excel line chart?
- How to extract data from a Matplotlib plot?
- How to plot data into imshow() with custom colormap in Matplotlib?

Advertisements