lib/matplotlib/backends/backend_ps.py
def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
                    paperWidth, paperHeight, orientation):
    """
    When we want to use the LaTeX backend with postscript, we write PSFrag tags
    to a temporary postscript file, each one marking a position for LaTeX to
    render some text. convert_psfrags generates a LaTeX document containing the
    commands to convert those tags to text. LaTeX/dvips produces the postscript
    file that includes the actual text.
    """
    tmpdir = os.path.split(tmpfile)[0]
    epsfile = tmpfile+'.eps'
    shutil.move(tmpfile, epsfile)
    latexfile = tmpfile+'.tex'
    outfile = tmpfile+'.output'
    latexh = file(latexfile, 'w')
    dvifile = tmpfile+'.dvi'
    psfile = tmpfile+'.ps'

    if orientation=='landscape': angle = 90
    else: angle = 0

    if rcParams['text.latex.unicode']:
        unicode_preamble = """\usepackage{ucs}
\usepackage[utf8x]{inputenc}"""
    else:
        unicode_preamble = ''

    s = r"""\documentclass{article}
%s
%s
%s
\usepackage[dvips, papersize={%sin,%sin}, body={%sin,%sin}, margin={0in,0in}]{geometry}
\usepackage{psfrag}
\usepackage[dvips]{graphicx}
\usepackage{color}
\pagestyle{empty}
\begin{document}
\begin{figure}
\centering
\leavevmode
%s
\includegraphics*[angle=%s]{%s}
\end{figure}
\end{document}
"""% (font_preamble, unicode_preamble, custom_preamble, paperWidth, paperHeight,
      paperWidth, paperHeight,
      '\n'.join(psfrags), angle, os.path.split(epsfile)[-1])

    if rcParams['text.latex.unicode']:
        latexh.write(s.encode('utf8'))
    else:
        try:
            latexh.write(s)
        except UnicodeEncodeError, err:
            verbose.report("You are using unicode and latex, but have "
                           "not enabled the matplotlib 'text.latex.unicode' "
                           "rcParam.", 'helpful')
            raise

    latexh.close()

    # the split drive part of the command is necessary for windows users with
    # multiple
    if sys.platform == 'win32': precmd = '%s &&'% os.path.splitdrive(tmpdir)[0]
    else: precmd = ''
    command = '%s cd "%s" && latex -interaction=nonstopmode "%s" > "%s"'\
                %(precmd, tmpdir, latexfile, outfile)
    verbose.report(command, 'debug')
    exit_status = os.system(command)
    fh = file(outfile)
    if exit_status:
        raise RuntimeError('LaTeX was not able to process your file:\
\nHere is the full report generated by LaTeX: \n\n%s'% fh.read())
    else: verbose.report(fh.read(), 'debug')
    fh.close()
    os.remove(outfile)

    command = '%s cd "%s" && dvips -q -R0 -o "%s" "%s" > "%s"'%(precmd, tmpdir,
                os.path.split(psfile)[-1], os.path.split(dvifile)[-1], outfile)
    verbose.report(command, 'debug')
    exit_status = os.system(command)
    fh = file(outfile)
    if exit_status: raise RuntimeError('dvips was not able to \
process the following file:\n%s\nHere is the full report generated by dvips: \
\n\n'% dvifile + fh.read())
    else: verbose.report(fh.read(), 'debug')
    fh.close()
    os.remove(outfile)
    os.remove(epsfile)
    shutil.move(psfile, tmpfile)
    if not debugPS:
        for fname in glob.glob(tmpfile+'.*'):
            os.remove(fname)

    When we want to use the LaTeX backend with postscript, we write PSFrag tags
    to a temporary postscript file, each one marking a position for LaTeX to
    render some text. convert_psfrags generates a LaTeX document containing the
    commands to convert those tags to text. LaTeX/dvips produces the postscript
    file that includes the actual text.
    
When we want to use the LaTeX backend with postscript, we write PSFrag tags
to a temporary postscript file, each one marking a position for LaTeX to
render some text. convert_psfrags generates a LaTeX document containing the
commands to convert those tags to text. LaTeX/dvips produces the postscript
file that includes the actual text.
When we want to use the LaTeX backend with postscript we write PSFrag tags to a temporary postscript file each one marking a position for LaTeX to render some text . convert_psfrags generates a LaTeX document containing the commands to convert those tags to text . LaTeX / dvips produces the postscript file that includes the actual text .
def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
                    paperWidth, paperHeight, orientation):
    tmpdir = os.path.split(tmpfile)[0]
    epsfile = tmpfile+'.eps'
    shutil.move(tmpfile, epsfile)
    latexfile = tmpfile+'.tex'
    outfile = tmpfile+'.output'
    latexh = file(latexfile, 'w')
    dvifile = tmpfile+'.dvi'
    psfile = tmpfile+'.ps'
    if orientation=='landscape': angle = 90
    else: angle = 0
    if rcParams['text.latex.unicode']:
        unicode_preamble = """\usepackage{ucs}
\usepackage[utf8x]{inputenc}"""
    else:
        unicode_preamble = ''
    s = r"""\documentclass{article}
%s
%s
%s
\usepackage[dvips, papersize={%sin,%sin}, body={%sin,%sin}, margin={0in,0in}]{geometry}
\usepackage{psfrag}
\usepackage[dvips]{graphicx}
\usepackage{color}
\pagestyle{empty}
\begin{document}
\begin{figure}
\centering
\leavevmode
%s
\includegraphics*[angle=%s]{%s}
\end{figure}
\end{document}
"""% (font_preamble, unicode_preamble, custom_preamble, paperWidth, paperHeight,
      paperWidth, paperHeight,
      '\n'.join(psfrags), angle, os.path.split(epsfile)[-1])
    if rcParams['text.latex.unicode']:
        latexh.write(s.encode('utf8'))
    else:
        try:
            latexh.write(s)
        except UnicodeEncodeError, err:
            verbose.report("You are using unicode and latex, but have "
                           "not enabled the matplotlib 'text.latex.unicode' "
                           "rcParam.", 'helpful')
            raise
    latexh.close()
    if sys.platform == 'win32': precmd = '%s &&'% os.path.splitdrive(tmpdir)[0]
    else: precmd = ''
    command = '%s cd "%s" && latex -interaction=nonstopmode "%s" > "%s"'\
                %(precmd, tmpdir, latexfile, outfile)
    verbose.report(command, 'debug')
    exit_status = os.system(command)
    fh = file(outfile)
    if exit_status:
        raise RuntimeError('LaTeX was not able to process your file:\
\nHere is the full report generated by LaTeX: \n\n%s'% fh.read())
    else: verbose.report(fh.read(), 'debug')
    fh.close()
    os.remove(outfile)
    command = '%s cd "%s" && dvips -q -R0 -o "%s" "%s" > "%s"'%(precmd, tmpdir,
                os.path.split(psfile)[-1], os.path.split(dvifile)[-1], outfile)
    verbose.report(command, 'debug')
    exit_status = os.system(command)
    fh = file(outfile)
    if exit_status: raise RuntimeError('dvips was not able to \
process the following file:\n%s\nHere is the full report generated by dvips: \
\n\n'% dvifile + fh.read())
    else: verbose.report(fh.read(), 'debug')
    fh.close()
    os.remove(outfile)
    os.remove(epsfile)
    shutil.move(psfile, tmpfile)
    if not debugPS:
        for fname in glob.glob(tmpfile+'.*'):
            os.remove(fname)
