B
    }‹dÅ  ã               @   s@   d Z ddlmZ ddlmZ ddlmZ dZdd„ Zd	d
„ Z	dS )zText formatting for GWpy plots
é    )ÚrcParams)Úunitsé   )Útexz(Duncan Macleod <duncan.macleod@ligo.org>c             C   sP   t d }t| tjƒr|  d¡S t| ttfƒr:|r:t | ¡S |rHt 	| ¡S t
| ƒS )z|Format an input for representation as text

    This method is just a convenience that handles default LaTeX formatting
    ztext.usetexZlatex_inline)r   Ú
isinstancer   ZUnitBaseÚ	to_stringÚfloatÚintr   Zfloat_to_latexZlabel_to_latexÚstr)Zinput_Zusetex© r   ú[/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/gwpy/plot/text.pyr      s    


r   c             C   s(   | j s
dS |  | d¡¡}d| _ | ¡ S )a™  Set default label for an axis from a `~astropy.units.Unit`

    If the axis already has a label, this function does nothing.

    Parameters
    ----------
    axis : `~matplotlib.axis.Axis`
        the axis to manipulate

    unit : `~astropy.units.Unit`
        the unit to use for the label

    Returns
    -------
    text : `str`, `None`
        the text for the new label, if set, otherwise `None`
    NZlatex_inline_dimensionalT)ZisDefault_labelZset_label_textr   Zget_text)ZaxisÚunitÚlabelr   r   r   Údefault_unit_label.   s
    r   N)
Ú__doc__Z
matplotlibr   Zastropyr   Ú r   Ú
__author__r   r   r   r   r   r   Ú<module>   s   