set axes size; figure adjusts

What is the simple way to do the following?

I want to set the size of the actual axes box
(i.e, , the lines drawn for the axes, not
including the ticks and labels.)

I do not care about the figure size, but I
would like the resulting drawing to have
a tight bounding box. (After I add the
ticks and axes labels.)

The best I've come up with so far is to
create a figure with a set size, and then
add axes with a specified rectangle.
But this does not give a neat path to
what I want.

Thanks,
Alan Isaac

The best I've come up with so far is to
create a figure with a set size, and then
add axes with a specified rectangle.
But this does not give a neat path to
what I want.

Alan,
I think the way you're doing is the easiest way.
Anyhow, can you provide an example of a "neat path"? In my view, fixed
axes size means fixed figure size (in most cases), and I'm not quite
sure how this can be improved.

This might not be very helpful but I recently added an
"axes_divider.py" in the example directory which includes helper
classes to calculate the axes size in drawing time. And It is possible
to have the axes size fixed in inches (check demo_fixed_size_axes
function in the file) regardless of the figure size, but the method is
basically same as the one you're using.

Regards,

-JJ

The best I've come up with so far is to create a figure with a set size, and then add axes with a specified rectangle.

I think the way you're doing is the easiest way. Anyhow, can you provide an example of a "neat path"? In my view, fixed axes size means fixed figure size (in most cases), and I'm not quite sure how this can be improved.

For my current use it would be enough if savefig had an option
         bbox = 'tight'
so that only the area actually drawn in was written
to file.

The problem is that if you set the fig size and then
set the axis size proportionately, you must fiddle
with things to get a tight fit to what's actually drawn
(including the tick labels and axis labels).

Cheers,
Alan Isaac

···

On 1/12/2009 3:56 AM Jae-Joon Lee apparently wrote:

For my current use it would be enough if savefig had an option
        bbox = 'tight'
so that only the area actually drawn in was written
to file.

The problem is that if you set the fig size and then
set the axis size proportionately, you must fiddle
with things to get a tight fit to what's actually drawn
(including the tick labels and axis labels).

It seems that you want not only to fix the size of the axes but also
to adjust its position (and the figure size accordingly). Adjusting
the position of the axes is not straight forward but take a look at
the following tutorial (if you haven't).

http://matplotlib.sourceforge.net/faq/howto_faq.html#automatically-make-room-for-tick-labels

Anyhow, there might not be a neat way to do this within the current
mpl framework.

On the other hand, I think it might be possible to implement
"bbox=tight" option by tweaking the figure class (or renderer) and
I'll think about it later if possible. Meanwhile, I'm afraid that
there is not much I can help.

Regards,

-JJ