How to remove white space

Dear All,
I have one .png image of 940X780 and i am plotting waveforms on it. When I save this plot as .png , matp[lotlib gives image in
800X600 that too with white space. I dont want to keep the white space and i want the same resolution as original image.How should I go ahead?
Thanks in advance!!!
Regards
Yogesh

Hi Yogesh,

Doesn't the following example fulfill your needs (already posted to "How to
save file in to image in desired resolution in matplotlib?")?

fig = plt.figure(figsize=(9.4, 7.8))
ax = plt.axes([0.0, 0.0, 1.0, 1.0]) # leaves no white space around the axes
ax.plot([1, 2, 4], lw=5)
ax.set_xticks([]) # removes ticks
ax.set_yticks([])

fig.savefig('test.png', dpi=100)

Kind regards,
Matthias

···

On Thursday 01 April 2010 09:41:06 yogesh karpate wrote:

Dear All,
               I have one .png image of 940X780 and i am plotting waveforms
on it. When I save this plot as .png , matp[lotlib gives image in
800X600 that too with white space. I dont want to keep the white space and
i want the same resolution as original image.How should I go ahead?
Thanks in advance!!!
Regards
Yogesh

Hi all,
I have several graph to create and the position on the x axis can vary quite a lot.
Most of the time I'm quite happy with the default behavior but when my x values are very high matplotlib automatically change the ticks and set a scale on the axis (see screenshot) <http://img6.imageshack.us/img6/6834/chab052195802198642shif.png>
I looking for a way to change the default behavior to get a scale in 10E** instead of some random scale.
Is there a simple way of doing that?

Thanks a lot for your help

Tim

···

--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Hi Tim,

the "random scale" you are observing is the originalscale, where "some useful"
offset has been substracted and is shown in the lower right.
You can circumvent this behaviour by using your own Formatter like a
ScalarFormatter withour offset:
  formatter = plt.ScalarFormatter(useOffset=False)
Furthermore you can switch off the scientific formatting (extracting a common
prefactor) using
  formatter.set_scientific(False)
Applying this formatter to the current axes:
  plt.gca().xaxis.set_major_formatter(formatter)

or a string-formatter like
  majorFormatter = plt.FormatStrFormatter('%.5e')
or
majorFormatter = plt.FormatStrFormatter('%g')

Kind regards,
Matthias

PS: By the way, you should start a new thread for a new topic (sending a new
mail to mpl-users) instead of responding to another message.

···

On Thursday 01 April 2010 12:27:59 timothee cezard wrote:

Hi all,
I have several graph to create and the position on the x axis can vary
quite a lot.
Most of the time I'm quite happy with the default behavior but when my x
values are very high matplotlib automatically change the ticks and set a
scale on the axis (see screenshot)
<http://img6.imageshack.us/img6/6834/chab052195802198642shif.png>
I looking for a way to change the default behavior to get a scale in
10E** instead of some random scale.
Is there a simple way of doing that?

Thanks a lot for your help

Tim