- 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
How to decouple hatch and edge color in Matplotlib?
To decouple hatch and edge color in matplotlib, we can use hatch color “o” and edge color “red”.−
Steps
- Create a new figure or activate existing figure.
- Add a subplot arrangement to the current axes.
- Create two lists of data points.
- Use bar() method with hatch and edgecolor.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax1 = fig.add_subplot(111) x = [3, 6, 1] y = [4, 6, 1] ax1.bar(x, y, color='black', edgecolor='red', hatch="o", lw=1., zorder=0) plt.show()
Output
Advertisements