- 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 set different opacity of edgecolor and facecolor of a patch in Matplotlib?
To set different opacity of edge and face color, we can use a color tuple and the 4th index of the tuple could set the opacity value of the colors.
- Set the figure size and adjust the padding between and around the subplots.
- Create a figure and a set of subplots using subplots() method.
- Set different values for edge and face color opacity.
- Add a rectangel patch using add_patch() method.
- To display the figure, use show() method.
from matplotlib import pyplot as plt, patches plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True figure, ax = plt.subplots() edge_color_opacity = 1 # 0<val<1 face_color_opacity = 0.75 # 0<val<1 ax.add_patch(patches.Rectangle((.25, .25), .50, .50, edgecolor=(1, 0, 0, edge_color_opacity), facecolor=(0, 1, 0, face_color_opacity), linewidth=2)) plt.show()
- How to label a patch in matplotlib?
- How to control the border of a bar patch in matplotlib?
- How to plot a 3D patch collection in matplotlib?
- Plot a circle with an edgecolor and hatch in Matplotlib
- Plot a rectangle with an edgecolor in Matplotlib
- Plot a circle with an edgecolor in Matplotlib
- How to rotate the rectangle patch in a plot using Matplotlib?
- Set the opacity of an image with CSS
- How to Set opacity for View in iOS?
- How to Set opacity for View in Android?
- How to set the margins of a Matplotlib figure?
- Plotting two different arrays of different lengths in matplotlib
- Set a colormap of an image in Matplotlib
- How to name different lines in the same plot of Matplotlib?
- How to set the background color of a column in a matplotlib table?