- 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
Transparent error bars without affecting the markers in Matplotlib
To make transparent error bars without affecting markers in matplotlib, we can take the following steps −
Steps
Set the figure size and adjust the padding between and around the subplots.
Make lists x, y and z for data.
Initialize a variable error_bar_width=5
Plot y versus x as lines and/or markers with attached errorbars.
Set the alpha value of bars and caps.
To display the figure, use show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = [1, 3, 5, 7] y = [1, 3, 5, 7] z = [4, 5, 1, 4] error_bar_width = 5 markers, caps, bars = plt.errorbar(x, y, z, capsize=5, elinewidth=error_bar_width, markeredgewidth=7, fmt='o', ecolor='black', capthick=2) [bar.set_alpha(0.5) for bar in bars] [cap.set_alpha(0.5) for cap in caps] plt.show()
Output
It will produce the following output −
- Related Articles
- How to avoid overlapping error bars in matplotlib?
- Plot 3D bars without axes in Matplotlib
- How to make the marker face color transparent without making the line transparent in Matplotlib?
- Plotting error bars from a dataframe using Seaborn FacetGrid (Matplotlib)
- How to turn off error bars in Seaborn Bar Plot using Matplotlib?
- Python matplotlib multiple bars
- Plotting a transparent histogram with non-transparent edge in Matplotlib
- MongoDB many insertsupdates without affecting performance?
- How to make markers on lines smaller in Matplotlib?
- How to add and remove error bars in Excel?
- How to make axes transparent in Matplotlib?
- How to create custom markers on a plot in Matplotlib
- How to adjust the space between legend markers and labels in Matplotlib?
- How to make two markers share the same label in the legend using Matplotlib?
- Controlling the width of bars in Matplotlib with per-month data

Advertisements