Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pyplot rectangle over image

import matplotlib.pyplot as plt
import matplotlib.patches as patches
from PIL import Image

im = Image.open('stinkbug.png')

# Create figure and axes
fig, ax = plt.subplots()

# Display the image
ax.imshow(im)

# Create a Rectangle patch
rect = patches.Rectangle((50, 100), 40, 30, linewidth=1, edgecolor='r', facecolor='none') # Coordinates: (left, top), width, height

# Add the patch to the Axes
ax.add_patch(rect)

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: isntall packages to databricks 
Python :: python print odd numberrs 
Python :: date strftime python 
Python :: python add field to dictionary 
Python :: non-integer arg 1 for randrange() 
Python :: dataframein python 
Python :: cv2 imshow in colab 
Python :: pandas group by day 
Python :: how to make a list using lambda function in python 
Python :: df .sort_values 
Python :: how to write the character from its ascii value in python 
Python :: df dropna 
Python :: how to add for loop in python 
Python :: pandas where 
Python :: python all lowercase letters 
Python :: pil img to pdf 
Python :: python location 
Python :: python find smallest value in 2d list 
Python :: python multiaxis slicing 
Python :: root mean square python 
Python :: install python altair 
Python :: python gui drag and drop 
Python :: python check tuple length 
Python :: python generator comprehension 
Python :: python replace double quotes with single quotes in string json loads 
Python :: find the highest 3 values in a dictionary. 
Python :: hot to check tkinter verionin python 
Python :: pandas dataframe filter 
Python :: iterate over dictionary django 
Python :: pyserial read 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =