- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 rotate the rectangle patch in a plot using Matplotlib?
To rotate the rectangle patch in a plot, we can use angle in the Rectangle() class to rotate it.
Steps
Create a figure and a set of subplots using subplots() method.
Add a rectangle on the patch, angle=45°.
Add a patch on the axis.
To display the figure, use show() method.
Example
from matplotlib import pyplot as plt, patches plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True figure, ax = plt.subplots(1) rectangle = patches.Rectangle((0.4, 0.25), 0.5, 0.5, edgecolor='orange', facecolor="green", linewidth=2, angle=45) ax.add_patch(rectangle) plt.show()
Output
- Related Articles
- How to plot a 3D patch collection in matplotlib?
- How to plot a rectangle on a datetime axis using Matplotlib?
- How to plot a rectangle inside a circle in Matplotlib?
- How to label a patch in matplotlib?
- Rotate theta=0 on a Matplotlib polar plot
- Plot a circle inside a rectangle in Matplotlib
- Plot a rectangle with an edgecolor in Matplotlib
- How to control the border of a bar patch in matplotlib?
- How to plot a wav file using Matplotlib?
- How to get a Gantt plot using matplotlib?
- How to rotate a simple matplotlib Axes?
- How to plot a kernel density plot of dates in Pandas using Matplotlib?
- How to plot MFCC in Python using Matplotlib?
- How to plot vectors in Python using Matplotlib?
- How can Bokeh be used to generate patch plot in Python?

Advertisements