OwlCyberSecurity - MANAGER
Edit File: legend_handler.cpython-38.pyc
U ��]�g � @ s$ d Z ddlmZ ddlZddlmZ ddlmZ ddl m Z ddlm Z dd� ZG dd � d e�ZG d d� de�ZG dd � d e�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�ZG d d!� d!e�ZdS )"a� This module defines default legend handlers. It is strongly encouraged to have read the :doc:`legend guide </tutorials/intermediate/legend_guide>` before this documentation. Legend handlers are expected to be a callable object with a following signature. :: legend_handler(legend, orig_handle, fontsize, handlebox) Where *legend* is the legend itself, *orig_handle* is the original plot, *fontsize* is the fontsize in pixels, and *handlebox* is a OffsetBox instance. Within the call, you should create relevant artists (using relevant properties from the *legend* and/or *orig_handle*) and add them into the handlebox. The artists needs to be scaled according to the fontsize (note that the size is in pixel, i.e., this is dpi-scaled value). This module includes definition of several legend handler classes derived from the base class (HandlerBase) with the following method:: def legend_artist(self, legend, orig_handle, fontsize, handlebox) � )�cycleN��Line2D)� Rectanglec C s | � |�� d � d S �Nr )�update_fromZget_children)Ztgt�src� r �;/usr/lib/python3/dist-packages/matplotlib/legend_handler.py�update_from_first_child% s r c @ sJ e Zd ZdZddd�Zdd� Zdd � Zd d� Zdd � Zdd� Z dd� Z dS )�HandlerBasea A Base class for default legend handlers. The derived classes are meant to override *create_artists* method, which has a following signature.:: def create_artists(self, legend, orig_handle, xdescent, ydescent, width, height, fontsize, trans): The overridden method needs to create artists of the given transform that fits in the given dimension (xdescent, ydescent, width, height) that are scaled by fontsize if necessary. � Nc C s || | _ | _|| _d S �N)�_xpad�_ypad�_update_prop_func)�selfZxpadZypadZupdate_funcr r r �__init__9 s zHandlerBase.__init__c C s( | j d kr| �||� n| � ||� d S r )r �_default_update_prop�r � legend_handle�orig_handler r r �_update_prop= s zHandlerBase._update_propc C s |� |� d S r )r r r r r r C s z HandlerBase._default_update_propc C s. | � ||� |�|� |�d � |�d � d S r )r Z_set_artist_props�set_clip_box� set_clip_path�r r r �legendr r r �update_propF s zHandlerBase.update_propc C sD || j | }|| j| }|| j | }|| j| }||||fS r )r r )r r r �xdescent�ydescent�width�height�fontsizer r r �adjust_drawing_areaN s zHandlerBase.adjust_drawing_areac C s^ | � |||j|j|j|j|�\}}}}| �||||||||�� �} | D ]} |�| � qF| d S )aU Return the artist that this HandlerBase generates for the given original artist/handle. Parameters ---------- legend : :class:`matplotlib.legend.Legend` instance The legend for which these legend artists are being created. orig_handle : :class:`matplotlib.artist.Artist` or similar The object for which these legend artists are being created. fontsize : float or int The fontsize in pixels. The artists being created should be scaled according to the given fontsize. handlebox : :class:`matplotlib.offsetbox.OffsetBox` instance The box which has been created to hold this legend entry's artists. Artists created in the `legend_artist` method must be added to this handlebox inside this method. r )r# r r r r! �create_artistsZ get_transformZ add_artist)r r r r"