[Matplotlib-users] LaTeX fonts

2007-08-07 Thread Johan Ekh
Hi all,
I'm new to Python in general and Matplotlib in particular.
I'm trying to create publication quality plots for inclusion
in LaTeX papers and presentations and have some problems
to get the fonts right.

My matplotlibrc contains the following lines

font.family: serif
font.serif : Times, Palatino, New Century Schoolbook, Bookman,
Computer Modern Roman
font.sans-serif: Helvetica, Avant Garde, Computer Modern Sans serif
font.cursive: Zapf Chancery
font.monospace : Courier, Computer Modern Typewriter

and my Python script contains the following lines

params = {'backend': 'ps',
  'axes.labelsize': 12,
  'text.fontsize': 12,
  'xtick.labelsize': 10,
  'ytick.labelsize': 10,
  'text.usetex': True,
  'figure.figsize': fig_size}
rcParams.update(params)

I run what I believe is a standard openSUSE 10.2 installation of tetex and
python, including matplotlib.

Still, fonts in my matplotlib plot are different from the ones used in my
LaTeX document. Also, strangely
psfrag does not seem to work? Nothing ever gets replaced in my plot!

Can someone please help me out, what am I doing wrong?

Best regards,
Johan
-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] LaTeX fonts

2007-08-07 Thread Darren Dale
On Tuesday 07 August 2007 07:37:04 am Johan Ekh wrote:
 Hi all,
 I'm new to Python in general and Matplotlib in particular.
 I'm trying to create publication quality plots for inclusion
 in LaTeX papers and presentations and have some problems
 to get the fonts right.

 My matplotlibrc contains the following lines

 font.family: serif
 font.serif : Times, Palatino, New Century Schoolbook, Bookman,
 Computer Modern Roman
 font.sans-serif: Helvetica, Avant Garde, Computer Modern Sans serif
 font.cursive: Zapf Chancery
 font.monospace : Courier, Computer Modern Typewriter

 and my Python script contains the following lines

 params = {'backend': 'ps',
   'axes.labelsize': 12,
   'text.fontsize': 12,
   'xtick.labelsize': 10,
   'ytick.labelsize': 10,
   'text.usetex': True,
   'figure.figsize': fig_size}
 rcParams.update(params)

 I run what I believe is a standard openSUSE 10.2 installation of tetex and
 python, including matplotlib.

 Still, fonts in my matplotlib plot are different from the ones used in my
 LaTeX document. Also, strangely
 psfrag does not seem to work? Nothing ever gets replaced in my plot!

 Can someone please help me out, what am I doing wrong?

Please make sure that the external dependencies are installed and properly 
configured, see http://www.scipy.org/Cookbook/Matplotlib/UsingTex. If that 
doesn't help, try setting your verbose.level to debug, write as simple a 
script as possible that reproduces the problem, and post again, along with 
the output and perhaps the figure.

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] LaTeX fonts

2007-08-07 Thread Ryan Krauss
This is admittedly a stupid question, but just to be sure,  I don't see

usetex: True

in your post.

Ryan

On 8/7/07, Johan Ekh [EMAIL PROTECTED] wrote:
 Hi all,
 I'm new to Python in general and Matplotlib in particular.
 I'm trying to create publication quality plots for inclusion
 in LaTeX papers and presentations and have some problems
 to get the fonts right.

 My matplotlibrc contains the following lines

 font.family: serif
 font.serif : Times, Palatino, New Century Schoolbook, Bookman,
 Computer Modern Roman
 font.sans-serif: Helvetica, Avant Garde, Computer Modern Sans serif
 font.cursive: Zapf Chancery
 font.monospace : Courier, Computer Modern Typewriter

 and my Python script contains the following lines

 params = {'backend': 'ps',
   'axes.labelsize ': 12,
   'text.fontsize': 12,
   'xtick.labelsize': 10,
   'ytick.labelsize': 10,
   'text.usetex': True,
   'figure.figsize': fig_size}
 rcParams.update(params)

 I run what I believe is a standard openSUSE 10.2 installation of tetex and
 python, including matplotlib.

 Still, fonts in my matplotlib plot are different from the ones used in my
 LaTeX document. Also, strangely
 psfrag does not seem to work? Nothing ever gets replaced in my plot!

 Can someone please help me out, what am I doing wrong?

 Best regards,
 Johan


 -
 This SF.net email is sponsored by: Splunk Inc.
 Still grepping through log files to find problems?  Stop.
 Now Search log events and configuration files using AJAX and a browser.
 Download your FREE copy of Splunk now   http://get.splunk.com/
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users



-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] LaTeX fonts

