- 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
How to change the face color of a plot using Matplotlib?
To change the face color of a plot using matplotlib, we can take the following steps −
- Set the figure size and adjust the padding between and around the subplots.
- Create x and y data points using numpy.
- Create a figure and a set of subplots.
- Plot the x and y data points using plot() method with color=yellow and linewidth=7.
- Set the facecolor of the axes, using set_facecolor().
- To display the figure, use show() method.
from matplotlib import pyplot as plt import numpy as np # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Create x and y data points x = np.linspace(-10, 10, 100) y = np.sin(x) # Create a figure and set of subplots fig, ax = plt.subplots() # Plot the x and y data points with color ax.plot(x, y, color='yellow', lw=7) # Set the facecolor ax.set_facecolor('red') plt.show()
It will produce the following output
- How to change the color of a plot frame in Matplotlib?
- How to change the color of a line using radiobuttons in Matplotlib?
- How to change the color of the axis, ticks and labels for a plot in matplotlib?
- How to change the background color of a plot created by using plot function in R?
- How to change the plot line color from blue to black in Matplotlib?
- How to change the color and add grid lines to a Python Matplotlib surface plot?
- How to change the color of bars of a bar plot using ggplot2 in R?
- How to change the text color of font in the legend using Matplotlib?
- How to change the border color of box of a base R plot?
- How to customize the color and colormaps of a Plot in Matplotlib
- How to change the background color of base R plot region?
- How to change the color and size of the axes labels of a plot created by using plot function in R?
- How to change the plot border color of a ggplot2 graph in R?
- How to change the DPI of a Pandas Dataframe Plot in Matplotlib?
- How to plot a gradient color line in matplotlib?