| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/matplotlib/__pycache__/ |
Upload File : |
�
G8�c�� � � � d Z ddlZddlZddlZddlZddlZddlmZm Z m
Z
mZ ddlm
Z
mZ ddlmZ ddlmZ ddlmZ ddlmZmZmZmZmZ dd lmZmZmZmZm Z m!Z! dd
l"m#Z# ddl$m%Z%m&Z&m'Z' ddl$m(Z(m)Z) dd
l*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3m4Z4 ddl5m6Z6 G d� de,� Z7e jp js d�� G d� de
� Z:dd�Z;dd�Z<ddd�d�Z=y)a�
The legend module defines the Legend class, which is responsible for
drawing legends associated with axes and/or figures.
.. important::
It is unlikely that you would ever create a Legend instance manually.
Most users would normally create a legend via the `~.Axes.legend`
function. For more details on legends there is also a :doc:`legend guide
</tutorials/intermediate/legend_guide>`.
The `Legend` class is a container of legend handles and legend texts.
The legend handler map specifies how to create legend handles from artists
(lines, patches, etc.) in the axes or figures. Default legend handlers are
defined in the :mod:`~matplotlib.legend_handler` module. While not all artist
types are covered by the default legend handlers, custom legend handlers can be
defined to support arbitrary objects.
See the :doc:`legend guide </tutorials/intermediate/legend_guide>` for more
information.
� N)�_api�
_docstring�colors� offsetbox)�Artist�allow_rasterization)�silent_list)�FontProperties)�Line2D)�Patch� Rectangle�Shadow�FancyBboxPatch� StepPatch)�
Collection�CircleCollection�LineCollection�PathCollection�PolyCollection�RegularPolyCollection)�Text)�Bbox�BboxBase�TransformedBbox)�BboxTransformTo�BboxTransformFrom)�AnchoredOffsetbox�DraggableOffsetBox�HPacker�VPacker�DrawingArea�TextArea)�ErrorbarContainer�BarContainer�
StemContainer� )�legend_handlerc �2 � � e Zd Zd� fd� Zd� Zd� Zd� Z� xZS )�DraggableLegendc � �� || _ t j ddg|�� || _ t �| � ||j |�� y)a�
Wrapper around a `.Legend` to support mouse dragging.
Parameters
----------
legend : `.Legend`
The `.Legend` instance to wrap.
use_blit : bool, optional
Use blitting for faster image composition. For details see
:ref:`func-animation`.
update : {'loc', 'bbox'}, optional
If "loc", update the *loc* parameter of the legend upon finalizing.
If "bbox", update the *bbox_to_anchor* parameter.
�loc�bbox��update)�use_blitN)�legendr �
check_in_list�_update�super�__init__�_legend_box)�selfr0 r/ r. � __class__s ��3/usr/lib/python3/dist-packages/matplotlib/legend.pyr4 zDraggableLegend.__init__6 sA �� � ������E�6�?�6�:����
�����!3�!3�h��G� c � � | j dk( r | j | j � � y | j dk( r | j | j � � y y )Nr+ r, )r2 �_update_loc�get_loc_in_canvas�_bbox_to_anchor�r6 s r8 �finalize_offsetzDraggableLegend.finalize_offsetL sM � ��<�<�5� ����T�3�3�5�6�
�\�\�V�
#�� � ��!7�!7�!9�:� $r9 c �F � | j j � }|j dk( s|j dk( r5| j j d � | j j � }t |� }t
|j |� � | j _ y )Nr ) r0 �get_bbox_to_anchor�width�height�set_bbox_to_anchorr �tuple� transform�_loc)r6 �
loc_in_canvasr, �_bbox_transforms r8 r; zDraggableLegend._update_locR sv � ��{�{�-�-�/�� �:�:��?�d�k�k�Q�.��K�K�*�*�4�0��;�;�1�1�3�D�+�D�1�� ��!:�!:�=�!I�J����r9 c � � | j j j j |� }| j j |� y �N)r0 �axes� transAxesrF rD )r6 rH �loc_in_bboxs r8 �_update_bbox_to_anchorz&DraggableLegend._update_bbox_to_anchor\ s4 � ��k�k�&�&�0�0�:�:�=�I�����&�&�{�3r9 �Fr+ )�__name__�
__module__�__qualname__r4 r? r; rO �
__classcell__�r7 s @r8 r) r) 5 s �� �H�,;�K�4r9 r) a
loc : str or pair of floats, default: :rc:`legend.loc` ('best' for axes, 'upper right' for figures)
The location of the legend.
The strings
``'upper left', 'upper right', 'lower left', 'lower right'``
place the legend at the corresponding corner of the axes/figure.
The strings
``'upper center', 'lower center', 'center left', 'center right'``
place the legend at the center of the corresponding edge of the
axes/figure.
The string ``'center'`` places the legend at the center of the axes/figure.
The string ``'best'`` places the legend at the location, among the nine
locations defined so far, with the minimum overlap with other drawn
artists. This option can be quite slow for plots with large amounts of
data; your plotting speed may benefit from providing a specific location.
The location can also be a 2-tuple giving the coordinates of the lower-left
corner of the legend in axes coordinates (in which case *bbox_to_anchor*
will be ignored).
For back-compatibility, ``'center right'`` (but no other location) can also
be spelled ``'right'``, and each "string" locations can also be given as a
numeric value:
=============== =============
Location String Location Code
=============== =============
'best' 0
'upper right' 1
'upper left' 2
'lower left' 3
'lower right' 4
'right' 5
'center left' 6
'center right' 7
'lower center' 8
'upper center' 9
'center' 10
=============== =============
bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
Box that is used to position the legend in conjunction with *loc*.
Defaults to `axes.bbox` (if called as a method to `.Axes.legend`) or
`figure.bbox` (if `.Figure.legend`). This argument allows arbitrary
placement of the legend.
Bbox coordinates are interpreted in the coordinate system given by
*bbox_transform*, with the default transform
Axes or Figure coordinates, depending on which ``legend`` is called.
If a 4-tuple or `.BboxBase` is given, then it specifies the bbox
``(x, y, width, height)`` that the legend is placed in.
To put the legend in the best location in the bottom right
quadrant of the axes (or figure)::
loc='best', bbox_to_anchor=(0.5, 0., 0.5, 0.5)
A 2-tuple ``(x, y)`` places the corner of the legend specified by *loc* at
x, y. For example, to put the legend's upper right-hand corner in the
center of the axes (or figure) the following keywords can be used::
loc='upper right', bbox_to_anchor=(0.5, 0.5)
ncols : int, default: 1
The number of columns that the legend has.
For backward compatibility, the spelling *ncol* is also supported
but it is discouraged. If both are given, *ncols* takes precedence.
prop : None or `matplotlib.font_manager.FontProperties` or dict
The font properties of the legend. If None (default), the current
:data:`matplotlib.rcParams` will be used.
fontsize : int or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
The font size of the legend. If the value is numeric the size will be the
absolute font size in points. String values are relative to the current
default font size. This argument is only used if *prop* is not specified.
labelcolor : str or list, default: :rc:`legend.labelcolor`
The color of the text in the legend. Either a valid color string
(for example, 'red'), or a list of color strings. The labelcolor can
also be made to match the color of the line or marker using 'linecolor',
'markerfacecolor' (or 'mfc'), or 'markeredgecolor' (or 'mec').
Labelcolor can be set globally using :rc:`legend.labelcolor`. If None,
use :rc:`text.color`.
numpoints : int, default: :rc:`legend.numpoints`
The number of marker points in the legend when creating a legend
entry for a `.Line2D` (line).
scatterpoints : int, default: :rc:`legend.scatterpoints`
The number of marker points in the legend when creating
a legend entry for a `.PathCollection` (scatter plot).
scatteryoffsets : iterable of floats, default: ``[0.375, 0.5, 0.3125]``
The vertical offset (relative to the font size) for the markers
created for a scatter plot legend entry. 0.0 is at the base the
legend text, and 1.0 is at the top. To draw all markers at the
same height, set to ``[0.5]``.
markerscale : float, default: :rc:`legend.markerscale`
The relative size of legend markers compared with the originally
drawn ones.
markerfirst : bool, default: True
If *True*, legend marker is placed to the left of the legend label.
If *False*, legend marker is placed to the right of the legend label.
frameon : bool, default: :rc:`legend.frameon`
Whether the legend should be drawn on a patch (frame).
fancybox : bool, default: :rc:`legend.fancybox`
Whether round edges should be enabled around the `.FancyBboxPatch` which
makes up the legend's background.
shadow : bool, default: :rc:`legend.shadow`
Whether to draw a shadow behind the legend.
framealpha : float, default: :rc:`legend.framealpha`
The alpha transparency of the legend's background.
If *shadow* is activated and *framealpha* is ``None``, the default value is
ignored.
facecolor : "inherit" or color, default: :rc:`legend.facecolor`
The legend's background color.
If ``"inherit"``, use :rc:`axes.facecolor`.
edgecolor : "inherit" or color, default: :rc:`legend.edgecolor`
The legend's background patch edge color.
If ``"inherit"``, use take :rc:`axes.edgecolor`.
mode : {"expand", None}
If *mode* is set to ``"expand"`` the legend will be horizontally
expanded to fill the axes area (or *bbox_to_anchor* if defines
the legend's size).
bbox_transform : None or `matplotlib.transforms.Transform`
The transform for the bounding box (*bbox_to_anchor*). For a value
of ``None`` (default) the Axes'
:data:`~matplotlib.axes.Axes.transAxes` transform will be used.
title : str or None
The legend's title. Default is no title (``None``).
title_fontproperties : None or `matplotlib.font_manager.FontProperties` or dict
The font properties of the legend's title. If None (default), the
*title_fontsize* argument will be used if present; if *title_fontsize* is
also None, the current :rc:`legend.title_fontsize` will be used.
title_fontsize : int or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}, default: :rc:`legend.title_fontsize`
The font size of the legend's title.
Note: This cannot be combined with *title_fontproperties*. If you want
to set the fontsize alongside other font properties, use the *size*
parameter in *title_fontproperties*.
alignment : {'center', 'left', 'right'}, default: 'center'
The alignment of the legend title and the box of entries. The entries
are aligned as a single block, so that markers always lined up.
borderpad : float, default: :rc:`legend.borderpad`
The fractional whitespace inside the legend border, in font-size units.
labelspacing : float, default: :rc:`legend.labelspacing`
The vertical space between the legend entries, in font-size units.
handlelength : float, default: :rc:`legend.handlelength`
The length of the legend handles, in font-size units.
handleheight : float, default: :rc:`legend.handleheight`
The height of the legend handles, in font-size units.
handletextpad : float, default: :rc:`legend.handletextpad`
The pad between the legend handle and text, in font-size units.
borderaxespad : float, default: :rc:`legend.borderaxespad`
The pad between the axes and legend border, in font-size units.
columnspacing : float, default: :rc:`legend.columnspacing`
The spacing between columns, in font-size units.
handler_map : dict or None
The custom dictionary mapping instances or types to a legend
handler. This *handler_map* updates the default handler map
found at `matplotlib.legend.Legend.get_legend_handler_map`.
)�_legend_kw_docc � � � e Zd ZdZddiej
�ZdZd� Z ej dd� e
j d-dd �� fd
�� � Zd� Z
d� Zd
� Zd� Z eee� Zd� Zed� � Ze ej0 � e ej4 � e ej8 � e ej<