
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Draw Grid Lines Behind Matplotlib Bar Graph
To draw grid lines behind matplotlib bar graph, we can take the following Steps −
Make a list of numbers, i.e., data.
Make a bar using the bar() method, by passing data, color='red' and alpha = 0.5. The alpha blending value should be between 0 (transparent) and 1 (opaque).
To configure the grid lines, use the grid() method, with color='yellow', linewidth=1, axis='both' and alpha=0.5.
To display the figure, show() method.
Example
from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = [3, 5, 9, 15, 12] plt.bar(range(len(data)), data, color='red', alpha=0.5) plt.grid(color='yellow', linewidth=1, axis='both', alpha=0.5) plt.show()
Output
Advertisements