- 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
Setting different error bar colors in barplot in Matplotlib
To set different error bar colors in barplot in matplotlib, we can take the following steps −
Create a figure and add a set of subplots using subplots() method.
Make a barplot with data range 4, heights 2. yerr means vertical errorbars to the bar tips. The values are sizes relative to the data. Dictionary of kwargs to be passed to the errorbar method. Values of ecolor or capsize defined here take precedence over the independent kwargs.
To display the figure, use show() method.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() ax.bar(range(4), [2] * 4, yerr=range(1, 5), color=['green', 'yellow', 'red', 'black', 'orange'], error_kw=dict(ecolor='black', lw=2, capsize=5, capthick=2)) plt.show()
Output
- Related Articles
- Setting Different Bar color in Matplotlib
- Setting the spacing between grouped bar plots in Matplotlib
- How to create progress bar in different colors in Bootstrap
- How to show an image in Matplotlib in different colors with different channels?
- Plot different colors for different categorical levels using matplotlib
- How to specify different colors for different bars in a Python matplotlib histogram?
- How to give a Pandas/Matplotlib bar graph custom colors?
- How to turn off error bars in Seaborn Bar Plot using Matplotlib?
- How do I make bar plots automatically cycle across different colors?
- Automatically setting Y-axis limits for a bar graph using Matplotlib
- Fill bars in a base R barplot with colors based on frequency.
- How to increase the thickness of error line in a Matplotlib bar chart?
- Map values to colors in Matplotlib
- How to create stacked barplot using barplot function with each bar having unique color in R?
- How to generate random colors in Matplotlib?

Advertisements