
 m[c        K   @` s  d  Z  d d l m Z m Z m Z m Z d d l Z d d l m Z d d l Z d d l	 Z	 d d l
 m
 Z
 d d l m Z d d l m Z d d l Z d d l m Z m Z m Z m Z m Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d	 l m  Z  m! Z! m" Z" d d
 l# m$ Z$ d d l% m& Z& m' Z' m( Z( m) Z) m* Z* d d l+ m, Z, d d l- m. Z. m/ Z/ m0 Z0 m1 Z1 d d l2 m3 Z3 d d l4 m5 Z5 m6 Z6 m7 Z7 d d l8 m9 Z9 d d l: j; Z; d d l< j= Z= d d l> m? Z? m@ Z@ mA ZA mB ZB mC ZC d d lD mE ZE d d lF mG ZG mH ZH d d lI mJ ZJ d d lK mL ZL d d l mM ZM d d l mN ZN d d l mO ZO e jP eQ  ZR d d  ZS e jT d  ZU d   ZV d   ZW d eX f d     YZY e d  eX f d!     Y ZZ d" eX f d#     YZ[ d$ eX f d%     YZ\ e] d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF dG dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd de df dg dh di dj dk dl dm dn do  %Z^ e. dp   e j_ e^  D   Z` dq   Za ea e` _b dr eX f ds     YZc dt eX f du     YZd dv e* f dw     YZe dx e) f dy     YZf dz eX f d{     YZg d| e' f d}     YZh d~ e( f d     YZi e& jj d e& f d     Y Zk d S(   uA   
A PDF matplotlib backend
Author: Jouni K Seppänen <jks@iki.fi>
i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   unichr(   t   datetime(   t   total_ordering(   t   BytesIO(   t   ceilt   cost   floort   pit   sin(   t   cbookt   __version__t   rcParams(   t   Gcf(   t   _Backendt   FigureCanvasBaset   FigureManagerBaset   GraphicsContextBaset   RendererBase(   t   MixedModeRenderer(   t   Buncht   get_realpath_and_statt   is_writable_file_liket   maxdict(   t   Figure(   t   findfontt   is_opentype_cff_fontt   get_font(   t   AFM(   t   FIXED_WIDTHt   ITALICt   LOAD_NO_SCALEt   LOAD_NO_HINTINGt   KERNING_UNFITTED(   t   MathTextParser(   t   Affine2Dt   BboxBase(   t   Path(   t   UTC(   t   _path(   t   _png(   t   ttconviK   c         C` s   d } d } g  } xp t  |   D]b \ } } t |  } | | | k  rX | | d 7} q | j d j |  | | !  | } | } q W| j d j |  |   d j |  S(   u   Make one string from sequence of strings, with whitespace
    in between. The whitespace is chosen to form lines of at most
    linelen characters, if possible.i    i   t    s   
(   t	   enumeratet   lent   appendt   join(   t   stringst   linelent   currpost   lastit   resultt   it   st   length(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   fillg   s    
s   ([\\()\r\n])c         C` sS   |  j  d  } | d k r# d | S| d k r3 d S| d k rC d St sO t  d  S(   Ni    s   \()s   \s   
s   \ns   s   \r(   t   groupt   Falset   AssertionError(   t   matcht   m(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   _string_escape   s    c         C` sI  t  |  d  r |  j   St |  t t j f  rx t j |   sO t d   n  d |  j d  } | j	 d  j	 d  St |  t
  r d d g |  St |  t j t j f  r d	 |  j d  St |  t j  r$y |  j d
  } t |  SWqEt k
 r t j |  j d  } t |  SXn!t |  t  rKd t j t |   d St |  t  rd g } | j g  t |   D]* } t |  j   d t |  |  ^ qv | j d  t |  St |  t t f  rd g } | j g  |  D] } t |  ^ q | j d  t |  S|  d k r)d St |  t  r|  j  d  } |  j!   } | d k	 rk| j" } n t# j$ rt# j% } n	 t# j& } | d k r| d 7} nI | d k  r| d | d | d f 7} n | d | d | d f 7} t |  St |  t'  r*t g  |  j( D] } t |  ^ q St) d j* t+ |      d S(   u!   Map Python objects to PDF syntax.u   pdfRepru%   Can only output finite numbers in PDFu   %.10fu   asciit   0t   .t   falset   trueu   %du   ASCIIu   UTF-16BEt   (t   )s   <<R-   s   >>t   [t   ]t   nullu   D:%Y%m%d%H%M%Si    u   Zu   +%02d'%02d'i  u   -%02d'%02d'u.   Don't know a PDF representation for {} objectsN(,   t   hasattrt   pdfReprt
   isinstancet   floatt   npt   floatingt   isfinitet
   ValueErrort   encodet   rstript   boolt   sixt   integer_typest   integert	   text_typet   UnicodeEncodeErrort   codecst   BOM_UTF16_BEt   bytest   _string_escape_regext   subR@   t   dictt   extendt   sortedt   NameR0   R:   t   listt   tuplet   NoneR   t   strftimet	   utcoffsett   secondst   timet   daylightt   altzonet   timezoneR'   t   boundst	   TypeErrort   formatt   type(   t   objt   rR8   t   keyt   valt   z(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRK      sf    
		;
	&
		!