2007-08-07 Thread Darren Dale
On Tuesday 07 August 2007 11:37:45 am Johan Ekh wrote:
 OK,
 here is the LaTeX example from the cookbook, i.e. I executed the following:

 --- x ---

 import pylab
 from pylab import arange,pi,sin,cos,sqrt
 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,
   'xtick.labelsize': 8,
   'ytick.labelsize': 8,
   'text.usetex': True,
   'figure.figsize': fig_size}
 pylab.rcParams.update(params)
 # Generate data
 x = pylab.arange(-2*pi,2*pi,0.01)
 y1 = sin(x)
 y2 = cos(x)
 # Plot data
 pylab.figure(1)
 pylab.clf()
 pylab.axes([0.125,0.2,0.95-0.125,0.95-0.2])
 pylab.plot(x,y1,'g:',label='$\sin(x)$')
 pylab.plot(x,y2,'-b',label='$\cos(x)$')
 pylab.xlabel('$x$ (radians)')
 pylab.ylabel('$y$')
 pylab.legend()
 pylab.savefig('fig1.eps')

 --- x ---

 Please find attached the resulting picture and the output from running the
 script with the flag --verbose-debug-annoying.

What is wrong with your output? It looks fine to me. Maybe there is an issue 
with your ps viewer. Try using the agg backend, and saving a png to compare 
the results.

Also, a couple comments:

Any of your strings that have backslashes need to be raw strings:
'$\sin(x)$' should be r'$\sin(x)$'.

You should do this:

import matplotlib as mpl
params = {'backend': 'ps',
   'axes.labelsize': 10,
   'text.fontsize': 10,
   'xtick.labelsize': 8,
   'ytick.labelsize': 8,
   'text.usetex': True,
   'figure.figsize': fig_size}
mpl.rcParams.update(params)

before you do this:

import pylab

Darren

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] LaTeX fonts

2007-08-07 Thread Johan Ekh
Well, it looks OK but the fonts are still not the same as the ones used in
LaTeX (at least not in my installation).
Please look at the attached picture. It is another example but is shows the
difference between the fonts. Best seen
if you focus on the digit 6 in the graph (the upper digit) and in the text
(the lower digit).

Best regards,
Johan

2007/8/7, Darren Dale [EMAIL PROTECTED]:

 On Tuesday 07 August 2007 11:37:45 am Johan Ekh wrote:
  OK,
  here is the LaTeX example from the cookbook, i.e. I executed the
 following:
 
  --- x ---
 
  import pylab
  from pylab import arange,pi,sin,cos,sqrt
  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,
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'text.usetex': True,
'figure.figsize': fig_size}
  pylab.rcParams.update(params)
  # Generate data
  x = pylab.arange(-2*pi,2*pi,0.01)
  y1 = sin(x)
  y2 = cos(x)
  # Plot data
  pylab.figure(1)
  pylab.clf()
  pylab.axes([0.125,0.2,0.95-0.125,0.95-0.2])
  pylab.plot(x,y1,'g:',label='$\sin(x)$')
  pylab.plot(x,y2,'-b',label='$\cos(x)$')
  pylab.xlabel('$x$ (radians)')
  pylab.ylabel('$y$')
  pylab.legend()
  pylab.savefig('fig1.eps')
 
  --- x ---
 
  Please find attached the resulting picture and the output from running
 the
  script with the flag --verbose-debug-annoying.

 What is wrong with your output? It looks fine to me. Maybe there is an
 issue
 with your ps viewer. Try using the agg backend, and saving a png to
 compare
 the results.

 Also, a couple comments:

 Any of your strings that have backslashes need to be raw strings:
 '$\sin(x)$' should be r'$\sin(x)$'.

 You should do this:

 import matplotlib as mpl
 params = {'backend': 'ps',
'axes.labelsize': 10,
'text.fontsize': 10,
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'text.usetex': True,
'figure.figsize': fig_size}
 mpl.rcParams.update(params)

 before you do this:

 import pylab

 Darren

attachment: closeup.png-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] LaTeX fonts

2007-08-07 Thread Darren Dale
On Tuesday 07 August 2007 12:17:56 pm Johan Ekh wrote:
 Well, it looks OK but the fonts are still not the same as the ones used in
 LaTeX (at least not in my installation).
 Please look at the attached picture. It is another example but is shows the
 difference between the fonts. Best seen
 if you focus on the digit 6 in the graph (the upper digit) and in the
 text (the lower digit).

You have your font.family set to serif and font.serif set to Times. That means 
you are telling matplotlib to use the Times fonts, but you are using the 
default Computer Modern fonts in your latex document. I suggest you either 
add \usepackage{pslatex} in your latex header to use the adobe fonts instead 
of computer modern, or move computer modern roman to the front of your list 
of serif fonts in matplotlib.

Darren 

-
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now   http://get.splunk.com/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users