 # figure border and mapping window to data coordinates

I have been using matplotlib with TkInter (TkAgg backend)

> and it's really nice once I got the hang of it... I have
> two questions though, which I couldn't find in the manual.

> 1. The figure window has a pretty large border around it,
> that seems to expand as I enlarge the window. Is there a
> way to set this to, say, N pixels?

You cannot set it by pixel, but you can control it with the axes
command. The syntax is axes([left, bottom, width, height]) where all
values are fractions of the figure. Eg, left and width are fractions
of the figure width, and bottom, top are fractions of the figure
height. With a little arithmetic, you can figure out what fractions
to use for a given pixel value, since the figure width in pixels is
width in inches * dpi. See
http://matplotlib.sf.net/matplotlib.matlab.html#-axes.

> 2. I have some x, y window coordinates I got via Tk event
> bindings. How can I translate these into data coordinates?

You can plot in any coordinate system you want by setting the
appropriate transform. If you want to plot in pixels, just specify
your data in pixels and use the identity_transform, as in this example

from matplotlib.matlab import *
from matplotlib.transforms import identity_transform
# left, bottom, width, height as fractions of figure size
axes([0.05, 0.05, .9, 0.9])

# plot in pixel coords with the identity transform
plot([100,400], [200,300], transform=identity_transform())
axis('off') # turn off tick labeling
show()

See http://matplotlib.sf.net/matplotlib.transforms.html for more
information on transforms.

For some backends, you may want to subtract the y pixel coordinate
from the figure height. You can get the pixel width and height of the
current figure with

w, h = gcf().get_width_height()

See http://matplotlib.sf.net/matplotlib.figure.html for help with
figure methods.

Good luck - when I get the users guide finished, some of these details
will be more accessible.

JDH

···

Thanks,

> Wayne

> -------------------------------------------------------
> This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one
> of 170 Project Admins to receive an Apple iPod Mini FREE
> for your judgement on who ports your project to Linux PPC