Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Pandas
  • Numpy
  • Seaborn
  • Ploty
  • Data visualization
  • Data Analysis
  • Power BI
  • Tableau
  • Machine Learning
  • Deep Learning
  • NLP
  • Computer Vision
  • Data Science for Beginners
  • Data Science interview questions
  • Data analysis interview questions
  • NLP Interview questions
Open In App
Next Article:
Change Font Size in Matplotlib
Next article icon

Change the error bar thickness in Matplotlib

Last Updated : 11 Oct, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Matplotlib is a Python library which is widely used by data analytics. Matplotlib.pyplot.errorbar()  is a pyplot module consisting of a function which provides a MATLAB like interface.

Changing Error Bar Thickness

Before changing the thickness of error bar let us see what error bar is and how we can plot and use them.

Error Bar: Error bars are bars that we incorporate within our data conveying the unpredictability in reported measurements. In layman terms it displays graphical representations of the variableness of data and used on graphs to show the error measurement.

Syntax: matplotlib.pyplot.errorbar(x, y, yerr=None, xerr=None, fmt='', ecolor=None, elinewidth=None, capsize=None, barsabove=False, lolims=False, uplims=False, xlolims=False, xuplims=False, errorevery=1, capthick=None, *, data=None, **kwargs)

Example 1:

Python3
# importing necessary libraries import matplotlib.pyplot as plt  # example data x = np.arange(3, 5, 0.5) y = np.arange(9, 11, 0.5)  # plotting with default thickness of bar plt.title("1. Without changing thickness") plt.errorbar(x, y, xerr=0.2, yerr=0.6, fmt='o') plt.show()  # plotting with changed thickness of bar plt.title("1. With changed thickness of bar")  # change elinewidth to change the thickness of bar plt.errorbar(x, y, xerr=0.2, yerr=0.6, fmt='o', elinewidth=4) plt.show() 

Output : 

Figure 1.1
Figure 1.2

As we can see the difference in both the images. The elinewidth parameter takes the integer value and then increase the thickness of error bar.

Example 2:

Python3
# importing necessary libraries import matplotlib.pyplot as plt  # example data x = np.arange(1, 3, 0.5) y = np.log(x)  # plotting with default thickness of bar plt.title("2. Without changing thickness") plt.errorbar(x, y, xerr=0.2, yerr=0.4, fmt='o', ecolor='black', capsize=5) plt.show()  # plotting with changed thickness of bar # change elinewidth to change the thickness of bar plt.title("2. With changed thickness of bar") plt.errorbar(x, y, xerr=0.2, yerr=0.4, fmt='o', elinewidth=4,              ecolor='black', capsize=5, capthick=3)  plt.show() 

Output :

Figure 2.1
Figure 2.2

In the above example we have applied to capsize as caps containing the complete information regarding how big the uncertainty is. If the bar is smaller, lower the std and lower the spread of data which means that data is concentrated around mean and if the bar is larger, larger the std and larger the spread of data.


Next Article
Change Font Size in Matplotlib

A

amnindersingh1414
Improve
Article Tags :
  • Machine Learning
  • AI-ML-DS
  • Python-matplotlib
  • python
Practice Tags :
  • Machine Learning
  • python

Similar Reads

  • Matplotlib.axes.Axes.get_yticklines() in Python
    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.
    2 min read
  • Change Font Size in Matplotlib
    Matplotlib library is mainly used to create 2-dimensional graphs and plots. It has a module named Pyplot which makes things easy for plotting. To change the font size in Matplotlib, the two methods given below can be used with appropriate parameters:  Change Font Size using fontsize You can set the
    2 min read
  • Matplotlib.axes.Axes.errorbar() in Python
    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.
    3 min read
  • Use error bars in a Matplotlib scatter plot
    When visualizing data, error bars provide a great way to indicate variability or uncertainty in your measurements. In this article, we’ll explore how to create scatter plots with error bars using Matplotlib's errorbar() function. Syntaxmatplotlib.pyplot.errorbar( x, y, yerr=None, xerr=None, fmt='',
    2 min read
  • Change plot size in Matplotlib - Python
    Plots are an effective way of visually representing data and summarizing it beautifully. However, if not plotted efficiently it seems appears complicated. Python's Matplotlib provides several libraries for data representation. While making a plot we need to optimize its size. In this article, we wil
    3 min read
  • Change grid line thickness in 3D surface plot in Python - Matplotlib
    Prerequisites: Matplotlib Using Matplotlib library we can plot the three-dimensional plot by importing the mplot3d toolkit. In this plot, we are going the change the thickness of the gridline in a three-dimensional surface plot. Surface Plot is the diagram of 3D data it shows the functional relation
    6 min read
  • Change the line opacity in Matplotlib
    Changing Line Opacity in Matplotlib means adjusting the transparency level of a line in a plot. Opacity controls how much the background or overlapping elements are visible through the line. A fully opaque line is solid, while a more transparent line allows other elements behind it to be seen. Let's
    2 min read
  • How to Change the Size of Figures in Matplotlib?
    Matplotlib provides a default figure size of 6.4 inches in width and 4.8 inches in height. While this is suitable for basic graphs, various situations may require resizing figures for better visualization, presentation or publication. This article explores multiple methods to adjust the figure size
    3 min read
  • How to change the font size of the Title in a Matplotlib figure ?
    In this article, we are going to discuss how to change the font size of the title in a figure using matplotlib module in Python. As we use matplotlib.pyplot.title() method to assign a title to a plot, so in order to change the font size, we are going to use the font size argument of the pyplot.title
    2 min read
  • Changing the "tick frequency" on x or y axis in matplotlib
    In this article, we will see how can we change the tick frequency on the x-axis or y-axis in the Matplotlib library. Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. If you had not installed the Matplotlib library you can install it using
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences