- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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
63 Lectures 6 hours
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.
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.
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()
- Changing the color of a single X-axis tick label in Matplotlib
- Changing the formatting of a datetime axis in Matplotlib
- How to set the unit length of an axis in Matplotlib?
- How to change the color of the axis, ticks and labels for a plot in matplotlib?
- Changing the color a Tkinter rectangle on clicking
- Changing the color and marker of each point using Seaborn jointplot
- Changing the background color of a tkinter window using colorchooser module
- How to change the range of the X-axis and Y-axis in Matplotlib?
- How to draw a line outside of an axis in Matplotlib?
- Show tick labels when sharing an axis in Matplotlib
- Preserve padding while setting an axis limit in matplotlib
- How to set the value of the axis multiplier in matplotlib?
- How can I get the length of a single unit on an axis in Matplotlib?
- Using Colormaps to set the color of line in Matplotlib