&	t	   Referencec           B` s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   uP   PDF reference object.
    Use PdfFile.reserveObject() to create References.
    c         C` s   | |  _  d  S(   N(   t   id(   t   selfRw   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   __init__   s    c         C` s   d |  j  S(   Nu   <Reference %d>(   Rw   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   __repr__   s    c         C` s   d |  j  j d  S(   Nu   %d 0 Ru   ascii(   Rw   RR   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRK      s    c         C` sA   | j  } | d |  j j d   | t |   | d  d  S(   Nu	   %d 0 obj
u   asciis   
endobj
(   t   writeRw   RR   RK   (   Rx   t   contentst   fileR{   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR{      s    	(   t   __name__t
   __module__t   __doc__Ry   Rz   RK   R{   (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRv      s
   			Rb   c           B` sq   e  Z d  Z d Z e j d  Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z e d	    Z d
   Z RS(   u   PDF name object.u   nameu   [^!-~]c         C` sg   t  | t  r | j |  _ nE t  | t  r? | j d  } n  |  j j t j |  j d  |  _ d  S(   Nu   ascii(	   RL   Rb   t   nameR\   t   decodet   _regexR^   t   hexifyRR   (   Rx   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy     s
    c         C` s   d |  j  S(   Nu	   <Name %s>(   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRz     s    c         C` s   d t  j |  j  S(   Nu   /(   RU   RX   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   __str__  s    c         C` s   t  | t  o |  j | j k S(   N(   RL   Rb   R   (   Rx   t   other(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   __eq__  s    c         C` s   t  | t  o |  j | j k  S(   N(   RL   Rb   R   (   Rx   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   __lt__  s    c         C` s   t  |  j  S(   N(   t   hashR   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   __hash__  s    c         C` s   d t  |  j    S(   Nu   #%02x(   t   ordR;   (   R>   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR     s    c         C` s   d |  j  S(   Nt   /(   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRK     s    (   u   name(   R~   R   R   t	   __slots__t   ret   compileR   Ry   Rz   R   R   R   R   t   staticmethodR   RK   (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRb      s   						t   Operatorc           B` s/   e  Z d  Z d Z d   Z d   Z d   Z RS(   u   PDF operator object.u   opc         C` s   | |  _  d  S(   N(   t   op(   Rx   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy   '  s    c         C` s   d |  j  S(   Nu   <Operator %s>(   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRz   *  s    c         C` s   |  j  S(   N(   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRK   -  s    (   u   op(   R~   R   R   R   Ry   Rz   RK   (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR   #  s
   		t   Verbatimc           B` s    e  Z d  Z d   Z d   Z RS(   uI   Store verbatim PDF command content for later inclusion in the
    stream.c         C` s   | |  _  d  S(   N(   t   _x(   Rx   t   x(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy   4  s    c         C` s   |  j  S(   N(   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRK   7  s    (   R~   R   R   Ry   RK   (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR   1  s   	t   close_fill_stroket   bt   fill_stroket   BR:   t   ft	   closepatht   ht   close_strokeR8   t   stroket   St   endpatht   nt
   begin_textt   BTt   end_textt   ETt   curvetot   ct	   rectangleR   t   linetot   lt   movetoR?   t   concat_matrixt   cmt   use_xobjectt   Dot   setgray_stroket   Gt   setgray_nonstroket   gt   setrgb_stroket   RGt   setrgb_nonstroket   rgt   setcolorspace_stroket   CSt   setcolorspace_nonstroket   cst   setcolor_stroket   SCNt   setcolor_nonstroket   scnt   setdasht   dt   setlinejoint   jt
   setlinecapt   Jt	   setgstatet   gst   gsavet   qt   grestoret   Qt   textpost   Tdt
   selectfontt   Tft
   textmatrixt   Tmt   showt   Tjt   showkernt   TJt   setlinewidtht   wt   clipt   Wt   shadingt   shc         C` s%   i  |  ] \ } } t  |  |  q S(    (   R   (   t   .0R   t   value(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pys
   <dictcomp>H  s   	 c         C` s5   | r |  r t  j St  j Sn |  r* t  j St  j Sd S(   u   Return the PDF operator to paint a path in the following way:
    fill:   fill the path with the fill color
    stroke: stroke the outline of the path with the line colorN(   t   OpR   R   R:   R   (   R:   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   _paint_pathK  s    
t   Streamc           B` sG   e  Z d  Z d Z d d d  Z d	   Z d
   Z d   Z d   Z	 RS(   u   PDF stream object.

    This has no pdfRepr method. Instead, call begin(), then output the
    contents of the stream by calling write(), and finally call end().
    u   idu   lenu   pdfFileu   fileu   compressobju   extrau   posc         C` s  | |  _  | |  _ | |  _ | j |  _ d |  _ | d k rK t   |  _ n | j	   |  _ | d k	 r |  j j
 i t d  d 6| d 6 n  |  j j |  j   t d r | r t j t d  |  _ n  |  j d k r t   |  _ n |  j   |  j j   |  _ d S(   u9  id: object id of stream; len: an unused Reference object for the
        length of the stream, or None (to use a memory buffer); file:
        a PdfFile; extra: a dictionary of extra key-value pairs to
        include in the stream header; png: if the data is already
        png compressed, the decode parametersu   FlateDecodeu   Filteru   DecodeParmsu   pdf.compressionN(   Rw   R/   t   pdfFilet   fhR}   Re   t   compressobjR_   t   extrat   copyt   updateRb   t
   recordXrefR   t   zlibR   t   _writeHeadert   tellt   pos(   Rx   Rw   R/   R}   R   t   png(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy   d  s$    				
c         C` sw   |  j  j } | d |  j j d   |  j } |  j | d <t d rY t d  | d <n  | t |   | d  d  S(   Nu	   %d 0 obj
u   asciiu   Lengthu   pdf.compressionu   FlateDecodeu   Filters   
stream
(	   R}   R{   Rw   RR   R   R/   R   Rb   RK   (   Rx   R{   R_   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR     s    	
c         C` s   |  j    |  j d k rs |  j j   } t |  |  _ |  j j |  _ |  j   |  j j |  |  j j d  n< |  j j	   |  j
 } |  j j d  |  j j |  j |  d S(   u   Finalize stream.s   
endstream
endobj
N(   t   _flushR/   Re   R}   t   getvalueR   R   R   R{   R   R   t   writeObject(   Rx   R|   R9   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   end  s    

c         C` sH   |  j  d k r" |  j j |  n" |  j  j |  } |  j j |  d S(   u   Write some data on the stream.N(   R   Re   R}   R{   t   compress(   Rx   t   datat
   compressed(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR{     s    c         C` s>   |  j  d k	 r: |  j  j   } |  j j |  d |  _  n  d S(   u   Flush the compression object.N(   R   Re   t   flushR}   R{   (   Rx   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR     s    (   u   idu   lenu   pdfFileu   fileu   compressobju   extrau   posN(
   R~   R   R   R   Re   Ry   R   R   R{   R   (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR   \  s   				t   PdfFilec           B` s  e  Z d  Z e d  Z d   Z d d d d g d  Z d   Z d   Z d   Z	 d	   Z
 e e d
  Z d   Z d   Z e d    Z d   Z d   Z d   Z d   Z d   Z d   Z d Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e d  Z  d   Z! d    Z" d!   Z# d"   Z$ d#   Z% e& e e e d$   Z' e( e d%  Z) d& d'  Z* d(   Z+ d)   Z, d*   Z- d+   Z. d,   Z/ RS(-   u   PDF file object.c         C` s  d |  _  d d d g g |  _ t |  _ d  |  _ d |  _ t j | d d t	 \ } } | s y | j
   |  _ Wn# t k
 r t   } | |  _ q X| } t	 |  _ n  t j j t d d d	  |  _ | |  _ d  |  _ | j d
  | j d  |  j d  |  _ |  j d  |  _ g  |  _ |  j d  |  _ |  j d  |  _ |  j d  |  _ |  j d  |  _ |  j d  |  _ |  j d  |  _ i t d  d 6|  j d 6} |  j  |  j |  t j! d  } | rt" j# t$ |   } | j% d t&  } n t" j'   } i d t( d 6d t( d 6| d 6|  _) | d  k	 rL|  j) j* |  n  d   |  j) j+   D |  _) i  |  _, d |  _- i  |  _. d  |  _/ i  |  _0 i  |  _1 i  |  _2 d |  _3 t4 j5   |  _6 d |  _7 g  |  _8 t4 j5   |  _9 d |  _: t4 j5   |  _; i  |  _< g  |  _= g  |  _> g  d j?   D] } t |  ^ q }	 i |  j d 6|  j d  6|  j d! 6|  j d" 6|  j d# 6|	 d$ 6}
 |  j  |  j |
  d  S(%   Ni   i    i  u   the zero objectu   wbt   return_openedu   datapathu   fontsu   pdfcorefontss	   %PDF-1.4
s   % 
u   rootu   pagesu   extended graphics statesu   tiling patternsu   Gouraud trianglesu   external objectsu	   resourcesu   Catalogu   Typeu   Pagesu   SOURCE_DATE_EPOCHt   tzinfou$   matplotlib %s, http://matplotlib.orgu   Creatoru   matplotlib pdf backend %su   Produceru   CreationDatec         S` s+   i  |  ]! \ } } | d  k	 r | |  q S(   N(   Re   (   R   t   kt   v(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pys
   <dictcomp>  s   	 	u   PDF Text ImageB ImageC ImageIu   Fontu   XObjectu	   ExtGStateu   Patternu   Shadingu   ProcSet(@   t
   nextObjectt	   xrefTableR<   t   passed_in_file_objectRe   t   original_file_liket	   tell_baseR   t   to_filehandlet   TrueR   t   IOErrorR   t   ost   pathR1   R   t   _core14fontdirR   t   currentstreamR{   t   reserveObjectt
   rootObjectt   pagesObjectt   pageListt
   fontObjectt   alphaStateObjectt   hatchObjectt   gouraudObjectt   XObjectObjectt   resourceObjectRb   R   t   getenvR   t   utcfromtimestampt   intt   replaceR)   t   todayR   t   infoDictR   t   itemst	   fontNamest   nextFontt   dviFontInfot   _texFontMapt   type1Descriptorst   used_characterst   alphaStatest   nextAlphaStatet   collectionst   OrderedDictt   hatchPatternst	   nextHatcht   gouraudTrianglest   _imagest	   nextImaget   markerst   multi_byte_charprocst   pathst   pageAnnotationst   split(   Rx   t   filenamet   metadataR   t   openedt   roott   source_date_epocht   source_dateR   t   procsetst	   resources(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy     s    																							"




c         C` s  |  j    | | |  _ |  _ |  j d  } i t d  d 6|  j d 6|  j d 6d d d | d | g d 6| d	 6i t d
  d 6t d  d 6t d  d 6d
 6|  j d 6} |  j d  } |  j | |  |  j	 j
 |  |  j | j |  j d   |  j t j d t j  g  |  _ d  S(   Nu   page contentsu   Pageu   Typeu   Parentu	   Resourcesi    iH   u   MediaBoxu   Contentsu   Groupu   Transparencyu   Su	   DeviceRGBu   CSu   Annotsu   pageu   length of content streamu   round(   t	   endStreamt   widtht   heightR  Rb   R  R  R)  R   R	  R0   t   beginStreamRw   t   outputt   GraphicsContextPdft
   joinstylesR   R   (   Rx   R4  R5  t   contentObjectt   thePaget
   pageObject(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   newPage  s&    


ii    c         C` sa   i t  d  d 6t  d  d 6| d 6| d 6} |  j d  } |  j | |  |  j j |  d  S(   Nu   Annotu   Typeu   Textu   Subtypeu   Contentsu   Rectu
   annotation(   Rb   R  R   R)  R0   (   Rx   t   textt   positionRectt   theNotet   annotObject(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   newTextnote1  s    
c      
   C` s  |  j    |  j   |  j |  j d   t j |  j  D  |  j   |  j   d   t j |  j	  D } x, t j |  j
  D] } | d | | d <q Wx* t j |  j  D] \ } } | | | <q Wx6 |  j D]+ \	 } } } } } }	 }
 } } | | | <q W|  j |  j |  |  j   |  j   |  j   |  j |  j i t d  d 6|  j d 6t |  j  d 6 |  j   |  j   |  j   d	 S(
   u>   Write out the various deferred objects and the pdf end matter.c         S` s!   i  |  ] } | d  | d  q S(   i   i    (    (   R   Rt   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pys
   <dictcomp>C  s   	 c         S` s"   i  |  ] \ } } } | |  q S(    (    (   R   t   imageR   t   ob(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pys
   <dictcomp>G  s   	 i   i    u   Pagesu   Typeu   Kidsu   CountN(   R3  t
   writeFontsR   R  RU   t
   itervaluesR  t   writeHatchest   writeGouraudTrianglesR$  R&  t	   iteritemsR'  R(  R  t   writeImagest   writeMarkerst   writePathCollectionTemplatesR  Rb   R	  R/   t   writeInfoDictt	   writeXreft   writeTrailer(   Rx   t   xobjectst   tupR   R   R  t   transRD  R1   t   capt   paddingt   filledt   stroked(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   finalize<  s4    



(





c         C` s_   |  j    |  j r# |  j j   n8 |  j d k	 rN |  j j |  j j    n  |  j j   d S(   u)   Flush all buffers and free all resources.N(	   R3  R   R   R   R   Re   R{   R   t   close(   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRX  ]  s    
	c         C` s6   |  j  d  k r" |  j j |  n |  j  j |  d  S(   N(   R  Re   R   R{   (   Rx   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR{   h  s    c         G` s=   |  j  t g  | D] } t |  ^ q   |  j  d  d  S(   Ns   
(   R{   R:   RK   (   Rx   R   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR7  n  s    ,c         C` s4   |  j  d  k s t  t | | |  | |  |  _  d  S(   N(   R  Re   R=   R   (   Rx   Rw   R/   R   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR6  r  s    c         C` s,   |  j  d  k	 r( |  j  j   d  |  _  n  d  S(   N(   R  Re   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR3  v  s    c         C` s   t  | t j  r | } n^ t d rm t | d d d |  j } | d	 k ry t d d d d |  j } qy n t |  } |  j j |  } | d	 k r t	 d |  j
  } | |  j | <|  j
 d 7_
 t j d | |  n  | S(
   u   
        Select a font based on fontprop and return a name suitable for
        Op.selectfont. If fontprop is a string, it will be interpreted
        as the filename of the font.
        u   pdf.use14corefontst   fontextu   afmt	   directoryu	   Helveticau   F%di   u   Assigning font %s = %rN(   RL   RU   t   string_typesR   R   R  Re   R  t   getRb   R  t   _logt   debug(   Rx   t   fontpropR+  t   Fx(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   fontName{  s     	
c         C` s4   |  j  d  k r- t j t j d   |  _  n  |  j  S(   Nu
   pdftex.map(   R  Re   t   dvireadt
   PsfontsMapt   find_tex_file(   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt
   texFontMap  s    c         C` s   |  j  j | j  } | d k	 r( | j S|  j | j } | j d k rh t d j | j	 | j    n  t
 d |  j  } |  j d 7_ t j d | | j  t d | d | d | j d | j	 d	 | j d
 | j  |  j  | j <| S(   u   
        Given a dvi font object, return a name suitable for Op.selectfont.
        This registers the font information in self.dviFontInfo if not yet
        registered.
        uN   No usable font file found for {} (TeX: {}); the font may lack a Type-1 versionu   F%di   u   Assigning font %s = %s (dvi)t   dvifontt   pdfnamet   fontfilet   basefontt   encodingfilet   effectsN(   R  R\  t   texnameRe   Rg  Re  R+  RQ   Ro   t   psnameRb   R  R]  R^  R   t   encodingRk  (   Rx   Rf  t   dvi_infot   psfontRg  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   dviFontName  s&    			c   	      C` sB  i  } xO t  |  j j    D]8 \ } } | j } t j d |  |  j |  | | <q Wx t  |  j  D] } |  j | } t j d |  | j d  r t j d  |  j	 |  | | <qh t j d  t
 |  \ } } |  j j |  } | d  k	 rh t | d  rh |  j | | d  | | <qh qh W|  j |  j |  d  S(   Nu"   Embedding Type-1 font %s from dvi.u   Embedding font %s.u   .afmu   Writing AFM font.u   Writing TrueType font.i   (   Ra   R  R  Rg  R]  R^  t   _embedTeXFontR  t   endswitht   _write_afm_fontR   R  R\  Re   R/   t   embedTTFR   R
  (	   Rx   t   fontst   dvinamet   infoR`  R+  t   realpatht   stat_keyt   chars(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRE    s"    "	!c         C` s   t  | d   } t |  } Wd  QX| j   } i t d  d 6t d  d 6t |  d 6t d  d 6} |  j d	  } |  j | |  | S(
   Nu   rbu   Fontu   Typeu   Type1u   Subtypeu   BaseFontu   WinAnsiEncodingu   Encodingu   font dictionary(   t   openR   t   get_fontnameRb   R  R   (   Rx   R+  R   t   fontt   fontnamet   fontdictt   fontdictObject(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRt    s    c         C` s0  t  j d | j j | j  |  j d  } |  j | | j j  |  j d  } i t d  d 6t d  d 6d d	 6t	 | j j  d
 d 6| d 6} | j
 d  k	 rt j | j
  } g  | D] } t |  ^ q } d g | } i t d  d 6| d 6| d <n  | j d  k rLt  j d | j  t | j  | d <|  j | |  | St j | j  } | j r|| j | j  } n  t | j d  | d <| j j d d  | j j d d  f }	 |  j j | j |	 f  }
 |
 d  k r|  j | | j  }
 |
 |  j | j |	 f <n  |
 | d <|  j | |  | S(   Nu#   Embedding TeX font %s - fontinfo=%su   font widthsu   font dictionaryu   Fontu   Typeu   Type1u   Subtypei    u	   FirstChari   u   LastCharu   Widthsu   Encodingu   Differencesu   Because of TeX configuration (pdftex.map, see updmap option pdftexDownloadBase14) the font %s is not embedded. This is deprecated as of PDF 1.5 and it may cause the consumer application to show something that was not intended.u   BaseFontu   FontNameu   slantg        u   extendg      ?u   FontDescriptor(   R]  R^  Rf  Rl  t   __dict__R  R   t   widthsRb   R/   Rj  Re   Rb  t   EncodingRh  t   warningRi  t	   type1fontt	   Type1FontRk  t	   transformt   propR\  R  t   createType1Descriptor(   Rx   t   fontinfot   widthsObjectR  R  t   enct   cht   differencesArrayt   t1fontRk  t   fontdesc(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRr    sJ    	

	
c   
      C` s  |  j  d  } |  j  d  } | j d } | j d } d } | rQ | d O} n  | d O} | rn | d O} n  t |  } i t d	  d
 6t | j d  d 6| d 6| j d 6| d 6| j d 6| j d 6d d 6d d 6| d 6| j d d 6d d 6}	 |  j | |	  |  j | j	 d  i t | j d  d 6t | j d  d 6d d 6 |  j j | j d  |  j j | j d  |  j   | S(   Nu   font descriptoru	   font fileu   ItalicAngleu   isFixedPitchi    i   i   i   u   FontDescriptoru   Typeu   FontNameu   Flagsu   FontBBoxu   Ascentu   Descenti  u	   CapHeighti  u   XHeightu   FontFileu
   FamilyNameu
   FontFamilyi2   u   StemVu   Length1u   Length2u   Length3i   i   i@   (   R  R  R   Rb   t   bboxt   ascendert	   descenderR   R6  Rw   Re   R/   t   partsR  R{   R3  (
   Rx   R  Rh  t   fontdescObjectt   fontfileObjectt   italic_anglet   fixed_pitcht   flagst   ft2fontt
   descriptor(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    sB    





c         C` s*   d t  j j t  j j |   d | f S(   Nu   %s-%si    (   R  R  t   splitextt   basename(   Rx   R+  t   symbol_name(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   _get_xobject_symbol_name]  s    uO  /CIDInit /ProcSet findresource begin
12 dict begin
begincmap
/CIDSystemInfo
<< /Registry (Adobe)
   /Ordering (UCS)
   /Supplement 0
>> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000> <ffff>
endcodespacerange
%d beginbfrange
%s
endbfrange
endcmap
CMapName currentdict /CMap defineresource pop
end
endc         ` s  t    } t d } | j t d         f d   }      f d   } | j   } y | d$ j d   Wn$ t k
 r | d% j d   n X j d d   t    | j	 d  p i d d 6d d 6} | j	 d  p i d& d 6}	 | j
 }
 | j } d } t } |
 t @r4| d' O} n  | rG| d( O} n
 | d) O} | t @rh| d* O} n  i
 t d  d 6 d 6| d 6g  | j D] }   | d t ^ qd 6  | j d t d 6  | j d t d 6  | d d t d 6  | d  d 6|	 d d d 6d d  6} t   rMd! } t j d" t j j    n  | d	 k ri| | | |  S| d! k r| | | |  Sd# S(+   u9   Embed the TTF font from the named file into the document.u   pdf.fonttypec         S` sE   |  | d } | r! t  j |  S| d k  r7 t |  St |  Sd S(   u1   Convert font coordinates to PDF glyph coordinatesi  i    N(   RN   t   roundR
   R   (   R9   t   upet   nearestR   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   cvt}  s    
c         ` s   j  d  }  j  d  }  j  d  }  j  d  } g  } d( \ } }	 g   j D] }
  |
 d t ^ qX } i t d  d	 6 d
 6| d 6|	 d 6| d 6t d  d 6| d d 6| d 6d d d d d d g d 6| d 6i t d  d	 6| d 6d 6| d 6} d d l m   t   d  r7  f d    n   f d       f d   } g  t | |	 d  D] } | |  ^ qo} t |  | d <g  } g  } t	   } xn | D]f } | }  j
 |  } | j |   j |  } | d k r| j | | f  q| j |  qW| j   d  } xM | D]E \ } } | | d k r`| j |  n  | j t |   | } q4Wt j  j t j    |  } i  } x t |  D] } | | } i t |  d! 6} | | k r$t d"  | d	 <t d#  | d <| | d$ <| | j d%  d& } n   j  d'  }  j | j d) |   j j |   j   | | k r j  |  } |  j | <q| | | <qW j | |   j | |   j | |   j | |  | S(*   u5   The Type 3-specific part of embedding a Truetype fontu   font widthsu   font descriptoru   font dictionaryu   character procsi    i   R  u   Fontu   Typeu   BaseFontu	   FirstCharu   LastCharu   FontDescriptoru   Type3u   Subtypeu   FontNameu   Nameu   FontBBoxgMbP?u
   FontMatrixu	   CharProcsu   Encodingu   Differencesu   Widths(   t   cp1252u   decoding_mapc         ` s     j  |  p d S(   Ni    (   t   decoding_map(   t   charcode(   R  (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   decode_char  s    c         ` s   t    j |   S(   N(   R   t   decoding_table(   R  (   R  (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s    c         ` s2    |   }  j  | d t t Bj }   |  S(   NR  (   t	   load_charR"   R#   t   horiAdvance(   R  R8   R4  (   R  R  R~  (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   get_char_width  s    i   u   MaxWidthiu   Lengthu   XObjectu   Formu   BBoxt   d1i   u   charProc(   i    i   N(    R  R  R<   Rb   t	   encodingsR  RJ   t   ranget   maxt   sett   get_char_indexR0   t   get_glyph_namet   addt   sortR,   t   get_pdf_charprocsRR   t   syst   getfilesystemencodingRa   R/   t   findR6  Rw   Re   R  R{   R3  R  R'  R   (   R~  t
   charactersR  R  R  R  t   charprocsObjectR  t	   firstchart   lastcharR   R  R  R  R  R  t	   glyph_idst   differencest   multi_byte_charsR   t   ccodet   gindt
   glyph_namet   last_cR   t   rawcharprocst	   charprocst   charnamet   streamt   charprocDictt   charprocObject(   R  R+  t   ps_nameRx   (   R  R  R~  s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   embedTTFType3  s    (
)	




c   !      ` s   j  d  }  j  d  }  j  d  }  j  d  }  j  d  }  j  d  }  j  d  }	 i t d  d	 6t d
  d 6 d 6i d d 6d d 6d d 6d 6| d 6| d 6| d 6}
 i t d  d	 6t d  d 6 d 6t d  d 6| g d 6|	 d 6} | | d < j  d  }  j | j  j  d  i | d 6 t  d   S } d } xC t r| j d!  } | sPn  | t |  7}  j j	 |  q`WWd" QX j
    j | |  d# g d$ } g  } d } x | D]~ } | } |  j |  } |  j | d% t t B} | j |   | j  f  | d$ k  rRt |  | | <n  t | |  } qW| j   | | d&  } d' } g  } d } g  } x | D] \ } } | | d& k r| j |  | j | g  | j | | g  n | d( j |  | | d( d& <t | |  } | } qWg  } x[ | D]S \ } } | j d) | | d* j g  t | | d&  D] } d+ | ^ qe f  q0W j t |  d, j |  f j d-  }  d. j |  j d/  }  j | j d" i t |  d0 6  j j	 |   j
    j |	 j d" i |  d0 6  j j	 |    j
   | | d1 < j | |
   j | |   j | |   j | |  | S(2   u6   The Type 42-specific part of embedding a Truetype fontu   font descriptoru   CID font dictionaryu   Type 0 font dictionaryu   CIDToGIDMap streamu   font file streamu   Type 0 widthsu   ToUnicode mapu   Fontu   Typeu   CIDFontType2u   Subtypeu   BaseFontu   Adobeu   Registryu   Identityu   Orderingi    u
   Supplementu   CIDSystemInfou   FontDescriptoru   Wu   CIDToGIDMapu   Type0u
   Identity-Hu   Encodingu   DescendantFontsu	   ToUnicodeu	   FontFile2u   decoded length of a fontu   length of font streamu   Length1u   rbi   Nu    i   R  i   iiu   <%04x> <%04x> [%s]u    u   <%04x>u   
u   asciiu    u   utf-16beu   Lengthu   MaxWidth(   R  Rb   R6  Rw   R|  R   t   readR/   R  R{   R3  R   R  R  R"   R#   R0   R  R   R  R  R1   R  t   _identityToUnicodeCMapRR   Re   (!   R~  R  R  R  t   cidFontDictObjectt   type0FontDictObjectt   cidToGidMapObjectR  t   wObjectt   toUnicodeMapObjectt   cidFontDictt   type0FontDictt   length1ObjectRh  t   length1R   t   cid_to_gid_mapR  t	   max_ccodeR   R  R  t   glypht
   last_ccodeR   t	   max_widtht   unicode_groupsR4  t   unicode_bfranget   startR   R   t   unicode_cmap(   R  R+  R  Rx   (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   embedTTFType42  s    



	


<	


i   i    i   u	   mac_romani   i	  u   utf-16beu   asciiu   replaceu   pcltu	   capHeightu   xHeightu   postu   italicAnglei   i   u   FontDescriptoru   Typeu   FontNameu   FlagsR  u   FontBBoxu   Ascentu   Descentu	   CapHeightu   XHeightu   ItalicAngleu   StemVi*   u[   %r can not be subsetted into a Type 3 font. The entire font will be embedded in the output.N(   i   i    i    i   (   i   i   i	  i   (   i    i    i   i   i    i@   (   R   R   t   units_per_EMR   t   get_sfntR   t   KeyErrorRR   Rb   t   get_sfnt_tablet
   face_flagst   style_flagsR<   R    R!   R  R  R  R   R]  R  R  R  R  (   Rx   R+  R  R~  t   fonttypeR  R  t   sfntt   pcltt   postt   fft   sfR  t   symbolicR   R  (    (   R  R+  R  Rx   s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRu  w  sX    
rx#		


)
	c         C` s   |  j  j | d  } | d k	 r) | d St d |  j  } |  j d 7_ | i t d  d 6| d d 6| d d 6f |  j  | <| S(	   u?   Return name of an ExtGState that sets alpha to the given value.i    u   A%di   u	   ExtGStateu   Typeu   CAu   caN(   R  R\  Re   Rb   R  (   Rx   t   alphat   stateR   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt
   alphaState  s    #c         C` s   | d  k	 rc | \ } } } | d  k	 r6 t |  } n  | d  k	 rQ t |  } n  | | | f } n  |  j j | d   } | d  k	 r | St d |  j  } |  j d 7_ | |  j | <| S(   Nu   H%di   (   Re   Rd   R!  R\  Rb   R"  (   Rx   t   hatch_stylet   edget   facet   hatcht   patternR   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   hatchPattern  s    c         C` s  t    } d } xt j |  j  D]\ } } |  j d  } | | | <i g  d j   D] } t |  ^ qW d 6} |  j | j d  i	 t d  d 6d d 6d d	 6d d
 6d d | | g d 6| d 6| d 6| d 6d d d d d |  j
 d g d 6 | \ } }	 }
 |  j | d | d | d t j  |	 d  k	 rs|  j |	 d |	 d |	 d t j d d | | t j t j 
 n  |  j t d t j  |  j |  j t j |
  t   j |  d t   |  j t j  |  j   q" W|  j |  j |  d  S(   Ng      R@u   hatch patternu   PDF Text ImageB ImageC ImageIu   Procsetsu   Patternu   Typei   u   PatternTypeu	   PaintTypeu
   TilingTypei    u   BBoxu   XStepu   YStepu	   ResourcesiH   u   Matrixi   u   hatch.linewidtht   simplify(   R_   RU   RI  R!  R  R*  Rb   R6  Rw   Re   R5  R7  R   R   R   R   R:   R   R   t   pathOperationsR(   R  R&   t   scaleR<   R   R3  R   R  (   Rx   t	   hatchDictt   sidelenR  R   RD  R   t   rest
   stroke_rgbt   fill_rgbR  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRG    s>    	
)	$

c         C` s6   t  d t |  j   } |  j j | | | f  | S(   Nu   GT%d(   Rb   R/   R#  R0   (   Rx   t   pointst   colorsR   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   addGouraudTriangles  s    c         C` s"  t    } x|  j D]\ } } } |  j d  } | | | <| j } | j | d | d d f  } | j | d | d d f  } t j | d d d }	 t j | d d d }
 d |
 |	 } |  j | j	 d  i d d	 6d
 d 6d d 6d d 6t d  d 6t d 6|	 d |
 d |	 d |
 d d d d d d d g
 d 6 t j | d | d f d t d  t d  f t d  t d  d f t d  t d  d f g } d | d <| |	 | | d <| d  d   d  d  f d | d <|  j | j    |  j   q W|  j |  j |  d  S(   Nu   Gouraud trianglei    i   i   i   t   axisi   I    u   ShadingTypei    u   BitsPerCoordinateu   BitsPerComponentu   BitsPerFlagu	   DeviceRGBu
   ColorSpaceu	   AntiAliasu   Decodet   dtypeu   flagsu   u1u   pointsu   >u4u   colorsi   g     o@i   i   (   i   (   i   (   R_   R#  R  t   shapet   reshapeRN   t   minR  R6  Rw   Re   Rb   R   t   emptyt   strR{   t   tostringR3  R   R  (   Rx   t   gouraudDictR   R   R  RD  R  t   flat_pointst   flat_colorst
   points_mint
   points_maxt   factort	   streamarr(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRH    s@    	
	!!	
!
$c         C` s   |  j  j t |  d  } | d k	 r/ | d St d |  j  } |  j d |  j  } |  j d 7_ | | | f |  j  t |  <| S(   u=   Return name of an image XObject representing the given image.i   u   I%du   image %dN(   R$  R\  Rw   Re   Rb   R%  R  (   Rx   RC  t   entryR   RD  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   imageObject!  s    c         C` s  | j  d  \ } } | d d d  } | j d k rE | | | d f S| d d  d d  d d  f } t j | d d } | j  d d k r | d d  d d  d f d
 } t j | d	 k  r d } q t j | d d } n d } | | | | f Sd S(   u   
        Unpack the image object im into height, width, data, alpha,
        where data and alpha are HxWx3 (RGB) or HxWx1 (grayscale or alpha)
        arrays, except alpha is None if the image is fully opaque.
        i   Nii   t   orderu   Ci   .i   (   .N(   R  t   ndimRe   RN   t   arrayt   all(   Rx   t   imR   R   t   rgbR  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   _unpack.  s    %#	c         C` s  t    } t j | |  | j d  d } t d  } x t r| j |  } | d k sb t  t j	 d t
 |   \ } } | d k r t |  } | j |  } | | k s t  |  j j t
 |   | | 7} n  | d k r Pn | j | d  | j d d  q; Wd S(	   uo   
        Write the image *data* into the pdf file using png
        predictors with Flate compression.
        i   i    s   !L4st   IDATt   IENDi   i   N(   R   R+   t	   write_pngt   seekt	   bytearrayR   t   readintoR=   t   structt   unpackR\   R  R{   (   Rx   R   t   buffert   writtent   headerR   R9   Rp   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   _writePngF  s&    		c   	      C` s   i t  d  d 6t  d  d 6| d 6| d 6t  | r: d n d  d	 6d
 d 6} | ra | | d <n  t d r i d d 6| r d n d d 6| d 6} n d } |  j | |  j d  | d | | r |  j |  n |  j j | j    |  j	   d S(   u  
        Write the image *data* of size *height* x *width*, as grayscale
        if *grayscale* is true and RGB otherwise, as pdf object *id*
        and with the soft mask (alpha channel) *smask*, which should be
        either None or a *height* x *width* x 1 array.
        u   XObjectu   Typeu   Imageu   Subtypeu   Widthu   Heightu
   DeviceGrayu	   DeviceRGBu
   ColorSpacei   u   BitsPerComponentu   SMasku   pdf.compressioni
   u	   Predictori   i   u   Colorsu   Columnsu   length of image streamR   N(
   Rb   R   Re   R6  R  R&  R  R{   R
  R3  (	   Rx   R   R5  R4  t	   grayscaleRw   t   smaskRq   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   _writeImga  s.    



c   	      C` s   x t  j |  j  D] \ } } } |  j |  \ } } } } | d  k	 rw |  j d  } |  j | | | t | j  n d  } |  j | | | t	 | j |  q Wd  S(   Nu   smask(
   RU   RF  R$  R  Re   R  R)  R   Rw   R<   (	   Rx   t   imgR   RD  R5  R4  R   t   adatat   smaskObject(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRJ    s    "c         C` s   |  j  | | d t } t |  t |  t |  | | f }	 |  j j |	  }
 |
 d k r t d t |  j   } |  j	 d t |  j   } | j
 |  } | | | | g |  j |	 <n' |
 d | k  r | |
 d <n  |
 d } | S(   u<   Return name of a marker XObject representing the given path.R  u   M%du	   marker %dii    N(   R  R<   Rd   RT   R&  R\  Re   Rb   R/   R  t   get_extents(   Rx   R  RR  R:   R   t   lwt	   joinstylet   capstylet   pathopsRs   R6   R   RD  R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   markerObject  s    '
c   
      C` s   x t  j |  j  D] \ \ } } } } } \ } } } }	 | j |	 d  } |  j | j d  i t d  d 6t d  d 6t | j	  d 6 |  j
 t j | t j  |  j
 t j | t j  |  j
 |   |  j
 t j | |   |  j   q Wd  S(   Ng      ?u   XObjectu   Typeu   Formu   Subtypeu   BBox(   RU   RI  R&  t   paddedR6  Rw   Re   Rb   Rc   t   extentsR7  R8  R9  R   R   t	   capstylesR   t
   paint_pathR3  (
   Rx   R1  R:   R   R/  R0  R   RD  R  R.  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRK    s    7	
c   	   
   C` sp   t  d t |  j   } |  j d t |  j   } |  j j | | | | | j   | j   | | | f	  | S(   Nu   P%du   path %d(   Rb   R/   R(  R  R0   t   get_joinstylet   get_capstyle(	   Rx   t   gcR  RR  RT  RU  RV  R   RD  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   pathCollectionObject  s    	c      
   C` sC  x<|  j  D]1\	 } } } } } } } } }	 |  j | | d t }
 | j |  } t j t j | j   s d d d d g } n | j |  } t	 | j  } |  j
 | j d  i t d  d 6t d  d 6| d 6 |  j t j | t j  |  j t j | t j  |  j |
   |  j t j | |	   |  j   q
 Wd  S(   NR  i    u   XObjectu   Typeu   Formu   Subtypeu   BBox(   R(  R  R<   R-  RN   R  RP   R4  R3  Rc   R6  Rw   Re   Rb   R7  R8  R9  R   R   R5  R   R6  R3  (   Rx   R   R  RR  RD  R/  R0  RT  RU  RV  R1  R  R4  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRL    s$    (	
c         C` sR   t  t j |  | | | | d t j j t j j d t j j t j j g t	   g S(   Ni   t    (
   R   R*   t   convert_to_stringR   R   R   R   R   R   R   (   R  R  R   R  t   sketch(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s
    	*c         C` sp   | r2 d d |  j  d |  j d f } | j } n d  } t } |  j | | | d | d | } |  j |   d  S(   Ng        iH   R  R=  (   R4  R5  t   should_simplifyRe   R<   R  R7  (   Rx   R  R  R   R=  R  t   cmds(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   writePath  s     	u    c         C` s;   |  j  } |  j  d 7_  |  j j d d | g  t |  S(   u   Reserve an ID for an indirect object.
        The name is used for debugging in case we forget to print out
        the object with writeObject.
        i   i    N(   R   R   R0   Re   Rv   (   Rx   R   Rw   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s    	c         C` s%   |  j  j   |  j |  j | d <d  S(   Ni    (   R   R   R   R   (   Rx   Rw   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR     s    c         C` s$   |  j  | j  | j | |   d  S(   N(   R   Rw   R{   (   Rx   t   objectR|   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR     s    c         C` s   |  j  j   |  j |  _ |  j d |  j j d   d } t } x |  j D] \ } } } | d k r t
 d | | f d t j t } nD | d k r d } n d } d	 | | | f } |  j | j d   | d
 7} qL W| r t d   n  d S(   u   Write out the xref table.u
   xref
0 %d
u   asciii    u   No offset for object %d (%s)R}   u   the zero objectu   fu   nu   %010d %05d %s 
i   u   Indirect object does not existN(   R   R   R   t	   startxrefR{   R   RR   R<   R   Re   t   printR  t   stderrR   R=   (   Rx   R7   t   borkent   offsett
   generationR   Rs   R>  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRN    s"    
		c         C` s   d   } d   } d   } i	 | d 6| d 6| d 6| d 6| d 6| d	 6| d
 6| d 6| d 6} x\ |  j  D]Q } | | k r t j d |  qj | | |  j  |  sj t j d |  qj qj W|  j d  |  _ |  j |  j |  j   d S(   u8   Write out the info dictionary, checking it for good formc         S` s   t  |  t j  S(   N(   RL   RU   R[  (   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   is_string_like  s    c         S` s   t  |  t  S(   N(   RL   R   (   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   is_date  s    c         S` s   t  |  t  o |  j d k S(   Nu   Trueu   Falseu   Unknown(   u   Trueu   Falseu   Unknown(   RL   Rb   R   (   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   <lambda>  s   u   Titleu   Authoru   Subjectu   Keywordsu   Creatoru   Produceru   CreationDateu   ModDateu   Trappedu   Unknown infodict keyword: %su!   Bad value for infodict keyword %su   infoN(   R  t   warningst   warnR  t
   infoObjectR   (   Rx   RH  RI  t   check_trappedt   keywordsR   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRM    s&    			

c         C` s_   |  j  d  |  j  t i |  j d 6|  j d 6|  j d 6  |  j  d |  j j d   d S(   u   Write out the PDF trailer.s   trailer
u   Sizeu   Rootu   Infou   
startxref
%d
%%%%EOF
u   asciiN(   R{   RK   R   R  RM  RB  RR   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRO  3  s    	
	(0   R~   R   R   Re   Ry   R=  RB  RW  RX  R{   R7  R6  R3  Ra  t   propertyRe  Rq  RE  Rt  Rr  R  R  R  Ru  R  R  RG  R  RH  R  R  R&  R)  RJ  R2  RK  R:  RL  R   R  R<   R@  R  R   R   RN  RM  RO  (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR     sX   e		!					
				;	B		 9			&		&			#									t   RendererPdfc           B` s  e  Z e d   Z d   Z d   Z d d  Z d   Z d   Z	 d   Z
 d   Z d   Z d d	  Z d d
  Z d   Z d d  Z d   Z d   Z d d d d  Z d   Z d d d  Z d   Z e d d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   i2   c         C` sS   t  j |   | |  _ | |  _ | |  _ |  j   |  _ t d  |  _ | |  _	 d  S(   Nu   Pdf(
   R   Ry   R5  R4  R}   t   new_gcR9  R%   t   mathtext_parsert	   image_dpi(   Rx   R}   RT  R5  R4  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy   C  s    			c         C` s   |  j  j |  j j     d  S(   N(   R}   R7  R9  RW  (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRW  L  s    c         C` s  t  | d d	  } | | _ t  | d d
  } | j   d  k rU | j d d t n  | j rv | j | j f | _ nQ | d  k s t	 |  d k  r | j
 d d f | _ n | j
 d | d f | _ |  j j |  } | r |  j j |   n  | | _ | | _ d  S(   Nu
   _fillcolorg        u   _effective_alphasg      ?i    t   isRGBAi   i   (   g        g        g        (   g      ?g      ?(   i    i    i    i    (   t   getattrt
   _fillcolort   get_rgbRe   t   set_foregroundR   t   _forced_alphat   _alphat   _effective_alphasR/   t   _rgbR9  t   deltaR}   R7  (   Rx   R9  t	   fillcolort	   orig_fillt   orig_alphasR^  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   check_gcO  s    			c         C` s   t  | t j  r | } n	 | j } t |  \ } } |  j j j | | t   f  } | d j	 g  | D] } t
 |  ^ qh  d S(   uD   Keeps track of which characters are required from
        each font.i   N(   RL   RU   R[  t   fnameR   R}   R  t
   setdefaultR  R   R   (   Rx   R~  R8   Rc  Ry  Rz  R  R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   track_charactersk  s    		c         C` s\   xU t  j |  D]D \ } \ } } |  j j j | | t   f  } | d j |  q Wd  S(   Ni   (   RU   RI  R}   R  Rd  R  R   (   Rx   R   Rz  Ry  t   charsetR  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   merge_used_charactersw  s    "c         C` s   |  j  d S(   Ng      R@(   RT  (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   get_image_magnification}  s    c         C` s   t  S(   uA   
        pdf backend support arbitrary scaling of image.
        (   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   option_scale_image  s    c         C` s	   t  d S(   ul   
        return whether to generate a composite image from multiple images on
        a set of axes
        u   image.composite_image(   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   option_image_nocomposite  s    c         C` sO  | j  d  \ } } | d k s+ | d k r/ d  S| d  k rK | j d  n  |  j |  d | |  j } d | |  j } |  j j |  } | d  k r |  j j t j	 | d d | | | t j
 | t j t j  nv | j   j   \ }	 }
 } } } } |  j j t j	 d d d d | | t j
 |	 |
 | | | | t j
 | t j t j  d  S(   Ni   i    g      ?g      R@i   (   R  Re   t	   set_alphaRb  RT  R}   R  R7  R   R   R   R   R   t   frozent	   to_values(   Rx   R9  R   t   yR  R  R   R   t   imobt   tr1t   tr2t   tr3t   tr4t   tr5t   tr6(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt
   draw_image  s$    $c         C` sd   |  j  | |  |  j j | | | d  k o: | j   d  k | j    |  j j |  j j    d  S(   N(	   Rb  R}   R@  Re   t   get_hatch_patht   get_sketch_paramsR7  R9  t   paint(   Rx   R9  R  R  t   rgbFace(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   draw_path  s    	c   $      C` s  t  } t j |  } t j |  } t |  sF t } | j   } nB t j | d  d   d f | d k  r | d d k } n t } t |  s t } ni t j t j |	  d k  r t } nB t j | d  d   d f | d k  r | d	 d k } n t } t |  d k r+t | d j  n d } |  j | | | | |  } | | d | | k  } | sr| rt	 j
 |  | | | | | | | | |	 |
 | | |  St j |	  } g  } x] t |  j | | |   D]@ \ } \ } } |  j j | | | | | |  } | j |  qW|  j j } | |  j j     d
 \ } } x |  j | | | | | | | | |	 |
 | | |  D]o \ } } } }  }! |  j |  |!  | | | | }" }# | d d d d |" |# t j | t j 	 | | } } qzW| |  j j     d  S(   Ni   i    g        i   i   (   i    i   (   i    i   (   i    i   (   i    i   (   i    i    (   R   RN   t   asarrayR/   R<   t	   get_hatchR  t   verticest   _iter_collection_uses_per_pathR   t   draw_path_collectionR  R.   t   _iter_collection_raw_pathsR}   R:  R0   R7  R9  t   pusht   _iter_collectionRb  R   R   R   t   pop($   Rx   R9  t   master_transformR(  t   all_transformst   offsetst   offsetTranst
   facecolorst
   edgecolorst
   linewidthst
   linestylest   antialiasedst   urlst   offset_positiont   can_do_optimizationRU  RV  t   len_patht   uses_per_patht   should_do_optimizationRT  t
   path_codesR7   R  R  R   R7  t   lastxt   lastyt   xot   yot   path_idt   gc0Rz  t   dxt   dy(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s\    )		)+"		"
c         C` s  t  |  } t  |  } | | | | d k  rS t j |  | | | | | |  d  S|  j | |  | j |  }	 | j   }
 |  j j } |  j j | | |	 |
 |  j	 j
 | j   | j    } | t j  d \ } } x | j | d d d |  j j d |  j j d f d t D] \ } } t  |  r| d \ } } | d k  s| d k  s| |  j j d k s| |  j j d k rqn  | | | | } } | d d d d | | t j | t j 	 | | } } qqW| t j  d  S(	   Ni   i    R   iH   R  ii   (   i    i    (   R/   R   t   draw_markersRb  R:   R   R}   R7  R2  R9  t
   _linewidthR7  R8  R   R   t   iter_segmentsR4  R5  R<   R   R   R   (   Rx   R9  t   marker_patht   marker_transR  RR  Rz  t   len_marker_patht   usesR:   R   R7  t   markerR  R  R~  t   codeR   Rn  R  R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s:    		&,c         C` s,   |  j  | | j d  | j d  |  d  S(   Ni   i   i   i   (   i   i   i   (   i   i   i   (   t   draw_gouraud_trianglesR  (   Rx   R9  R   R  RR  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   draw_gouraud_triangle  s    c         C` s0  t  |  t  |  k s t  | j d k s3 t  | j d d k sL t  | j d d k se t  | j d k sz t  | j d d k s t  | j d d k s t  | j } | j | d | d d f  } | j |  } | j |  } |  j j | |  } |  j |  |  j j	 | t
 j  d  S(   Ni   i   i   i   i    (   R/   R=   R  R  R  R  R}   R  Rb  R7  R   R   (   Rx   R9  R   R  RR  R  t   tpointsR   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s    	!i    c         C` s   | | k o d k n r@ |  j  j | | | | t j  ne | d t } |  j  j t |  t |  t |  t |  | | t j  |  j  j d d t j  d  S(   Ni    g     f@(   R}   R7  R   R   R   R	   R   R   (   Rx   R   Rn  t   anglet   oldxt   oldyt   oldangle(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   _setup_textpos0  s    $c      
   C` s,  |  j  j | d |  \ } } }	 }
 } } |  j |  t d } | d t } |  j j t j  |  j j t	 |  t
 |  t
 |  t	 |  | | t j  |  j | | j  |  j j t j  d	 } d
 \ } } x |
 D] \ } } } } } } t |  rd } n | } | d k s*| d k r |  j | | d | |  | | } } | | f | k r|  j j |  j j |  | t j  | | f } n  |  j j |  j t |  |  t j  q q W|  j j t j  | d k rx |
 D] \ } } } } } } t |  rd } n | } | d k r| d k r|  j j |  |  j j t j d | d d d | | | t j  |  j j | |  } |  j j t |  t j  |  j j t j  qqWn  xK | D]C \ } } } } |  j j t j | | | | t j t j t j  qW|  j j t j  d  S(   NiH   u   pdf.fonttypeg     f@i    i*   i   i   gMbP?(   NN(   i    i    (   RS  t   parseRg  R   R   R}   R7  R   R   R	   R   R   Rb  R]  R   Re   R   R  Ra  R   t   encode_stringR   R   R   R  Rb   R   R   R   R:   (   Rx   R9  R   Rn  R8   R  R  R4  R5  t   descentt   glyphst   rectsR  t   global_fonttypet   at	   prev_fontR  R  t   oxt   oyR  t   fontsizet   numR  R  R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   draw_mathtext:  sX    *
4
	
	

	u   TeX!c	   $   	   C` s|  |  j    }	 | j   }
 |	 j | |
  } t j | d   } t t |   } Wd  QXd  g  } } x | j D] \ } } } } } | | k r |  j	 j
 |  } | d | | j g g 7} | } n  | d | | t j |  j d  g | | g g 7} qn Wd \ } } }
 x4| t |  d k  rA| | | d !\ } } | d d k rX| d }
 n | d | d k owd k n r4| d | d k r4| d | d } t |  d	 k  r| d
 d c | d
 d 7<| d c | d | d 7<n4 | d
 c | d |
 | d
 d g 7<| d | d <| | d =qn  | d 7} qWt   j |  j | |  } |  j | | j  |  j	 j t j  d \ } } } } x | D] } | d d k r|  j	 j | d | d t j  q| d d k r| j | d | d f  \ } } |  j | | | | |  | | } } t | d
  d k ri|  j	 j | d
 d t j  q|  j	 j | d
 t j  qt st  qW|  j	 j t j   |  j!   } | j" |  | j# d  t$ j% t$ j& t$ j& t$ j& t$ j' g }  x | j( D]w \ } } }! }" t$ | | g | |" | g | |" | |! g | | |! g d d g g |   }# |  j) | |# | | j  qWd  S(   NiH   u   fontu   textu   latin-1i    i   i   i   g?i   ig     @@(   i    i    N(   i    i    i    i    (*   t   get_texmanagert   get_size_in_pointst   make_dviRb  t   Dvit   nextt   iterRe   R>  R}   Rq  t   sizeRU   R   RR   R/   t   absR&   t
   rotate_degt	   translateRb  R]  R7  R   R   R   t   transform_pointR  R   R   R<   R=   R   RR  t   copy_propertiest   set_linewidthR(   t   MOVETOt   LINETOt	   CLOSEPOLYt   boxesR{  ($   Rx   R9  R   Rn  R8   R  R  t   ismatht   mtextt
   texmanagerR  t   dvifilet   dvit   paget   oldfontt   seqt   x1t   y1Rf  R  R4  Rg  R7   t   curxt   eltt   nxtRF  t   mytranst   curyR  R  t   boxgcR1  R   R   R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   draw_tex|  sj    	-8&$#!7c         C` s,   | d k r | j  d d  S| j  d d  S(   Ni   i   u   cp1252u   replaceu   utf-16be(   i   i   (   RR   (   Rx   R8   R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s    c	         ` sY   j  | | j  | r5  j |        S j    t d r~  j     j   \ }	 }
 } } d  nW  j     j     j	  d d t
 t d  t  j  r d  n   f d   }          f d   }          f d	   } |   \ } } | rK|   S| |  Sd  S(
   Nu   pdf.use14corefontsi   g        R  u   pdf.fonttypei*   c         ` s	  t  } g  } t d s   d k r t |  t  r t |   d k r t j |   }  x} |  D]u } t |  d k r{ d } n d } t |  r | d d | k r | d d j |  qZ | j | | g f  qZ Wt |  d k o | d d d k } q n  | | f S(   u   Determine if we should use the simple or woven method
            to output this text, and chunks the string into 1-byte and
            2-byte sections if necessary.u   pdf.use14corefontsi   i    i   i   i   i(	   R   R   RL   R\   R/   RU   RX   R   R0   (   R8   t   use_simple_methodt   chunksR   t	   char_type(   R  (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   check_simple_method  s    
.	 c           ` sj    j  j t j  j  j    t j   j       j  j  j    t j t j	  d S(   u%   Outputs text using the simple method.N(
   R}   R7  R   R   Ra  R   R  R  R   R   (    (   R  R  R  R  R8   Rx   R   Rn  (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   draw_text_simple  s    
c         ` s  g  |  D]! \ } } | d j  |  f ^ q }   j j t j    d t }  j j t |  t |  t |  t |    t j  x:d D]2} d } } | d k r  j j t j	  j j
    t j  n  x|  D]\ } } | d k rP| d k rP j | d d | d d   j j  j |   t j  | } n  d
 } xG| D]?}	 t |	  }
  j |
  } | d
 k	 r]| d k r;| d k r; j |  }  j j t j   j j d  d d d  | d t j   j j  j |  }  j j t |  t j   j j t j  n   j |
 d t } | d
 k	 rt j | | t  } n d } | } | | d | j d	 7} q]q]Wq W| d k r  j j t j  q q W j j t j  d
 S(   u   Outputs text using the woven method, alternating
            between chunks of 1-byte characters and 2-byte characters.
            Only used for Type 3 fonts.u    g     f@i   i   i    gMbP?R  g      P@g      @N(   i   i   (   R1   R}   R7  R   R   R   R	   R   R   R   Ra  R   R  R  R   Re   R   R  R  R  Rc  Rb   R   R   R  R#   t   get_kerningR$   t   linearHoriAdvanceR   (   R  R  R   t   modet   newxR  t
   chunk_typet   chunkt   lastgindR   R  R  R  R   R  t   kern(   R  R~  R  R  R  Rx   R   Rn  (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   draw_text_woven  sX    .4


	
		$(   Rb  R]  R  R  R   t   _get_font_afmt   get_str_bboxt   _get_font_ttfRe  t   set_textR#   R   Rc  (   Rx   R9  R   Rn  R8   R  R  R  R  R   R   R   R   R  R  R  R  R  (    (	   R  R~  R  R  R  R8   Rx   R   Rn  s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   draw_text  s*    
	
	$
$@c         C` sg  t  d rP |  j   } | j   } | j | | d |  \ } } } | | | f S| r |  j j | d |  \ } } } }	 }
 } n t  d r |  j |  } | j |  \ } } } } } | j   } | | d 9} | | d 9} | | d 9} ng |  j |  } | j	 | d d t
 | j   \ } } d
 } | | 9} | | 9} | j   } | | 9} | | | f S(   Nu   text.usetext   rendereriH   u   pdf.use14corefontsi  g        R  g      ?g      P@g      ?(   R   R  R  t   get_text_width_height_descentRS  R  R  t   get_str_bbox_and_descentR  R  R#   t   get_width_heightt   get_descent(   Rx   R8   R  R  R  R  R   R   R   R  R  R  R~  R   R   R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR  _  s0    
-



c         C` s   t  |  } |  j j |  } | d  k r t | d d d |  j j } | d  k ru t d d d d |  j j } n  |  j j |  } | d  k r t | d    } t |  } | |  j | <Wd  QXn  | |  j | <n  | S(   NRY  u   afmRZ  u	   Helveticau   rb(	   R   t   afm_font_cacheR\  Re   R   R}   R  R|  R   (   Rx   R  Rs   R~  R+  R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR  }  s     c         C` s<   t  |  } t |  } | j   | j | j   d  | S(   NiH   (   R   R   t   cleart   set_sizeR  (   Rx   R  R+  R~  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s
    
c         C` s   t  S(   N(   R<   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   flipy  s    c         C` s   |  j  j d |  j  j d f S(   Ng      R@(   R}   R4  R5  (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   get_canvas_width_height  s    c         C` s   t  |  j  S(   N(   R8  R}   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRR    s    N(   R~   R   R   R  Ry   RW  Re   Rb  Re  Rg  Rh  Ri  Rj  Rv  R{  R  R  R  R  R  R  R  R  R<   R  R  R  R  R  R  RR  (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRQ  @  s4   									G#		
	BQ						R8  c        
   B` s@  e  Z d    Z d   Z d   Z d   Z d   Z i d d 6d d 6d	 d
 6Z i d d 6d d 6d	 d 6Z d   Z	 d   Z
 d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d( e f d) e f d* e	 f d+ e f d, e
 f d- e f d. e f d/ e f d0 e f f	 Z d%   Z d&   Z d'   Z RS(1   c         C` s5   t  j |   d |  _ d |  _ | |  _ d  |  _ d  S(   Ng        g      ?(   g        g        g        (   g      ?g      ?(   R   Ry   RW  R\  R}   Re   t   parent(   Rx   R}   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy     s
    			c         C` s'   t  |  j  } | d =| d =t |  S(   Nu   fileu   parent(   R_   R  t   repr(   Rx   R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRz     s    c         C` sD   |  j  d k oC |  j d k oC t |  j  d k pC |  j d d k S(   u   
        Predicate: does the path need to be stroked (its outline drawn)?
        This tests for the various conditions that disable stroking
        the path, in which case it would presumably be filled.
        i    i   g        (   R  R[  R/   R]  (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR     s    c         G` sW   t  |  r | d } n	 |  j } |  j pV | d k	 oV t  |  d k pV | d d k S(   u   
        Predicate: does the path need to be filled?

        An optional argument can be used to specify an alternative
        _fillcolor, as needed by RendererPdf.draw_markers.
        i    i   g        N(   R/   RW  t   _hatchRe   (   Rx   t   argsRW  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR:     s    		c         C` s   t  j |  j   |  j    S(   uo   
        Return the appropriate pdf operator to cause the path to be
        stroked, filled, or both.
        (   R   R6  R:   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy    s    i    u   butti   u   roundi   u
   projectingu   miteru   bevelc         C` s   |  j  | t j g S(   N(   R5  R   R   (   Rx   t   style(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   capstyle_cmd  s    c         C` s   |  j  | t j g S(   N(   R9  R   R   (   Rx   R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   joinstyle_cmd  s    c         C` s   | t  j g S(   N(   R   R   (   Rx   R4  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   linewidth_cmd  s    c         C` s=   | \ } } | d  k r' g  } d } n  t |  | t j g S(   Ni    (   Re   Rc   R   R   (   Rx   t   dashesRF  t   dash(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   dash_cmd  s
    	c         C` s   |  j  j |  } | t j g S(   N(   R}   R  R   R   (   Rx   R  t   forcedt   effective_alphasR   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   alpha_cmd  s    c         C` s   | s; |  j  d  k	 r% |  j |  j   St d  t j g Sn@ | |  j  | f } |  j j |  } t d  t j | t j g Sd  S(   Nu	   DeviceRGBu   Pattern(	   RW  Re   t   fillcolor_cmdRb   R   R   R}   R  R   (   Rx   R  t   hatch_colorR  R   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   hatch_cmd  s    c         C` sc   t  d r g  S| d | d k o1 | d k n rG | d t j g St | d   t j g Sd  S(   Nu   pdf.inheritcolori    i   i   i   (   R   R   R   Rc   R   (   Rx   R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   rgb_cmd  s
    
(c         C` so   | d  k s t d r g  S| d | d k o= | d k n rS | d t j g St | d   t j g Sd  S(   Nu   pdf.inheritcolori    i   i   i   (   Re   R   R   R   Rc   R   (   Rx   R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR    s
    (c         C` s;   t  |  j  } | j |   |  j | _ | |  _ t j g S(   N(   R8  R}   R  R  R   R   (   Rx   R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR  	  s
    	c         C` s>   |  j  d  k	 s t  |  j |  j   |  j  j  |  _  t j g S(   N(   R  Re   R=   R  R   R   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR  
	  s    c         C` s  g  } xD |  j  |  j f | | f k rL |  j d k	 rL | j |  j    q	 W|  j  |  j f | | f k sz |  j d k r| j |  j    |  j  | k r | j | t j t j	 t j
 g  n  |  j | k r| j   \ } } | j t j | | d t t j	 t j
 g  qn  | S(   u5   Set clip rectangle. Calls self.pop() and self.push().R  N(   t	   _cliprectt	   _clippathR  Re   R`   R  R  R   R   R   R   t   get_transformed_path_and_affineR   R  R<   (   Rx   t   cliprectt   clippathR?  R  t   affine(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   clip_cmd	  s    !%u	   _cliprectu	   _clippathu   _alphau   _forced_alphau   _effective_alphasu	   _capstyleu
   _fillcoloru
   _joinstyleu
   _linewidthu   _dashesu   _rgbu   _hatchu   _hatch_colorc   
      C` s  g  } t  } x|  j D]|\ } } t  } x | D] } t |  |  } t | |  }	 y= | d k sn |	 d k r} | |	 k	 } n t | |	 k  } WnV t k
 r t j |  } t j |	  }	 | j |	 j k p t j	 | |	 k  } n X| r/ Pq/ q/ W| d k r| rt
 } n  | r | d k r-t
 } n  g  | D] } t | |  ^ q4}	 | j | |  |	   x* | D] } t |  | t | |   qlWq q W| S(   uy   
        Copy properties of other into self and return PDF commands
        needed to transform self into other.
        u   _hatchu   _hatch_coloru
   _fillcolorN(   u   _hatchu   _hatch_color(   u
   _fillcolor(   R<   t   commandsRV  Re   RT   RQ   RN   R|  R  t   anyR   R`   t   setattr(
   Rx   R   R?  t   fill_performedt   paramst   cmdt	   differentt   pt   ourst   theirs(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR^  2	  s8    		"$c         C` sP   t  j |  |  t | d |  j  } t | d |  j  } | |  _ | |  _ d S(   u5   
        Copy properties of other into self.
        u
   _fillcoloru   _effective_alphasN(   R   R  RV  RW  R\  (   Rx   R   R_  R  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR  X	  s    		c         C` s3   g  } x& |  j  d k	 r. | j |  j    q	 W| S(   uB   
        Make sure every pushed graphics state is popped.
        N(   R  Re   R`   R  (   Rx   R?  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRW  c	  s    (   u	   _cliprectu	   _clippath(   u   _alphau   _forced_alphau   _effective_alphas(   u	   _capstyle(   u
   _fillcolor(   u
   _joinstyle(   u
   _linewidth(   u   _dashes(   u   _rgb(   u   _hatchu   _hatch_color(   R~   R   Ry   Rz   R   R:   Ry  R5  R9  R  R   R  R  R  R
  R  R  R  R  R  R  R^  R  RW  (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR8    s<   																									&	t   PdfPagesc           B` st   e  Z d  Z d Z e d d  Z d   Z d   Z d   Z	 d   Z
 d d  Z d	   Z d
 d
 d d g d  Z RS(   ua  
    A multi-page PDF file.

    Examples
    --------

    >>> import matplotlib.pyplot as plt
    >>> # Initialize:
    >>> with PdfPages('foo.pdf') as pdf:
    ...     # As many times as you like, create a figure fig and save it:
    ...     fig = plt.figure()
    ...     pdf.savefig(fig)
    ...     # When no figure is specified the current figure is saved
    ...     pdf.savefig()

    Notes
    -----

    In reality :class:`PdfPages` is a thin wrapper around :class:`PdfFile`, in
    order to avoid confusion when using :func:`~matplotlib.pyplot.savefig` and
    forgetting the format argument.
    u   _fileu
   keep_emptyc         C` s"   t  | d | |  _ | |  _ d S(   u  
        Create a new PdfPages object.

        Parameters
        ----------

        filename : str
            Plots using :meth:`PdfPages.savefig` will be written to a file at
            this location. The file is opened at once and any older file with
            the same name is overwritten.
        keep_empty : bool, optional
            If set to False, then empty pdf files will be deleted automatically
            when closed.
        metadata : dictionary, optional
            Information dictionary object (see PDF reference section 10.2.1
            'Document Information Dictionary'), e.g.:
            `{'Creator': 'My software', 'Author': 'Me',
            'Title': 'Awesome fig'}`

            The standard keys are `'Title'`, `'Author'`, `'Subject'`,
            `'Keywords'`, `'Creator'`, `'Producer'`, `'CreationDate'`,
            `'ModDate'`, and `'Trapped'`. Values have been predefined
            for `'Creator'`, `'Producer'` and `'CreationDate'`. They
            can be removed by setting them to `None`.

        R,  N(   R   t   _filet
   keep_empty(   Rx   R+  R  R,  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRy   	  s    c         C` s   |  S(   N(    (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   __enter__	  s    c         C` s   |  j    d  S(   N(   RX  (   Rx   t   exc_typet   exc_valt   exc_tb(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   __exit__	  s    c         C` si   |  j  j   |  j  j   |  j   d k r\ |  j r\ |  j  j r\ t j |  j  j j	  n  d |  _  d S(   u_   
        Finalize this object, making the underlying file a complete
        PDF file.
        i    N(   R  RW  RX  t   get_pagecountR  R   R  t   removeR   R   Re   (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyRX  	  s    c         C` s
   |  j  j S(   u   
        Return a modifiable information dictionary object
        (see PDF reference section 10.2.1 'Document Information
        Dictionary').
        (   R  R  (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   infodict	  s    c         K` s   t  | t  sl | d k r* t j   } n t j |  } | d k r] t d j |    n  | j j	 } n  z2 | j } t
 |  | _ | j |  d d | Wd | | _ Xd S(   uQ  
        Saves a :class:`~matplotlib.figure.Figure` to this file as a new page.

        Any other keyword arguments are passed to
        :meth:`~matplotlib.figure.Figure.savefig`.

        Parameters
        ----------

        figure : :class:`~matplotlib.figure.Figure` or int, optional
            Specifies what figure is saved to file. If not specified, the
            active figure is saved. If a :class:`~matplotlib.figure.Figure`
            instance is provided, this figure is saved. If an int is specified,
            the figure instance to save is looked up by number.
        u   No figure {}Ro   u   pdfN(   RL   R   Re   R   t
   get_activet   get_fig_managerRQ   Ro   t   canvast   figuret   FigureCanvasPdft   savefig(   Rx   R+  t   kwargst   managert   orig_canvas(    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR-  	  s    	c         C` s   t  |  j j  S(   uP   
        Returns the current number of pages in the multipage pdf file.
        (   R/   R  R	  (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR%  	  s    ii    c         C` s   |  j  j | |  d S(   u   
        Add a new text note to the page to be saved next. The optional
        positionRect specifies the position of the new note on the
        page. It is outside the page per default to make sure it is
        invisible on printouts.
        N(   R  RB  (   Rx   R>  R?  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   attach_note	  s    (   u   _fileu
   keep_emptyN(   R~   R   R   R   R   Re   Ry   R   R$  RX  R'  R-  R%  R1  (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR  t	  s   				 	R,  c           B` s<   e  Z d  Z d Z d   Z i d d 6Z d   Z d   Z RS(   u   
    The canvas the figure renders into.  Calls the draw and print fig
    methods, creates the renderers, etc...

    Attributes
    ----------
    figure : `matplotlib.figure.Figure`
        A high-level Figure instance

    iH   c         C` s   d  S(   N(    (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   draw
  s    u   Portable Document Formatu   pdfc         C` s   d S(   Nu   pdf(    (   Rx   (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   get_default_filetype
  s    c   	   
   K` s*  | j  d d  } |  j j d  |  j j   \ } } t | t  rR | j } n t | d | j d d   } z | j
 | |  | j d d   } t |  j | | | t | | | |  d | } |  j j |  | j   t | t  s | j   n  Wd  t | t  r| j   n
 | j   Xd  S(   Nu   dpiiH   R,  u   metadatau   bbox_inches_restoret   bbox_inches_restore(   R\  R+  t   set_dpit   get_size_inchesRL   R  R  R   R  Re   R=  R   RQ  R2  RW  R3  RX  (	   Rx   R+  R.  RT  R4  R5  R}   t   _bbox_inches_restoreR  (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt	   print_pdf
  s(    	
(   R~   R   R   t	   fixed_dpiR2  t	   filetypesR3  R8  (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR,  	  s   
		t   FigureManagerPdfc           B` s   e  Z RS(    (   R~   R   (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR;  %
  s   t   _BackendPdfc           B` s   e  Z e Z e Z RS(    (   R~   R   R,  t   FigureCanvasR;  t   FigureManager(    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyR<  )
  s   (l   R   t
   __future__R    R   R   R   RU   R   RZ   R  R   t	   functoolsR   t   ioR   t   loggingt   mathR   R	   R
   R   R   R  R   R!  R  Ri   RK  R   t   numpyRN   t
   matplotlibR   R   R   t   matplotlib._pylab_helpersR   t   matplotlib.backend_basesR   R   R   R   R   t!   matplotlib.backends.backend_mixedR   t   matplotlib.cbookR   R   R   R   t   matplotlib.figureR   t   matplotlib.font_managerR   R   R   t   matplotlib.afmR   t   matplotlib.type1fontR  t   matplotlib.dvireadRb  t   matplotlib.ft2fontR    R!   R"   R#   R$   t   matplotlib.mathtextR%   t   matplotlib.transformsR&   R'   t   matplotlib.pathR(   t   matplotlib.datesR)   R*   R+   R,   t	   getLoggerR~   R]  R:   R   R]   R@   RK   RA  Rv   Rb   R   R   R_   t   _pdfopsRI  R   R   R6  R   R   RQ  R8  R  R,  R;  t   exportR<  (    (    (    s>   lib/python2.7/site-packages/matplotlib/backends/backend_pdf.pyt   <module>   s   "(("(2		\$!		Q      b0	