×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python | Error-Bar in Plotting

Python | Error-Bar in Plotting: In this article, we are going to learn how to add error-bar in plotting in Python?
Submitted by Anuj Singh, on July 16, 2020

It is one of the most important aspects of plotting. Because of the huge application in experimental Data Visualization, matplotlib has provided a function matplotlib.pyplot.errorbar() for our desired operations.

Python | Error-Bar in Plotting (1)

Python | Error-Bar in Plotting (2)

Python code to demonstrate example of error-bar in plotting

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(0.1, 5, 0.1)
y = np.sin(x)
yerr = 0.1 + 0.1 * np.sqrt(x)

plt.figure()
plt.errorbar(x, y, yerr=yerr)
plt.title('Errorbar')
plt.show()

y = np.exp(-x)
yerr = 0.1 + 0.1 * np.sqrt(x)

plt.figure()
plt.errorbar(x, y, yerr=yerr)
plt.title('Errorbar')
plt.show()

Output:

Output is as figure
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.