On Mon, Nov 16, 2009 at 4:12 AM, Jason Heeris <jason.hee...@gmail.com> wrote:
> Hi,
>
> I'd like to know if it's possible to do something like this in matplotlib:
>
> I want to create a 2D plot with legend, output as PNG. I also want to
> embed a logo in it, in the top right corner of the plotting area. If
> the original logo image is a 40px by 40px PNG, I want it to appear at
> that size exactly as it is in the original logo.
>
> Even if I can't do this directly, I might be able to fudge it if
> matplotlib tells me the exact (pixel) dimensions of the plot area —
> then I could scale and offset the secondary axes, convert the logo PNG
> to RGB values and plot that (or use Python to invoke an imagemagick
> subprocess and pass it those numbers... anything, really).
>
> Is it possible to get this info from matplotlib, or is there a better
> way to do this?


See

  http://matplotlib.sourceforge.net/examples/api/watermark_image.html

for an example of embedding a watermark image in mpl.


To compute figure size, multiply the DPI setting by the figure
dimensions in inches:

dpi = 100 # dpi, whatever value you want
width, height = 6,4  # in inches, whatever values you want

fig = plt.figure(figsize=(width, height), dpi=dpi)
pixelw = dpi * width   # pixel width of figure
pixelh = dpi * height  # pixel height of figure

# now watermark you figure as in the example linked above, passing the
pixel coords of the lower left corner of the image to figimage

# this last piece is important: pass dpi to savefig too since mpl
supports different dpi for display and hardcopy

fig.savefig(myfile, dpi=dpi)

JDH

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to