B
    ]t\}                 @   s\   d dl mZ d dlmZ G dd deZG dd deZG dd deZG dd	 d	eZ	dS )
    Nc               @   st   e Zd ZdZdd Zdd ZdddZed	d
d Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )	Containerz
    Base class for containers.

    Containers are classes that collect semantically related Artists such as
    the bars of a bar plot.
    c             C   s   d t| jt| S )Nz<{} object of {} artists>)formattype__name__len)self r   3lib/python3.7/site-packages/matplotlib/container.py__repr__   s    zContainer.__repr__c             O   s   t | |d S )Nr   )tuple__new__)clsklkwargsr   r   r	   r      s    zContainer.__new__Nc             C   s&   d| _ d| _i | _d | _| | d S )NFr   )Zeventson_oid_propobservers_remove_method	set_label)r   r   Zlabelr   r   r	   __init__   s
    zContainer.__init__z3.0c             C   s
   || _ d S )N)r   )r   fr   r   r	   set_remove_method   s    zContainer.set_remove_methodc             C   s@   x*t j| dd dD ]}|d k	r|  qW | jr<| |  d S )Nc             S   s   t | tjS )N)
isinstancemartistZArtist)xr   r   r	   <lambda>$   s    z"Container.remove.<locals>.<lambda>)Zscalarp)cbookflattenremover   )r   cr   r   r	   r   "   s    zContainer.removec             C   s   | j S )zC
        Get the label used for this artist in the legend.
        )_label)r   r   r   r	   	get_label+   s    zContainer.get_labelc             C   s(   |dk	rd|f | _ nd| _ |   dS )z
        Set the label to *s* for auto legend.

        Parameters
        ----------
        s : string or anything printable with '%s' conversion.
        Nz%s)r   pchanged)r   sr   r   r	   r   1   s    zContainer.set_labelc             C   s"   | j }|| j|< |  j d7  _ |S )z
        Adds a callback function that will be called whenever one of
        the :class:`Artist`'s properties changes.

        Returns an *id* that is useful for removing the callback with
        :meth:`remove_callback` later.
           )r   r   )r   funcoidr   r   r	   add_callback?   s    
zContainer.add_callbackc             C   s&   y| j |= W n tk
r    Y nX dS )z
        Remove a callback based on its *id*.

        .. seealso::

            :meth:`add_callback`
               For adding callbacks

        N)r   KeyError)r   r%   r   r   r	   remove_callbackL   s    
zContainer.remove_callbackc             C   s(   x"t | j D ]\}}||  qW dS )zg
        Fire an event when property changed, calling all of the
        registered callbacks.
        N)listr   items)r   r%   r$   r   r   r	   r!   [   s    zContainer.pchangedc             C   s   dd t | D S )Nc             S   s   g | ]}|d k	r|qS )Nr   ).0Zchildr   r   r	   
<listcomp>d   s    z*Container.get_children.<locals>.<listcomp>)r   r   )r   r   r   r	   get_childrenc   s    zContainer.get_children)N)r   
__module____qualname____doc__r
   r   r   r   Z
deprecatedr   r   r    r   r&   r(   r!   r-   r   r   r   r	   r      s   

	r   c               @   s   e Zd ZdZdddZdS )BarContainera  
    Container for the artists of bar plots (e.g. created by `.Axes.bar`).

    The container can be treated as a tuple of the *patches* themselves.
    Additionally, you can access these and further parameters by the
    attributes.

    Attributes
    ----------
    patches : list of :class:`~matplotlib.patches.Rectangle`
        The artists of the bars.

    errorbar : None or :class:`~matplotlib.container.ErrorbarContainer`
        A container for the error bar artists if error bars are present.
        *None* otherwise.

    Nc             K   s    || _ || _tj| |f| d S )N)patcheserrorbarr   r   )r   r2   r3   r   r   r   r	   r   z   s    zBarContainer.__init__)N)r   r.   r/   r0   r   r   r   r   r	   r1   g   s   r1   c               @   s   e Zd ZdZdddZdS )ErrorbarContainera  
    Container for the artists of error bars (e.g. created by `.Axes.errorbar`).

    The container can be treated as the *lines* tuple itself.
    Additionally, you can access these and further parameters by the
    attributes.

    Attributes
    ----------
    lines : tuple
        Tuple of ``(data_line, caplines, barlinecols)``.

        - data_line : :class:`~matplotlib.lines.Line2D` instance of
          x, y plot markers and/or line.
        - caplines : tuple of :class:`~matplotlib.lines.Line2D` instances of
          the error bar caps.
        - barlinecols : list of :class:`~matplotlib.collections.LineCollection`
          with the horizontal and vertical error ranges.

    has_xerr, has_yerr : bool
        ``True`` if the errorbar has x/y errors.

    Fc             K   s&   || _ || _|| _tj| |f| d S )N)lineshas_xerrhas_yerrr   r   )r   r5   r6   r7   r   r   r   r	   r      s    zErrorbarContainer.__init__N)FF)r   r.   r/   r0   r   r   r   r   r	   r4      s   r4   c               @   s   e Zd ZdZdd ZdS )StemContainera  
    Container for the artists created in a :meth:`.Axes.stem` plot.

    The container can be treated like a namedtuple ``(markerline, stemlines,
    baseline)``.

    Attributes
    ----------
    markerline :  :class:`~matplotlib.lines.Line2D`
        The artist of the markers at the stem heads.

    stemlines : list of :class:`~matplotlib.lines.Line2D`
        The artists of the vertical lines for all stems.

    baseline : :class:`~matplotlib.lines.Line2D`
        The artist of the horizontal baseline.

    c             K   s0   |\}}}|| _ || _|| _tj| |f| d S )N)
markerline	stemlinesbaseliner   r   )r   Zmarkerline_stemlines_baseliner   r9   r:   r;   r   r   r	   r      s
    
zStemContainer.__init__N)r   r.   r/   r0   r   r   r   r   r	   r8      s   r8   )
Zmatplotlib.cbookr   Zmatplotlib.artistZartistr   r   r   r1   r4   r8   r   r   r   r	   <module>   s
   b 