def convert_psfrags ( tmpfile , psfrags , font_preamble , custom_preamble , paperWidth , paperHeight , orientation ) : tmpdir = os . path . split ( tmpfile ) [ 0 ] epsfile = tmpfile + '.eps' shutil . move ( tmpfile , epsfile ) latexfile = tmpfile + '.tex' outfile = tmpfile + '.output' latexh = file ( latexfile , 'w' ) dvifile = tmpfile + '.dvi' psfile = tmpfile + '.ps' if orientation == 'landscape' : angle = 90 else : angle = 0 if rcParams [ 'text.latex.unicode' ] : unicode_preamble = """\usepackage{ucs}
\usepackage[utf8x]{inputenc}""" else : unicode_preamble = '' s = r"""\documentclass{article}
%s
%s
%s
\usepackage[dvips, papersize={%sin,%sin}, body={%sin,%sin}, margin={0in,0in}]{geometry}
\usepackage{psfrag}
\usepackage[dvips]{graphicx}
\usepackage{color}
\pagestyle{empty}
\begin{document}
\begin{figure}
\centering
\leavevmode
%s
\includegraphics*[angle=%s]{%s}
\end{figure}
\end{document}
""" % ( font_preamble , unicode_preamble , custom_preamble , paperWidth , paperHeight , paperWidth , paperHeight , '\n' . join ( psfrags ) , angle , os . path . split ( epsfile ) [ - 1 ] ) if rcParams [ 'text.latex.unicode' ] : latexh . write ( s . encode ( 'utf8' ) ) else : try : latexh . write ( s ) except UnicodeEncodeError , err : verbose . report ( "You are using unicode and latex, but have " "not enabled the matplotlib 'text.latex.unicode' " "rcParam." , 'helpful' ) raise latexh . close ( ) if sys . platform == 'win32' : precmd = '%s &&' % os . path . splitdrive ( tmpdir ) [ 0 ] else : precmd = '' command = '%s cd "%s" && latex -interaction=nonstopmode "%s" > "%s"' % ( precmd , tmpdir , latexfile , outfile ) verbose . report ( command , 'debug' ) exit_status = os . system ( command ) fh = file ( outfile ) if exit_status : raise RuntimeError ( 'LaTeX was not able to process your file:\
\nHere is the full report generated by LaTeX: \n\n%s' % fh . read ( ) ) else : verbose . report ( fh . read ( ) , 'debug' ) fh . close ( ) os . remove ( outfile ) command = '%s cd "%s" && dvips -q -R0 -o "%s" "%s" > "%s"' % ( precmd , tmpdir , os . path . split ( psfile ) [ - 1 ] , os . path . split ( dvifile ) [ - 1 ] , outfile ) verbose . report ( command , 'debug' ) exit_status = os . system ( command ) fh = file ( outfile ) if exit_status : raise RuntimeError ( 'dvips was not able to \
process the following file:\n%s\nHere is the full report generated by dvips: \
\n\n' % dvifile + fh . read ( ) ) else : verbose . report ( fh . read ( ) , 'debug' ) fh . close ( ) os . remove ( outfile ) os . remove ( epsfile ) shutil . move ( psfile , tmpfile ) if not debugPS : for fname in glob . glob ( tmpfile + '.*' ) : os . remove ( fname )
When we want to use the LaTeX backend with postscript, we write PSFrag tags
to a temporary postscript file, each one marking a position for LaTeX to
render some text.
When we want to use the LaTeX backend with postscript we write PSFrag tags to a temporary postscript file each one marking a position for LaTeX to render some text .
"""
    When we want to use the LaTeX backend with postscript, we write PSFrag tags
    to a temporary postscript file, each one marking a position for LaTeX to
    render some text. convert_psfrags generates a LaTeX document containing the
    commands to convert those tags to text. LaTeX/dvips produces the postscript
    file that includes the actual text.
    """ # the split drive part of the command is necessary for windows users with # multiple
tmpfile
psfrags
font_preamble
custom_preamble
paperWidth
paperHeight
orientation