Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to change axes labels font size in PGF?

Hi!

I am trying to change axes labels font size during export to PGD using the following code:

# Change font style
from matplotlib import rc

font = {'family':'serif',
        'serif':['Computer Modern Unicode'],
        'size': 10, }

rc('font', **font)

# Create and save test plot
file_name = '/tmp/foo.pgf'
p = plot(sin, 0, 2 * pi,  axes_labels=('$x$', '$y$'))
p.save(file_name)

# Check font size
with open(file_name, 'r') as f:
    for line in f:
        if 'fontsize' in line:
            print line,

And then suddenly these lines appear in the output of the last block:

\pgftext[x=1.495728in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 1}% \pgftext[x=2.612150in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 2}% \pgftext[x=3.728572in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 3}% \pgftext[x=4.844994in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 4}% \pgftext[x=5.961415in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 5}% \pgftext[x=7.077837in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 6}% \pgftext[x=7.645397in,y=2.795699in,left,base]{\rmfamily \fontsize{16.000000}{19.200000} \selectfont (\displaystyle x)}% \pgftext[x=0.323750in,y=0.203598in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont -1}% \pgftext[x=0.323750in,y=1.499649in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont -0.5}% \pgftext[x=0.323750in,y=4.091749in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 0.5}% \pgftext[x=0.323750in,y=5.387800in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 1}% \pgftext[x=0.379306in,y=5.602445in,,bottom]{\rmfamily \fontsize{16.000000}{19.200000} \selectfont (\displaystyle y)}%

Why does font size 16 requested, font size 12 was specified explicitly.

How to change axes labels font size in PGF?PGF (possible bug?)?

Hi!

I am trying to change axes labels font size during export to PGD using the following code:

# Change font style
from matplotlib import rc

font = {'family':'serif',
        'serif':['Computer Modern Unicode'],
        'size': 10, }

rc('font', **font)

# Create and save test plot
file_name = '/tmp/foo.pgf'
p = plot(sin, 0, 2 * pi,  axes_labels=('$x$', '$y$'))
p.save(file_name)

# Check font size
with open(file_name, 'r') as f:
    for line in f:
        if 'fontsize' in line:
            print line,

And then suddenly these lines appear in the output of the last block:

\pgftext[x=1.495728in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 1}% \pgftext[x=2.612150in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 2}% \pgftext[x=3.728572in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 3}% \pgftext[x=4.844994in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 4}% \pgftext[x=5.961415in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 5}% \pgftext[x=7.077837in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 6}% \pgftext[x=7.645397in,y=2.795699in,left,base]{\rmfamily \fontsize{16.000000}{19.200000} \selectfont (\displaystyle x)}% \pgftext[x=0.323750in,y=0.203598in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont -1}% \pgftext[x=0.323750in,y=1.499649in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont -0.5}% \pgftext[x=0.323750in,y=4.091749in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 0.5}% \pgftext[x=0.323750in,y=5.387800in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 1}% \pgftext[x=0.379306in,y=5.602445in,,bottom]{\rmfamily \fontsize{16.000000}{19.200000} \selectfont (\displaystyle y)}%

Why does font size 16 requested, font size 12 was specified explicitly.

How to change axes labels font size in PGF (possible bug?)?

Hi!

I am trying to change axes labels font size during export to PGD using the following code:

# Change font style
from matplotlib import rc

font = {'family':'serif',
        'serif':['Computer Modern Unicode'],
        'size': 10, }

rc('font', **font)

# Create and save test plot
file_name = '/tmp/foo.pgf'
p = plot(sin, 0, 2 * pi,  axes_labels=('$x$', '$y$'))
p.save(file_name)

# Check font size
with open(file_name, 'r') as f:
    for line in f:
        if 'fontsize' in line:
            print line,

And then suddenly these lines appear in the output of the last block:

\pgftext[x=1.495728in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 1}% \pgftext[x=2.612150in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 2}% \pgftext[x=3.728572in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 3}% \pgftext[x=4.844994in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 4}% \pgftext[x=5.961415in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 5}% \pgftext[x=7.077837in,y=2.740143in,,top]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 6}% \pgftext[x=7.645397in,y=2.795699in,left,base]{\rmfamily \fontsize{16.000000}{19.200000} \selectfont (\displaystyle x)}% \pgftext[x=0.323750in,y=0.203598in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont -1}% \pgftext[x=0.323750in,y=1.499649in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont -0.5}% \pgftext[x=0.323750in,y=4.091749in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 0.5}% \pgftext[x=0.323750in,y=5.387800in,right,]{\rmfamily\fontsize{10.000000}{12.000000}\selectfont 1}% \pgftext[x=0.379306in,y=5.602445in,,bottom]{\rmfamily \fontsize{16.000000}{19.200000} \selectfont (\displaystyle y)}%

Why does font size 16 requested, font size 12 10 was specified explicitly.