
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
Changing the Color of an Axis in Matplotlib
First, we can get the axes. Then, ax.spines could help to set the color by specifying the name of the axes, i.e., top, bottom, right and left.
Steps
Add an axes to the current figure and make it the current axes.
Using step 1 axes, we can set the color of all the axes.
Using ax.spines[axes].set_color(‘color’), set the color of the axes. Axes could be bottom, top, right, and left. Color could be yellow, red, black, and blue.
To show the figure, use the plt.show() method.
Example
from matplotlib import pyplot as plt ax = plt.axes() ax.spines['bottom'].set_color('yellow') ax.spines['top'].set_color('red') ax.spines['right'].set_color('black') ax.spines['left'].set_color('blue') plt.show()
Output
Advertisements