etc for producing images at various scales) Reply-To: In-Reply-To: <20110121232036.GA26739@ykcyc> X-PGP-Key: http://pirsquared.org/PaulIvanov0F3E28F7.asc
Paul Ivanov, on 2011-01-21 15:20, wrote: > I'm almost certain that one *can* write a function to do this > pro grammatically (without having to hand tweak anything), by > looking at say, the .get_window_extent() but I haven't found the > time to scratch that itch, yet. > > If someone wants to beat me to it, here's the sort of thing that > you can do: > > def show_labels_by_shrinking(ax): > " adjust subplot parameters to fit the yaxis label" > f = ax.figure > textwidth = ax.yaxis.get_label().get_window_extent().width > labelwidth = max([lab.get_window_extent().width for lab in > ax.get_yticklabels()]) > > plt.subplots_adjust(left=(textwidth+labelwidth+3*ax.yaxis.labelpad)/f.get_window_extent().width) > # the 3 *ax.yaxis.labelpad is just a fudge factor for now, need > # to look into the sourcecode to figure out what the > # appropriate placement is normally, to know how to adjust > # properly > > > ax.set_ylabel('foo') > show_labels_by_shrinking(ax) > ax.set_ylabel("a\nmulti\nline\nexample") > show_labels_by_shrinking(ax) I should add that along with doing a similar thing for the xaxis, this would need to be extended for the multiple subplot case, to also adjust the wspace and hspace parameters accordingly. this is important functionality currently missing from matplotlib out-of-the-box at the moment, so I'll try my crack at it this out this weekend. CCing the devel list in case someone has more opinions. best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
signature.asc
Description: Digital signature
------------------------------------------------------------------------------ Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users