+
     ]i  c                   s   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RI	H
t
HtHtHt ]P                  ! ]4      t ! R R]P"                  4      t ! R R]P&                  4      t ! R R	]P*                  4      t ! R
 R4      t]! 4       ;]P0                  ]&   ;]P0                  ]P4                  &   ;]P0                  ]&   ]P0                  ]P8                  &   R# )a  
Plotting of string "category" data: ``plot(['d', 'f', 'a'], [1, 2, 3])`` will
plot three points with x-axis values of 'd', 'f', 'a'.

See :doc:`/gallery/lines_bars_and_markers/categorical_variables` for an
example.

The module uses Matplotlib's `matplotlib.units` mechanism to convert from
strings to integers and provides a tick locator, a tick formatter, and the
`.UnitData` class that creates and stores the string-to-integer mapping.
)OrderedDictN)_apicbooktickerunitsc                   s`   a  ] tR t^t o ]R 4       t]R 4       t]R 4       t]R 4       tRt	V t
R# )StrCategoryConverterc                s   Vf   \        R4      h\        P                  V4       \        P                  ! \        P
                  ! V \        R7      4      pVP                  V4       \        P                  ! VP                  P                  \        .R7      ! V4      p\        P                  ! V 4      '       g   V# V^ ,          # )a  
Convert strings in *value* to floats using mapping information stored
in the *unit* object.

Parameters
----------
value : str or iterable
    Value or list of values to be converted.
unit : `.UnitData`
    An object mapping strings to integers.
axis : `~matplotlib.axis.Axis`
    The axis on which the converted value is plotted.

    .. note:: *axis* is unused.

Returns
-------
float or `~numpy.ndarray` of float
zMissing category information for StrCategoryConverter; this might be caused by unintendedly mixing categorical and numeric dataZdtype)Zotypes)
ValueErrorr   _validate_unitnp
atleast_1darrayobjectupdateZ	vectorize_mappingZ__getitem__floatr   Zis_scalar_or_string)valueunitaxisvaluesZss   &&&  :/usr/lib64/python3.14/site-packages/matplotlib/category.pyconvertZStrCategoryConverter.convert   s    * <    	++D1rxxV<=FLL22E7CFK11%88qBadB    c                s    \         P                  V 4       \        V P                  4      p\	        V P                  4      p\
        P                  ! W#R7      # )aL  
Set the default axis ticks and labels.

Parameters
----------
unit : `.UnitData`
    object string unit information for value
axis : `~matplotlib.axis.Axis`
    axis for which information is being set

    .. note:: *axis* is not used

Returns
-------
`~matplotlib.units.AxisInfo`
    Information to support default tick labeling

)majlocmajfmt)r   r   StrCategoryLocatorr   StrCategoryFormatterr   ZAxisInfo)r   r   r   r      &&  r   axisinfoZStrCategoryConverter.axisinfo=   s?    ( 	++D1 $DMM2%dmm4~~V;;r   c                s    VP                   f'   VP                  \        V 4      4       VP                   # VP                   P                  V 4       VP                   # )z
Set and update the `~matplotlib.axis.Axis` units.

Parameters
----------
data : str or iterable of str
axis : `~matplotlib.axis.Axis`
    axis on which the data is plotted

Returns
-------
`.UnitData`
    object storing string to integer mapping
)r   Z	set_unitsUnitDatar   )datar      &&r   default_unitsZ"StrCategoryConverter.default_unitsX   sH    " ::NN8D>* zz JJd#zzr   c                sH    \        V R 4      '       g   \        RV  R24      hR# )r   zProvided unit "zU" is not valid for a categorical converter, as it does not have a _mapping attribute.N)Zhasattrr   )r      &r   r   Z#StrCategoryConverter._validate_unito   s6    tZ((!$ (G GH H )r    N)__name__
__module____qualname____firstlineno__staticmethodr   r   r    r   __static_attributes____classdictcell__Z__classdict__   @r   r   r      sX     C CB < <4  , H Hr   r   c                   s6   a  ] tR t^wt o RtR tR tR tRtV t	R# )r   z1Tick at every integer mapping of the string data.c                    Wn         R# zb
Parameters
----------
units_mapping : dict
    Mapping of category names (str) to indices (int).
N_unitsselfZunits_mappingr   r   __init__ZStrCategoryLocator.__init__y   	     $r   c                sH    \        V P                  P                  4       4      # N)Zlistr/   r   )r1   r!   r   __call__ZStrCategoryLocator.__call__   s    DKK&&())r   c                s    V ! 4       # r4   r"   )r1   ZvminZvmax   &&&r   tick_valuesZStrCategoryLocator.tick_values   s	    vr   r.   N)
r#   r$   r%   r&   __doc__r2   r5   r7   r(   r)   r*   r+   r   r   r   w   s     ;$* r   r   c                   sJ   a  ] tR t^t o RtR tRR ltR t]R 4       t	Rt
V tR# )	r   z0String representation of the data at every tick.c                r,   r-   r.   r0   r   r   r2   ZStrCategoryFormatter.__init__   r3   r   Nc                s4    V P                  V.4      ^ ,          # )i    )format_ticks)r1   ZxZposr6   r   r5   ZStrCategoryFormatter.__call__   s      !%a((r   c                s    V P                   P                  4        UUu/ uF  w  r#W0P                  V4      bK  	  pppV Uu. uF  qTP                  \	        V4      R 4      NK  	  up# u uppi u upi )Z )r/   Zitems_textZgetZround)r1   r   ZkZvZ	r_mappingvals   &&    r   r9   Z!StrCategoryFormatter.format_ticks   s]    26++2C2C2EF2E$!Q

1%2E	F9?@#eCj"-@@ G@s   A'#A-c                s    \        V \        4      '       d   V P                  RR7      p V # \        V \        4      '       g   \        V 4      p V # )z0Convert text values into utf-8 or ascii strings.zutf-8)Zencoding)Z
isinstancebytesZdecodestrr   r!   r   r:   ZStrCategoryFormatter._text   sE     eU##LL'L2E  E3''JEr   r.   r4   )r#   r$   r%   r&   r8   r2   r5   r9   r'   r:   r(   r)   r*   r+   r   r   r      s,     :$)A
  r   r   c                   s@   a  ] tR t^t o RR lt]R 4       tR tRtV t	R# )r   Nc                s    \        4       V n        \        P                  ! 4       V n        Ve   V P                  V4       R# R# )z
Create mapping between unique categorical values and integer ids.

Parameters
----------
data : iterable
    sequence of string values
N)r    r   	itertoolsZcount_counterr   )r1   r   r   r   r2   ZUnitData.__init__   s2     $!)KK r   c                s     \        V 4       R#   \         d>     \        P                  P	                  T 4        R#   \        \
        3 d      R# i ; ii ; i)zI
Helper method to check whether a string can be parsed as float or date.
FT)r   r   dateutilZparserZparseZ	TypeError)r;   r!   r   _str_is_convertibleZUnitData._str_is_convertible   sY    
	#J   	%%c*  	* 	s$    A=AAAAc                s   \         P                  ! \         P                  ! V\        R7      4      pRp\        P
                  ! V4       Fr  p\        P                  ! \        \        3VR7       V'       d   V P                  V4      pW0P                  9  g   KP  \        V P                  4      V P                  V&   Kt  	  VP                  '       d"   V'       d   \        P!                  R4       R# R# R# )z
Map new values to integer identifiers.

Parameters
----------
data : iterable of str or bytes

Raises
------
TypeError
    If elements in *data* are neither str nor bytes.
r   Tr>   zUsing categorical units to plot a list of strings that are all parsable as floats or dates. If these strings should be plotted as numbers, cast to the appropriate data type before plotting.N)r	   r
   r   r   r    Zfromkeysr   Zcheck_isinstancer=   r<   rB   r   Znextr@   Zsize_logZinfo)r1   r   Zconvertibler;   r   r   r   ZUnitData.update   s     }}RXXd&9:''-C!!3,c:"66s;--'%)$--%8c" . 999II ? @ %9r   )r@   r   r4   )
r#   r$   r%   r&   r2   r'   rB   r   r(   r)   r*   r+   r   r   r      s*       @ @r   r   )r8   Zcollectionsr    Zdateutil.parserrA   r?   ZloggingZnumpyr	   Z
matplotlibr   r   r   r   Z	getLoggerr#   rC   ZConversionInterfacer   ZLocatorr   Z	Formatterr   r   Zregistryr=   Zstr_r<   Zbytes_r"   r   r   <module>rD      s   
 $     1 1 "ZH544 ZHz (6++ <:@ :@D !5 67s  7	NN2777	NN5	NN299r   