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 (gerolf@...1807...)
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

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 (gerolf@...1807...)
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

Do you use "usetex"? If you do, the mathtext is rendered using latex, and
latex renders mathtext in serif fonts.

Darren

···

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.

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: mail.gerolf@...1807...
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