Hi all!
I am preparing a journal article and the figures should have a fixed width
of 3 inches, with as thin white border around as possible. The figure does
an imshow with equal axes:
My problem is: I do not know in advance the height of my figure to specify
figsize. The height should vary so that the whole figure (with ticks,
legends and colorbanr) fits tightly into a 3 x ? inch box.
I have already tried bbox_inches='tight' for savefig and looked at HowTo
FAQ: automatically make room for tick labels for possible ideas but do no
have a clue yet.
Any suggestion is welcome.
Do you want you figure width to be exactly 3 inch? Otherwise, I wonder
why bbox_inches="tight" does not work.
My recommendation is
1) create a figure with high enough height.
2) adjust subplot parameters either manually or using the method
described in the FAQ.
3) call savefig with tight bbox option.
If you want your figure width to be exactly 3 inch, try something like below
fig = figure(1, figsize=(3,7))
ax = subplot(111)
ax.set_aspect(1)
def get_tightbbox(renderer, fig=fig):
from matplotlib.figure import Figure
from matplotlib.transforms import Bbox
bbox = Figure.get_tightbbox(fig, renderer)
w, h = fig.get_size_inches()
x1, y1, x2, y2 = bbox.extents
return Bbox.from_extents(0, y1, w, y2)
fig.get_tightbbox = get_tightbbox
savefig("a.png", bbox_inches="tight")
-JJ
···
On Tue, Feb 23, 2010 at 5:43 AM, Kornél Jahn <kjahn.public@...287...> wrote:
Thx very much!
Kornel
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options