On Thu, Aug 12, 2010 at 2:08 PM, Russell E. Owen <ro...@uw.edu> wrote:
> So...can I convince the automatic sizer to always show the full X (time)
> axis annotations and put all the variable sizing into the data area? Or
> do I have to manually set them somehow?
>

Another option you may try is to use axes_grid1 toolkit.
Attached is a simplified version of the script I have been using.
matplotlib v1.0 is required.

IHTH,

-JJ
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import SubplotDivider
import mpl_toolkits.axes_grid1.axes_size as axes_size

class SizeFromFunc(axes_size._Base):
    def __init__(self, func):
        self._func = func

    def get_size(self, renderer):
        rel_size = 0.

        bb = self._func(renderer)
        dpi = renderer.points_to_pixels(72.)
        abs_size = bb/dpi

        return rel_size, abs_size

class GetExtentHelper(object):
    def __init__(self, ax):
        self._ax = ax
    def __call__(self, renderer):
        # return width of ticklabels on the left side of axes
        return self._ax.yaxis.get_ticklabel_extents(renderer)[0].width

fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_yticks([0.5])
ax.set_yticklabels(["very long label"])

helper = GetExtentHelper(ax)

divider = SubplotDivider(fig, 1, 1, 1,
                         horizontal=[SizeFromFunc(helper),
                                     axes_size.Scaled(1.)],
                         vertical=[axes_size.Scaled(1.)],
                         aspect=False)
ax.set_axes_locator(divider.new_locator(nx=1, ny=0))

plt.show()

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to