savefig bug

Hi,

I've come across a bug with the savefig method when using the dpi= argument and saving an EPS file. If you try the following code, you will see that the frame is incomplete. Is there a way to solve this from a user point of view?

···

---

import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *

import numpy as np

nx,ny = 10,10

image = np.random.random((nx,ny))

fig = figure(figsize=(4,4))
ax = fig.add_subplot(111)
ax.imshow(image,interpolation='nearest')
fig.savefig('plot.eps',dpi=30)

---

I've submitted a bug report:

https://sourceforge.net/tracker/?func=detail&aid=2777476&group_id=80706&atid=560720

Thanks,

Thomas

I can reproduce this bug with the current svn.

It works correctly If you set dpi=72, but it seems that it would not
be an option in your case.

It seems to me that this is related with the change in r6847 that Michael made.

At line 431 of the backend_ps.py,

             clip = (0.0, 0.0, self.width * self.imagedpi,
                         self.height * self.imagedpi)

I think we should use the dpi of the figure, instead of the imagedpi
of the renderer.
Replacing self.imagedpi with 72 (which is the dpi of the figure when
ps backend is used) seems to solve the problem.

Thomas, I don't see any easy workaround for this bug other than
patching the code. Others may have better insight though.

Regards,

-JJ

···

On Tue, Apr 21, 2009 at 9:59 AM, Thomas Robitaille <thomas.robitaille@...287...> wrote:

Hi,

I've come across a bug with the savefig method when using the dpi=
argument and saving an EPS file. If you try the following code, you
will see that the frame is incomplete. Is there a way to solve this
from a user point of view?

---

import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *

import numpy as np

nx,ny = 10,10

image = np.random.random((nx,ny))

fig = figure(figsize=(4,4))
ax = fig.add_subplot(111)
ax.imshow(image,interpolation='nearest')
fig.savefig('plot.eps',dpi=30)

---

I've submitted a bug report:

https://sourceforge.net/tracker/?func=detail&aid=2777476&group_id=80706&atid=560720

Thanks,

Thomas

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thanks for your quick reply!

I'll be patient and wait for the fix to be made in the SVN repository, rather than trying to patch it myself. Do I need to add any information to the bug report?

Best,

Thomas

···

On Apr 21, 2009, at 1:06 PM, Jae-Joon Lee wrote:

I can reproduce this bug with the current svn.

It works correctly If you set dpi=72, but it seems that it would not
be an option in your case.

It seems to me that this is related with the change in r6847 that Michael made.

matplotlib download | SourceForge.net

At line 431 of the backend_ps.py,

            clip = (0.0, 0.0, self.width * self.imagedpi,
                        self.height * self.imagedpi)

I think we should use the dpi of the figure, instead of the imagedpi
of the renderer.
Replacing self.imagedpi with 72 (which is the dpi of the figure when
ps backend is used) seems to solve the problem.

Thomas, I don't see any easy workaround for this bug other than
patching the code. Others may have better insight though.

Regards,

-JJ

On Tue, Apr 21, 2009 at 9:59 AM, Thomas Robitaille > <thomas.robitaille@...287...> wrote:

Hi,

I've come across a bug with the savefig method when using the dpi=
argument and saving an EPS file. If you try the following code, you
will see that the frame is incomplete. Is there a way to solve this
from a user point of view?

---

import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *

import numpy as np

nx,ny = 10,10

image = np.random.random((nx,ny))

fig = figure(figsize=(4,4))
ax = fig.add_subplot(111)
ax.imshow(image,interpolation='nearest')
fig.savefig('plot.eps',dpi=30)

---

I've submitted a bug report:

https://sourceforge.net/tracker/?func=detail&aid=2777476&group_id=80706&atid=560720

Thanks,

Thomas

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

I think Jae-Joon's assesment is correct, since the logical dpi in PS is hardcoded to 72.0. I have made this change in the SVN repository.

Mike

Thomas Robitaille wrote:

···

Thanks for your quick reply!

I'll be patient and wait for the fix to be made in the SVN repository, rather than trying to patch it myself. Do I need to add any information to the bug report?

Best,

Thomas

On Apr 21, 2009, at 1:06 PM, Jae-Joon Lee wrote:

I can reproduce this bug with the current svn.

It works correctly If you set dpi=72, but it seems that it would not
be an option in your case.

It seems to me that this is related with the change in r6847 that Michael made.

matplotlib download | SourceForge.net

At line 431 of the backend_ps.py,

            clip = (0.0, 0.0, self.width * self.imagedpi,
                        self.height * self.imagedpi)

I think we should use the dpi of the figure, instead of the imagedpi
of the renderer.
Replacing self.imagedpi with 72 (which is the dpi of the figure when
ps backend is used) seems to solve the problem.

Thomas, I don't see any easy workaround for this bug other than
patching the code. Others may have better insight though.

Regards,

-JJ

On Tue, Apr 21, 2009 at 9:59 AM, Thomas Robitaille >> <thomas.robitaille@...287...> wrote:
    

Hi,

I've come across a bug with the savefig method when using the dpi=
argument and saving an EPS file. If you try the following code, you
will see that the frame is incomplete. Is there a way to solve this
from a user point of view?

---

import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *

import numpy as np

nx,ny = 10,10

image = np.random.random((nx,ny))

fig = figure(figsize=(4,4))
ax = fig.add_subplot(111)
ax.imshow(image,interpolation='nearest')
fig.savefig('plot.eps',dpi=30)

---

I've submitted a bug report:

https://sourceforge.net/tracker/?func=detail&aid=2777476&group_id=80706&atid=560720

Thanks,

Thomas

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options
  
--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA

It works great now - thanks for fixing this!

Thomas

···

On Apr 23, 2009, at 10:29 AM, Michael Droettboom wrote:

I think Jae-Joon's assesment is correct, since the logical dpi in PS is hardcoded to 72.0. I have made this change in the SVN repository.

Mike

Thomas Robitaille wrote:

Thanks for your quick reply!

I'll be patient and wait for the fix to be made in the SVN repository, rather than trying to patch it myself. Do I need to add any information to the bug report?

Best,

Thomas

On Apr 21, 2009, at 1:06 PM, Jae-Joon Lee wrote:

I can reproduce this bug with the current svn.

It works correctly If you set dpi=72, but it seems that it would not
be an option in your case.

It seems to me that this is related with the change in r6847 that Michael made.

matplotlib download | SourceForge.net

At line 431 of the backend_ps.py,

           clip = (0.0, 0.0, self.width * self.imagedpi,
                       self.height * self.imagedpi)

I think we should use the dpi of the figure, instead of the imagedpi
of the renderer.
Replacing self.imagedpi with 72 (which is the dpi of the figure when
ps backend is used) seems to solve the problem.

Thomas, I don't see any easy workaround for this bug other than
patching the code. Others may have better insight though.

Regards,

-JJ

On Tue, Apr 21, 2009 at 9:59 AM, Thomas Robitaille >>> <thomas.robitaille@...287...> wrote:

Hi,

I've come across a bug with the savefig method when using the dpi=
argument and saving an EPS file. If you try the following code, you
will see that the frame is incomplete. Is there a way to solve this
from a user point of view?

---

import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *

import numpy as np

nx,ny = 10,10

image = np.random.random((nx,ny))

fig = figure(figsize=(4,4))
ax = fig.add_subplot(111)
ax.imshow(image,interpolation='nearest')
fig.savefig('plot.eps',dpi=30)

---

I've submitted a bug report:

https://sourceforge.net/tracker/?func=detail&aid=2777476&group_id=80706&atid=560720

Thanks,

Thomas

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA