Font size and savefig

Thomas,
As John suggested before, please check if the size differences go away
if you use the same dpi, actually dpi=72.

After some quick look, it seems that the osx backend does not scale
the font size correctly respecting the dpi.
At line 124 of bacend_macosx.py,

            size = prop.get_size_in_points()
            weight = prop.get_weight()
            style = prop.get_style()
            gc.draw_text(x, y, unicode(s), family, size, weight, style, angle)

My quick guess is that replacing

size => size*self.dpi/72.

in the last call may solve the problem. Since I don't use the osx
backend, I wonder if others can test this.

-JJ

···

On Thu, Apr 30, 2009 at 9:32 AM, Michael Droettboom <mdroe@...86...> wrote:

I forwarded this message to Michiel de Hoon, the author of the Mac OS-X
backend, in case he has any thoughts.

Mike

Thomas Robitaille wrote:

Hi Jae-Jong and John,

Thanks for your replies! While experimenting with this to send
screenshots, I realized that my default backend was set to MacOSX, not
WXAgg. The WXAgg output to the screen actually agrees with the PNG output in
terms of font sizes. But the font sizes differ between the MacOSX and WXAgg
backends. Attached are screenshots using the MacOSX and WXAgg backends. You
can see the font size is different. Is this a bug?

Thanks,

Thomas

------------------------------------------------------------------------

------------------------------------------------------------------------

On 29 Apr 2009, at 00:24, Jae-Joon Lee wrote:

On Tue, Apr 28, 2009 at 11:09 PM, John Hunter <jdh2358@...287...> wrote:

If you want the relative fontsizes in the figure window and saved figure
to
agree, pass the same "dpi" to the figure command and savefig command.

John,
I thought the font size (which is specified in points) is independent
of dpi, i.e., font size in "pixel" actually scales with the dpi. I
think it should be filed as a bug if the relative font size depends on
the dpi.

Anyhow, I just did a quick test and the (relative) font size does not
seem to vary with dpi.

Thomas,
What version of mpl are you using?
With the mpl from the svn trunk, I don't see any significant change as
you described.
The WxAgg figure and the png output are actually drawn by an identical
backend, so there should be no significant difference. There can be
some subtle difference due to different dpi, but I don't see a
difference as large as 30%. Can you post a some sample images? i.e., a
screenshot of WxAgg figure and the png output.

I can see that the text in pdf output occupies a bit larger area than
png (when usetex=False), but, to me, this seems to be due to different
amount of kernings (it seems that no kerning is applied for pdf text)
instead of different font size.

So, can you first check if the difference goes away when you use same
dpi as John suggested? And if that is the case, can you try the latest
svn and check if the relative font size still depends on the dpi?

Regards,

-JJ

------------------------------------------------------------------------

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of expert-led,
hands-on workshops and two days of sessions from industry leaders in
dedicated Performance & Operations tracks. Use code vel09scf and Save an
extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
------------------------------------------------------------------------

_______________________________________________
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

Michiel de Hoon provided a patch for this which I just applied to the trunk.

As I don't have a Mac, I can't test it -- any feedback is welcome.

Mike

Jae-Joon Lee wrote:

···

Thomas,
As John suggested before, please check if the size differences go away
if you use the same dpi, actually dpi=72.

After some quick look, it seems that the osx backend does not scale
the font size correctly respecting the dpi.
At line 124 of bacend_macosx.py,

            size = prop.get_size_in_points()
            weight = prop.get_weight()
            style = prop.get_style()
            gc.draw_text(x, y, unicode(s), family, size, weight, style, angle)

My quick guess is that replacing

size => size*self.dpi/72.

in the last call may solve the problem. Since I don't use the osx
backend, I wonder if others can test this.

-JJ

On Thu, Apr 30, 2009 at 9:32 AM, Michael Droettboom <mdroe@...86...> wrote:
  

I forwarded this message to Michiel de Hoon, the author of the Mac OS-X
backend, in case he has any thoughts.

Mike

Thomas Robitaille wrote:
    

Hi Jae-Jong and John,

Thanks for your replies! While experimenting with this to send
screenshots, I realized that my default backend was set to MacOSX, not
WXAgg. The WXAgg output to the screen actually agrees with the PNG output in
terms of font sizes. But the font sizes differ between the MacOSX and WXAgg
backends. Attached are screenshots using the MacOSX and WXAgg backends. You
can see the font size is different. Is this a bug?

Thanks,

Thomas

------------------------------------------------------------------------

------------------------------------------------------------------------

On 29 Apr 2009, at 00:24, Jae-Joon Lee wrote:

On Tue, Apr 28, 2009 at 11:09 PM, John Hunter <jdh2358@...287...> wrote:
        

