Re: [Matplotlib-users] Setting font family in ticks not possible. Bug?
More complete: I tried all permunations of backends. Now I stick to PS, because I use matplotlib from commandline with scripts. The environment is debian/etch with a current version of matplotlib (self compiled). Try this script from pylab import * t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) plot(t, s) grid(True) # matlab handle graphics style xticklines = getp(gca(), 'xticklines') yticklines = getp(gca(), 'yticklines') xgridlines = getp(gca(), 'xgridlines') ygridlines = getp(gca(), 'ygridlines') xticklabels = getp(gca(), 'xticklabels') yticklabels = getp(gca(), 'yticklabels') setp(xticklines, 'linewidth', 3) setp(yticklines, 'linewidth', 3) setp(xgridlines, 'linestyle', '-') setp(ygridlines, 'linestyle', '-') setp(yticklabels, 'color', 'r', fontsize='medium') setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif') savefig('axprops_demo') ** On my system the line setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif') doesn't change the font family. Best regards: Gerolf -- Dipl. Phys. Gerolf Ziegenhain ([EMAIL PROTECTED]) Private: Klopstockstrasse 21 - 65187 Wiesbaden - Germany Office: Room 46-332 - Erwin-Schrödinger-Str.46 - TU Kaiserslautern - Germany Web: gerolf.ziegenhain.com Tel.: +49-611-18840590 Fax: +49-611-18840599 - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting font family in ticks not possible. Bug?
Hi, Thanks for all the replies! Of course it is not directly a bug. But awkward. This is how I was finally able to change alle fonts and the whole layout of the plot: fig_width_pt = 246.0 # Get this from LaTeX using \showthe\columnwidth inches_per_pt = 1.0/72.27 # Convert pt to inch golden_mean = (sqrt(5)-1.0)/2.0 # Aesthetic ratio fig_width = fig_width_pt*inches_per_pt # width in inches fig_height = fig_width*golden_mean # height in inches fig_size = [fig_width,fig_height] params = {'backend': 'ps','axes.labelsize': 10,'text.fontsize': 10,'legend.fontsize': 10,'text.usetex': True,'text.latex.preamble':[\usepackage{bm},\usepackage{textcomp}], 'figure.figsize': fig_size, 'font.family' : 'sans-serif', 'font.style': 'normal', 'font.weight':'normal',} rcParams.update(params) ... ffont = {'family':'sans-serif','fontsize':10,'weight':'bold'} ax1=gca() ax1.set_xticklabels(ax1.get_xticks(),ffont) ax1.set_yticklabels(ax1.get_yticks(),ffont) subplots_adjust(top=1-.13) xticks(**ffont) yticks(**ffont) Best regards: Gerolf On Thu 27.Mar.08 14:54, Darren Dale wrote: On Thursday 27 March 2008 01:27:28 pm Gerolf Ziegenhain wrote: More complete: I tried all permunations of backends. Now I stick to PS, because I use matplotlib from commandline with scripts. The environment is debian/etch with a current version of matplotlib (self compiled). Try this script from pylab import * t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) plot(t, s) grid(True) # matlab handle graphics style xticklines = getp(gca(), 'xticklines') yticklines = getp(gca(), 'yticklines') xgridlines = getp(gca(), 'xgridlines') ygridlines = getp(gca(), 'ygridlines') xticklabels = getp(gca(), 'xticklabels') yticklabels = getp(gca(), 'yticklabels') setp(xticklines, 'linewidth', 3) setp(yticklines, 'linewidth', 3) setp(xgridlines, 'linestyle', '-') setp(ygridlines, 'linestyle', '-') setp(yticklabels, 'color', 'r', fontsize='medium') setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif') savefig('axprops_demo') ** On my system the line setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif') doesn't change the font family. Do you use usetex? If you do, the mathtext is rendered using latex, and latex renders mathtext in serif fonts. Darren - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Dipl. Phys. Gerolf Ziegenhain Web: http://gerolf.ziegenhain.com Email: [EMAIL PROTECTED] Fax: +49 611 18840599 Phone: +49 611 18840590 Office: Erwin-Schrödinger-Str. 46 / Room 46.332 / 67663 Kaiserslautern / Germany Private: Klopstockstr. 21 / 65187 Wiesbaden / Germany - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Setting font family in ticks not possible. Bug?
Dear Mailinglist, Today I tried to change the fontset to sans-serif for a whole plot. Everything except the ticks could be adjusted. This is what I tried first: *** ffont = {'size':'20','family':'sans-serif'} xticks(**ffont) *** No change in the font family. But I can change the size without problems. I removed the ~/.matplotlib/FONTCACHE stuff as described here(2). Following (1) I tried again to change the font using *** import pylab pylab.figure() ax = pylab.axes() ax.plot(pylab.arange(10)) xlabels = ax.get_xticklabels() xlabel0 = xlabels[0] # one of the xtick labels xlabel0.get_fontsize() xlabel0.set_fontsize(20) pylab.show() *** Again nothing changed. Using ipython I got this: *** In [192]: xlabels[0].get_fontname() Out[192]: 'Bitstream Vera Serif, New Century Schoolbook, serif' In [195]: xlabels[0].set_family(sans-serif) In [196]: xlabels[0].get_fontname() Out[196]: 'Bitstream Vera Sans, Lucida Grande, Verdana, sans-serif' In [197]: show() *** Summary: It appears to me like I can change the default fontfamily, but somehow there is no change in the output. What could be the problem? Best regards: Gerolf (1) http://www.nabble.com/axes-numbers-font-size-td14459877.html (2) http://matplotlib.sourceforge.net/faq.html#FONTMISSING -- Dipl. Phys. Gerolf Ziegenhain Web: http://gerolf.ziegenhain.com Email: [EMAIL PROTECTED] Fax: +49 611 18840599 Phone: +49 611 18840590 Office: Erwin-Schrödinger-Str. 46 / Room 46.332 / 67663 Kaiserslautern / Germany Private: Klopstockstr. 21 / 65187 Wiesbaden / Germany - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting font family in ticks not possible. Bug?
Gerolf Ziegenhain wrote: Dear Mailinglist, Today I tried to change the fontset to sans-serif for a whole plot. Everything except the ticks could be adjusted. This is what I tried first: *** ffont = {'size':'20','family':'sans-serif'} xticks(**ffont) *** Hmmm... This works for me. What backend are you using? Perhaps it isn't updating? Also, do these two lines + show() alone not work, or is it only in the context of something else? Also, what platform are you on? Mike -- Michael Droettboom Science Software Branch Operations and Engineering Division Space Telescope Science Institute Operated by AURA for NASA - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting font family in ticks not possible. Bug?
More complete: I tried all permunations of backends. Now I stick to PS, because I use matplotlib from commandline with scripts. The environment is debian/etch with a current version of matplotlib (self compiled). Try this script from pylab import * t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) plot(t, s) grid(True) # matlab handle graphics style xticklines = getp(gca(), 'xticklines') yticklines = getp(gca(), 'yticklines') xgridlines = getp(gca(), 'xgridlines') ygridlines = getp(gca(), 'ygridlines') xticklabels = getp(gca(), 'xticklabels') yticklabels = getp(gca(), 'yticklabels') setp(xticklines, 'linewidth', 3) setp(yticklines, 'linewidth', 3) setp(xgridlines, 'linestyle', '-') setp(ygridlines, 'linestyle', '-') setp(yticklabels, 'color', 'r', fontsize='medium') setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif') savefig('axprops_demo') ** On my system the line setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif') doesn't change the font family. Best regards: Gerolf -- Dipl. Phys. Gerolf Ziegenhain ([EMAIL PROTECTED]) Private: Klopstockstrasse 21 - 65187 Wiesbaden - Germany Office: Room 46-332 - Erwin-Schrödinger-Str.46 - TU Kaiserslautern - Germany Web: gerolf.ziegenhain.com Tel.: +49-611-18840590 Fax: +49-611-18840599 - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Setting font family in ticks not possible. Bug?
On Thursday 27 March 2008 01:27:28 pm Gerolf Ziegenhain wrote: More complete: I tried all permunations of backends. Now I stick to PS, because I use matplotlib from commandline with scripts. The environment is debian/etch with a current version of matplotlib (self compiled). Try this script from pylab import * t = arange(0.0, 2.0, 0.01) s = sin(2*pi*t) plot(t, s) grid(True) # matlab handle graphics style xticklines = getp(gca(), 'xticklines') yticklines = getp(gca(), 'yticklines') xgridlines = getp(gca(), 'xgridlines') ygridlines = getp(gca(), 'ygridlines') xticklabels = getp(gca(), 'xticklabels') yticklabels = getp(gca(), 'yticklabels') setp(xticklines, 'linewidth', 3) setp(yticklines, 'linewidth', 3) setp(xgridlines, 'linestyle', '-') setp(ygridlines, 'linestyle', '-') setp(yticklabels, 'color', 'r', fontsize='medium') setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif') savefig('axprops_demo') ** On my system the line setp(xticklabels, 'color', 'r', fontsize='medium', family='sans-serif') doesn't change the font family. Do you use usetex? If you do, the mathtext is rendered using latex, and latex renders mathtext in serif fonts. Darren - Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users