png is clipped

Hi,

I am trying to generate some pngs without using the GUI interface using the
AGG backend. The problem is when I set figsize, the bottom part of the
x-axis label is clipped. I am using python 2.5 in windows XP. I just
installed the lastest version of matplotlib today version 0.98.3. Below is
the code that produces two images that both have this problem.

from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

fname1=r'C:\Documents and Settings\CCM\Desktop\test_plot1.png'
fname2=r'C:\Documents and Settings\CCM\Desktop\test_plot2.png'

fig = Figure(figsize=(4,3))
canvas = FigureCanvas(fig)
ax = fig.add_subplot(111)
ax.set_clip_box(None)
ax.plot([1,2,3])
ax.set_title('hi mom')
ax.grid(True)
ax.set_xlabel('time')
ax.set_ylabel('volts')
print fig.get_size_inches()
canvas.print_figure(fname1,dpi=200)
fig.savefig(fname2)

···

--
View this message in context: http://old.nabble.com/png-is-clipped-tp27327004p27327004.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Try setting

fig.subplots_adjust(bottom=0.2)

The default is 0.1

JDH

···

On Tue, Jan 26, 2010 at 12:00 PM, cwurld <cwurld@...9...> wrote:

Hi,

I am trying to generate some pngs without using the GUI interface using the
AGG backend. The problem is when I set figsize, the bottom part of the
x-axis label is clipped. I am using python 2.5 in windows XP. I just
installed the lastest version of matplotlib today version 0.98.3. Below is
the code that produces two images that both have this problem.

If you do not mind the output size slightly adjusted, try

savefig("somename.png", bbox_inches="tight")

Regards,

-JJ

···

On Tue, Jan 26, 2010 at 3:27 PM, John Hunter <jdh2358@...287...> wrote:

On Tue, Jan 26, 2010 at 12:00 PM, cwurld <cwurld@...9...> wrote:

Hi,

I am trying to generate some pngs without using the GUI interface using the
AGG backend. The problem is when I set figsize, the bottom part of the
x-axis label is clipped. I am using python 2.5 in windows XP. I just
installed the lastest version of matplotlib today version 0.98.3. Below is
the code that produces two images that both have this problem.

Try setting

fig.subplots_adjust(bottom=0.2)

The default is 0.1

JDH

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Jae-Joon Lee wrote:

savefig("somename.png", bbox_inches="tight")

I tried it and it did NOT solve the problem. The
"fig.subplots_adjust(bottom=0.2)" solution did solve the problem.

···

--
View this message in context: http://old.nabble.com/png-is-clipped-tp27327004p27333507.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Another way to solve this problem is to not use the figsize keyword when
creating the Figure. Instead only adjust the dpi. For example:

w,h=fig.get_size_inches()
target_width_pix=300
dpi=target_width_pix/w
canvas.print_figure(fname1,dpi=dpi)

···

--
View this message in context: http://old.nabble.com/png-is-clipped-tp27327004p27333529.html
Sent from the matplotlib - users mailing list archive at Nabble.com.