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
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,im.size) )
sz = imout.size
pcoords = ( (sz-76),(sz-385),sz,sz )
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.