Skip to content

Instantly share code, notes, and snippets.

@letmaik
letmaik / figimage.py
Created September 12, 2014 14:42
Draw things naturally onto an image using matplotlib
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
def loadFigImage(path):
im = mpimg.imread(path)
h,w = im.shape[0], im.shape[1]
dpi = 80
fig = plt.figure(figsize=(w/dpi, h/dpi), dpi=dpi)
ax = plt.Axes(fig, [0, 0, 1, 1])
ax.set_xlim(0, w)