PDF/SVG Backends Don't Save FigureImages

Is this a bug in the PDF/SVG backends or am I doing something wrong? If the
former is there any workaround?

The simple testcase below demonstrates the problem whereby the watermark doesn't
show up in the pdf output but does in the png output.

import Image
from scipy import lena
from scipy.ndimage import map_coordinates
from cStringIO import StringIO

def add_watermark(fig, watermark):
    import matplotlib.image as image
    im = image.imread(watermark)
    dpi = fig.get_dpi()
    offset = dpi*fig.get_size_inches()[0] - im.shape[1]
    fig.figimage(im, offset, 0, alpha=0.3)
    return fig

···

#

im = Image.fromarray(map_coordinates(lena(), mgrid[0:512:100j, 0:512:100j]))
watermark = StringIO()
im.save(watermark, format='png')
watermark.seek(0)

fig = figure(figsize=(12, 8))
plot(randn(1000))
add_watermark(fig, watermark)
fig.savefig('test.png', dpi=fig.get_dpi())
fig.savefig('test.pdf', dpi=fig.get_dpi())

Thanks,
Dave

I'm not able to reproduce the problem: I get the watermark in both png and pdf output. This was with git master.

What version of matplotlib are you using? Can you send (off-list) the png and pdf files so I can have a look at your output?

Mike

···

On 09/21/2011 10:28 AM, Dave Hirschfeld wrote:

Is this a bug in the PDF/SVG backends or am I doing something wrong? If the
former is there any workaround?

The simple testcase below demonstrates the problem whereby the watermark doesn't
show up in the pdf output but does in the png output.

import Image
from scipy import lena
from scipy.ndimage import map_coordinates
from cStringIO import StringIO

def add_watermark(fig, watermark):
     import matplotlib.image as image
     im = image.imread(watermark)
     dpi = fig.get_dpi()
     offset = dpi*fig.get_size_inches()[0] - im.shape[1]
     fig.figimage(im, offset, 0, alpha=0.3)
     return fig
#

im = Image.fromarray(map_coordinates(lena(), mgrid[0:512:100j, 0:512:100j]))
watermark = StringIO()
im.save(watermark, format='png')
watermark.seek(0)

fig = figure(figsize=(12, 8))
plot(randn(1000))
add_watermark(fig, watermark)
fig.savefig('test.png', dpi=fig.get_dpi())
fig.savefig('test.pdf', dpi=fig.get_dpi())

Thanks,
Dave

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options