If you want the relative fontsizes in the figure window and saved figure
to
agree, pass the same "dpi" to the figure command and savefig command.
          

John,
I thought the font size (which is specified in points) is independent
of dpi, i.e., font size in "pixel" actually scales with the dpi. I
think it should be filed as a bug if the relative font size depends on
the dpi.

Anyhow, I just did a quick test and the (relative) font size does not
seem to vary with dpi.

Thomas,
What version of mpl are you using?
With the mpl from the svn trunk, I don't see any significant change as
you described.
The WxAgg figure and the png output are actually drawn by an identical
backend, so there should be no significant difference. There can be
some subtle difference due to different dpi, but I don't see a
difference as large as 30%. Can you post a some sample images? i.e., a
screenshot of WxAgg figure and the png output.

I can see that the text in pdf output occupies a bit larger area than
png (when usetex=False), but, to me, this seems to be due to different
amount of kernings (it seems that no kerning is applied for pdf text)
instead of different font size.

So, can you first check if the difference goes away when you use same
dpi as John suggested? And if that is the case, can you try the latest
svn and check if the relative font size still depends on the dpi?

Regards,

-JJ
        

------------------------------------------------------------------------

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of expert-led,
hands-on workshops and two days of sessions from industry leaders in
dedicated Performance & Operations tracks. Use code vel09scf and Save an
extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
------------------------------------------------------------------------

_______________________________________________
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

The patch seems to work - the MacOSX backend now displays the same font size as the other backends.

Thanks!

Thomas

···

On 1 May 2009, at 14:06, Michael Droettboom wrote:

Michiel de Hoon provided a patch for this which I just applied to the trunk.

As I don't have a Mac, I can't test it -- any feedback is welcome.

Mike

Jae-Joon Lee wrote:

Thomas,
As John suggested before, please check if the size differences go away
if you use the same dpi, actually dpi=72.

After some quick look, it seems that the osx backend does not scale
the font size correctly respecting the dpi.
At line 124 of bacend_macosx.py,

           size = prop.get_size_in_points()
           weight = prop.get_weight()
           style = prop.get_style()
           gc.draw_text(x, y, unicode(s), family, size, weight, style, angle)

My quick guess is that replacing

size => size*self.dpi/72.

in the last call may solve the problem. Since I don't use the osx
backend, I wonder if others can test this.

-JJ

On Thu, Apr 30, 2009 at 9:32 AM, Michael Droettboom >> <mdroe@...86...> wrote:

I forwarded this message to Michiel de Hoon, the author of the Mac OS-X
backend, in case he has any thoughts.

Mike

Thomas Robitaille wrote:

Hi Jae-Jong and John,

Thanks for your replies! While experimenting with this to send
screenshots, I realized that my default backend was set to MacOSX, not
WXAgg. The WXAgg output to the screen actually agrees with the PNG output in
terms of font sizes. But the font sizes differ between the MacOSX and WXAgg
backends. Attached are screenshots using the MacOSX and WXAgg backends. You
can see the font size is different. Is this a bug?

Thanks,

Thomas

------------------------------------------------------------------------

------------------------------------------------------------------------

On 29 Apr 2009, at 00:24, Jae-Joon Lee wrote:

On Tue, Apr 28, 2009 at 11:09 PM, John Hunter >>>>> <jdh2358@...287...> wrote:

If you want the relative fontsizes in the figure window and saved figure
to
agree, pass the same "dpi" to the figure command and savefig command.

John,
I thought the font size (which is specified in points) is independent
of dpi, i.e., font size in "pixel" actually scales with the dpi. I
think it should be filed as a bug if the relative font size depends on
the dpi.

Anyhow, I just did a quick test and the (relative) font size does not
seem to vary with dpi.

Thomas,
What version of mpl are you using?
With the mpl from the svn trunk, I don't see any significant change as
you described.
The WxAgg figure and the png output are actually drawn by an identical
backend, so there should be no significant difference. There can be
some subtle difference due to different dpi, but I don't see a
difference as large as 30%. Can you post a some sample images? i.e., a
screenshot of WxAgg figure and the png output.

I can see that the text in pdf output occupies a bit larger area than
png (when usetex=False), but, to me, this seems to be due to different
amount of kernings (it seems that no kerning is applied for pdf text)
instead of different font size.

So, can you first check if the difference goes away when you use same
dpi as John suggested? And if that is the case, can you try the latest
svn and check if the relative font size still depends on the dpi?

Regards,

-JJ

------------------------------------------------------------------------

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of expert-led,
hands-on workshops and two days of sessions from industry leaders in
dedicated Performance & Operations tracks. Use code vel09scf and Save an
extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
------------------------------------------------------------------------

_______________________________________________
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