Re: [Matplotlib-users] savefig as pdf not generating vector graphics?

2009-06-28 Thread Jouni K . Seppänen
per freem perfr...@gmail.com writes:

 i am using matplotlib 0.98.5.2 on Mac OS X. i am plotting a histogram
 and then saving it as .pdf. The x and y labels use some symbols from
 latex, and i have useTex set to true in my rcParams.

Do you really need usetex? Matplotlib's usual mathtext engine is pretty
good and doesn't require any external programs.

 The problem is that myfig.pdf for some reason renders the figure's x
 and y labels as *images* rather than vector graphics.

Could you send the resulting pdf file to me off-list?

-- 
Jouni K. Seppänen
http://www.iki.fi/jks


--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] savefig as pdf not generating vector graphics?

2009-06-28 Thread Jouni K . Seppänen
per freem perfr...@gmail.com writes:

 you're right, i don't need to use usetex -- i removed it, but the problem
 still persists. here is the pdf that it generates (code below). any idea
 what is happening here? thanks very much for your help.

The file you sent was not generated by the pdf backend but by Mac OS X
10.5.6 Quartz PDFContext, which probably means that the OS X backend
saves pdf files using the OS X machinery and not the pdf backend. Indeed
the formulas look like bitmaps.

 from scipy import *
 import matplotlib.pyplot as plt
 from matplotlib import rc
 rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
 import matplotlib
 matplotlib.use('PDF')

You are trying to use the pdf backend, but the last line quoted above
has no effect because you have already imported pyplot, which causes the
backend to be set as directed by your matplotlibrc file. Any call to
matplotlib.use needs to be done before you import pyplot.

-- 
Jouni K. Seppänen
http://www.iki.fi/jks

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] setting figure font to helvetica

2009-06-28 Thread per freem
hi,

i am trying to use the Helvetica font on matplotlib. i am using mac os x (so
i definitely have helvetica installed) with version 0.98.5.2 of matplotlib.
my code is:

from scipy import *
import matplotlib
matplotlib.use('PDF')
from matplotlib import rc
import matplotlib.pyplot as plt
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
plt.rcParams['font.family'] = 'Helvetica'
plt.hist(rand(100))
xlabel(rMy x axis $\alpha$)
ylabel(rMy y axis $\beta$)

i verified that plt.rcParams gets modified to use 'Helvetica' as the value
for font.family, etc. but i still get the default font used in all of these
figures. i tried using the PS backend using matplotlib.use('PS') but the
problem persists. i am interested in getting out PDFs that use helvetica
everywhere.

does anyone know how to fix this? thank you.
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] setting figure font to helvetica

2009-06-28 Thread per freem
I just wanted to add: if i simply set the font to Arial, using

rc('font',**{'family':'sans-serif','sans-serif':['Arial']})

then it works. But the same call with Helvetica still defaults to that
Bitstream/default font of matplotlib. any idea why this might be? could
matplotlib be confusing helvetica with bitstream?

On Sun, Jun 28, 2009 at 11:28 AM, per freem perfr...@gmail.com wrote:

 hi,

 i am trying to use the Helvetica font on matplotlib. i am using mac os x
 (so i definitely have helvetica installed) with version 0.98.5.2 of
 matplotlib. my code is:

 from scipy import *
 import matplotlib
 matplotlib.use('PDF')
 from matplotlib import rc
 import matplotlib.pyplot as plt
 rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
 plt.hist(rand(100))
 xlabel(rMy x axis $\alpha$)
 ylabel(rMy y axis $\beta$)

 i verified that plt.rcParams gets modified to use 'Helvetica' as the value
 for font.family, etc. but i still get the default font used in all of these
 figures. i tried using the PS backend using matplotlib.use('PS') but the
 problem persists. i am interested in getting out PDFs that use helvetica
 everywhere.

 does anyone know how to fix this? thank you.

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Stopping Legend From Overlapping the Graph

2009-06-28 Thread Chris Spencer
Awesome, thanks. That works perfectly.

Chris

On Sun, Jun 28, 2009 at 12:16 AM, Jae-Joon Leelee.j.j...@gmail.com wrote:
 sorry.
 As guillaume has mentioned, you need to install mpl from svn.

 Here is some workaround you can try. I guess it would work with 0.98.5.3.
 Basically, you create a separate axes for a legend.

 ax1 = axes([0.1, 0.2,0.8, 0.7])
 p1, = ax1.plot([1,2,3])
 p2, = ax1.plot([3,2,1])

 ax2 = axes([0.1, 0.1, 0.8, 0.01], frameon=False)
 ax2.xaxis.set_visible(False)
 ax2.yaxis.set_visible(False)
 l = ax2.legend([p1, p2], [Legend1, Legend2], mode=expand, ncol=2,
   borderaxespad=0.)


 -JJ



 On Sat, Jun 27, 2009 at 6:00 PM, Chris Spencerchriss...@gmail.com wrote:
 Thanks. Is that some sort of blending edge feature? I just installed
 0.98.5.3, but the sample code gives me the error:

 TypeError: __init__() got an unexpected keyword argument 'bbox_to_anchor'

 On Thu, Jun 25, 2009 at 10:20 PM, Jae-Joon Leelee.j.j...@gmail.com wrote:
 The linked page below shows how you put the legend above the graph.

 http://matplotlib.sourceforge.net/users/plotting/legend.html#legend-location

 You can put it below the axes by adjusting the bbox_to_anchor parameter.
 Try something like
  bbox_to_anchor=(0., -0.1, 1., -0.1), loc=1

 Make sure to adjust the suplot parameter (or axes location) to make
 enough room for the legend.

 -JJ



 On Thu, Jun 25, 2009 at 9:22 PM, Chris Spencerchriss...@gmail.com wrote:
 How do you show the legend below the graph, so it doesn't overlap at
 all with the graph? The docs for the legend() loc parameter only
 seem to specify where *on* the graph you want it to show, which is
 driving me nuts because even using best, it usually hides some of my
 data.

 I want to see *all* of my graph, as well as the legend. Is there any
 way to do this with pylab?

 Any help is appreciated.

 Chris

 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users





--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] savefig as pdf not generating vector graphics?

2009-06-28 Thread Michiel de Hoon

--- On Sun, 6/28/09, Jouni K. Seppänen j...@iki.fi wrote:
 The file you sent was not generated by the pdf backend but
 by Mac OS X 10.5.6 Quartz PDFContext, which probably means
 that the OS X backend saves pdf files using the OS X machinery
 and not the pdf backend. Indeed the formulas look like bitmaps.

Previously the Mac OS X backend indeed used its own machinery to create PDF 
files. Recent versions of the backend in SVN, however, use matplotlib's pdf 
backend. So the problem should go away if you use matplotlib from SVN.

The Mac OS X backend itself can actually be fixed to use vector graphics on 
screen instead of bitmaps. That will need some time, but I'll get round to it 
one of these weeks.

--Michiel.


  

--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users