From: Daniel M. <dan...@go...> - 2011-02-22 09:23:41
|
Hi, there has been a similar question recently but I couldn't figure out if or how this is solved: I'd like to reduce the figure size so that I can add it to a LaTeX document without scaling (PDF output with LaTeX font rendering). For that, I need to adapt the font sizes, too. Unfortunately, the canvas is not properly scaled so that the axis labels and the possibly the tick marks are cut off. Is this a bug, feature, design flaw? How can I properly work around it, i.e. reduce the graph automatically for a given figsize/font size combination so that everything fits on the figure? An example follows to demonstrate, thanks in advance, Daniel import numpy,pylab,matplotlib.ticker as mtick x = numpy.linspace(0,10,1000) y = numpy.exp(x) pylab.rcdefaults() fig = pylab.figure() ax = fig.add_subplot(111) ax.set_yscale('log') ax.yaxis.set_major_formatter(mtick.FormatStrFormatter('%d')) ax.set_xlabel('asdf') ax.set_ylabel('qwer') ax.plot(x,y) fig.savefig('example_mpl-ticker_1') pylab.rcParams['figure.figsize'] = 5,3 pylab.rcParams['font.size'] = 12 fig = pylab.figure() ax = fig.add_subplot(111) ax.set_yscale('log') ax.yaxis.set_major_formatter(mtick.FormatStrFormatter('%d')) ax.set_xlabel('asdf') ax.set_ylabel('qwer') ax.plot(x,y) fig.savefig('example_mpl-ticker_2') |