- 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
Drawing a rectangle with only border in Matplotlib
To draw a rectangle with only border in matplotlib, we can take the following steps−
- Create a figure and a set of subplots.
- Get the current axes, creating one if necessary.
- Add a patch, i.e., a rectangle to the current axes that is returned in step 2. Set the facecolor attribute to 'none'.
- To display the figure, use show() method.
from matplotlib import pyplot as plt, patches plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True figure, _ = plt.subplots() ax = plt.gca() ax.add_patch(patches.Rectangle((.25, .25), .50, .50, edgecolor='orange', facecolor='none', linewidth=2)) plt.show()
- Drawing a network graph with networkX and Matplotlib
- Plot a rectangle with an edgecolor in Matplotlib
- Drawing multiple figures in parallel in Python with Matplotlib
- Matplotlib – Drawing lattices and graphs with Networkx
- How to display only a left and bottom box border in Matplotlib?
- Drawing circles on an image with Matplotlib and NumPy
- Drawing average line in histogram in Matplotlib
- Plot a circle inside a rectangle in Matplotlib
- Drawing lines between two plots in Matplotlib
- Plotting distance arrows in technical drawing in Matplotlib
- Draw a border around subplots in Matplotlib
- How to plot a rectangle inside a circle in Matplotlib?
- How to add a text into a Rectangle in Matplotlib?
- Drawing multiple legends on the same axes in Matplotlib
- How to change the attributes of a networkx / matplotlib graph drawing?