Re: [Matplotlib-users] Font size and savefig
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 md...@stsci.edu 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 jdh2...@gmail.com 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA -- 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] 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 md...@stsci.edu 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 jdh2...@gmail.com 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA -- 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Font size and savefig
On Tue, Apr 28, 2009 at 11:24 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote: On Tue, Apr 28, 2009 at 11:09 PM, John Hunter jdh2...@gmail.com 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. Hmm, I must have been confused. In older versions of mpl, as you increased the dpi the fonts looked larger in relation to the rest of the figure, and that is what I was remembering. I just ran a few tests and they do scale as expected, so sorry for the noise -- 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Font size and savefig
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 inline: wxagg.pnginline: macosx.png On 29 Apr 2009, at 00:24, Jae-Joon Lee wrote: On Tue, Apr 28, 2009 at 11:09 PM, John Hunter jdh2...@gmail.com 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Font size and savefig
Hi, I am using the savefig method to save plots - however, I am finding that the font size is systematically larger in the saved images than in the WxAgg window. It seems that text is ~30% larger in PNG and PDF files compared to the WxAgg display (relative to the axes box size). This can be a little frustrating, as in some cases it can lead to label overlap in the PNG file, when the displayed version looked fine. The following script produces a PNG and a PDF file in which the font size is ~30% larger than in the WxAgg display. --- from matplotlib.font_manager import FontProperties import matplotlib.pyplot as mpl fig = mpl.figure() ax = fig.add_subplot(111) font = FontProperties() font.set_size('small') for tick in ax.get_xticklabels(): tick.set_fontproperties(font) for tick in ax.get_yticklabels(): tick.set_fontproperties(font) ax.set_xlabel(Hello) ax.set_ylabel(World) fig.canvas.draw() fig.savefig('test.png') fig.savefig('test.pdf') -- Is there a way to ensure that the font sizes are as close as possible in the files to what is displayed? Thanks, Thomas -- 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Font size and savefig
On Tue, Apr 28, 2009 at 9:52 PM, Thomas Robitaille thomas.robitai...@gmail.com wrote: Hi, I am using the savefig method to save plots - however, I am finding that the font size is systematically larger in the saved images than in the WxAgg window. It seems that text is ~30% larger in PNG and PDF files compared to the WxAgg display (relative to the axes box size). This can be a little frustrating, as in some cases it can lead to label overlap in the PNG file, when the displayed version looked fine. The following script produces a PNG and a PDF file in which the font size is ~30% larger than in the WxAgg display. 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. JDH -- 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Font size and savefig
On Tue, Apr 28, 2009 at 11:09 PM, John Hunter jdh2...@gmail.com 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 https://lists.sourceforge.net/lists/listinfo/matplotlib-users