Problem: you have a set of plots, a single image with the color bar for these plots and you want to add the colorbar to each plot, not manually.
Solution: Python Image Library. Making no representations that this represents a particularly elegant or efficient way to do this, here is my solution:
from PIL import Image
import glob
imout = Image.new("RGB",(566,385),(255,255,255))
cim = Image.open("legend.png")
for infile in glob.glob("*plot*.png"):
im = Image.open(infile)
cbar = cim.crop((0,0,127,517))
cbar = cbar.resize((76,385))
plot = im.crop( (0,0,im.size[0],im.size[1]) )
sz = imout.size
pcoords = ( (sz[0]-76),(sz[1]-385),sz[0],sz[1] )
print pcoords
print cbar.size
imout.paste(cbar, pcoords)
imout.paste(plot, (0,0,490,385))
imout.save(infile,"PNG")
You’ll notice I’ve somewhat lazily hard-coded the dimensions of the colorbar and the plots. legend.png refers to the colorbar, and the glob is used to get a list of all the plots.
Not sure how to get wordpress’ code tag to respect my indentation, but you know what you need to do to make the code work.