Skip to content

Instantly share code, notes, and snippets.

@victorhcm
Created November 19, 2015 00:02
Show Gist options
  • Save victorhcm/510156a6e5cd5339d656 to your computer and use it in GitHub Desktop.
Save victorhcm/510156a6e5cd5339d656 to your computer and use it in GitHub Desktop.
overlay image with annotations.
# coding: utf-8
import matplotlib.pyplot as plt
import Image
img = Image.open('truman-stairs.jpg')
fig, ax = plt.subplots(figsize=(12,12))
ax.imshow(img, aspect='equal')
ax.add_patch(
plt.Rectangle((30,30),
64, 128, fill = False, edgecolor='red', linewidth=3.5)
)
ax.text(30, 30-2,
'helloooooooo',
bbox=dict(facecolor='blue', alpha=0.5),
fontsize=20, color='white')
plt.axis('off')
plt.tight_layout()
plt.show()
fig.savefig('/tmp/edited.png')
plt.close(fig)
@victorhcm
Copy link
Author

truman-stairs
edited

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment