OwlCyberSecurity - MANAGER
Edit File: contour.cpython-38.pyc
U ��]h � @ s* d Z ddlmZ ddlZddlmZ ddlZddlm Z ddlmZ ddl mZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z$ ddl%m&Z& G dd� dej'�Z(G dd � d e)�Z*d d� Z+dd � Z,dd� Z-G dd� dej.e*�Z/G dd� de/�Z0dS )zQ These are classes to support contour plotting and labelling for the Axes class. � )�IntegralN)�ma)�BlockingContourLabelerc @ s e Zd ZdZdd� ZdS )� ClabelTextz� Unlike the ordinary text, the get_rotation returns an updated angle in the pixel coordinate assuming that the input rotation is an angle in data coordinate (or whatever transform set). c C sH t j�| �}| �� }| �� \}}|�t�|g�t�||gg��}|d S )Nr )�text�Text�get_rotation� get_transformZget_position�transform_angles�np�array)�selfZangle�trans�x�yZ new_angles� r �4/usr/lib/python3/dist-packages/matplotlib/contour.pyr ) s �zClabelText.get_rotationN)�__name__� __module__�__qualname__�__doc__r r r r r r # s r c @ s e Zd ZdZddddddddd�dd �Zejd dd�ed d� ��Zejd dd�edd� ��Z ejd dd�edd� ��Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zdd � Zd4d!d"�Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zd+d,� Zd5d-d.�Zd6d0d1�Zd2d3� ZdS )7�ContourLabelerz7Mixin to provide labelling capability to `.ContourSet`.NT� �%1.3fF)�fontsize�inline�inline_spacing�fmt�colors�use_clabeltext�manual�rightside_upc G s� || _ || _|| _|| _t| �dkr>| j} ttt| j���}n~t| �dkr�t| d �}g g }} t | j�D ]$\} }||krj|� | � | � |� qjt| �t|�k r�td�|| j���nt d��| | _|| _t�� | _| j�|� | j�� }|gt| � | _|dk�r| | _t�| j| j�| _n<tj|t| j�d�}ttt| j���| _tj|t�� d�| _g | _t� | j��r�| jD ]\}}| �!||||� �qrnF| j�r�t"d� t"d � |�s�t"d � t#| �}|||� n| �$||� t%�&d| j'�| _(| j(S )a� Label a contour plot. Call signature:: clabel(cs, [levels,] **kwargs) Adds labels to line contours in *cs*, where *cs* is a :class:`~matplotlib.contour.ContourSet` object returned by ``contour()``. Parameters ---------- cs : `.ContourSet` The ContourSet to label. levels : array-like, optional A list of level values, that should be labeled. The list must be a subset of ``cs.levels``. If not given, all levels are labeled. fontsize : string or float, optional Size in points or relative size e.g., 'smaller', 'x-large'. See `.Text.set_size` for accepted string values. colors : color-spec, optional The label colors: - If *None*, the color of each label matches the color of the corresponding contour. - If one string color, e.g., *colors* = 'r' or *colors* = 'red', all labels will be plotted in this color. - If a tuple of matplotlib color args (string, float, rgb, etc), different labels will be plotted in different colors in the order specified. inline : bool, optional If ``True`` the underlying contour is removed where the label is placed. Default is ``True``. inline_spacing : float, optional Space in pixels to leave on each side of label when placing inline. Defaults to 5. This spacing will be exact for labels at locations where the contour is straight, less so for labels on curved contours. fmt : string or dict, optional A format string for the label. Default is '%1.3f' Alternatively, this can be a dictionary matching contour levels with arbitrary strings to use for each contour level (i.e., fmt[level]=string), or it can be any callable, such as a :class:`~matplotlib.ticker.Formatter` instance, that returns a string when called with a numeric contour level. manual : bool or iterable, optional If ``True``, contour labels will be placed manually using mouse clicks. Click the first button near a contour to add a label, click the second button (or potentially both mouse buttons at once) to finish adding labels. The third button can be used to remove the last label added, but only if labels are not inline. Alternatively, the keyboard can be used to select label locations (enter to end label placement, delete or backspace act like the third mouse button, and any other key will select a label location). *manual* can also be an iterable object of x,y tuples. Contour labels will be created as if mouse is clicked at each x,y positions. rightside_up : bool, optional If ``True``, label rotations will always be plus or minus 90 degrees from level. Default is ``True``. use_clabeltext : bool, optional If ``True``, `.ClabelText` class (instead of `.Text`) is used to create labels. `ClabelText` recalculates rotation angles of texts during the drawing time, therefore this can be used if aspect of the axes changes. Default is ``False``. Returns ------- labels A list of `.Text` instances for the labels. r � z3Specified levels {} don't match available levels {}z-Illegal arguments to clabel, see help(clabel)N��N)�cmap�normz9Select label locations manually using first mouse button.z.End manual selection with second mouse button.z1Remove last label by clicking third mouse button.z text.Text))�labelFmt�_use_clabeltextZlabelManualr! �len�levels�list�range�cvalues� enumerate�append� ValueError�format� TypeError�labelLevelList�labelIndiceList�font_managerZFontProperties�labelFontPropsZset_sizeZget_size_in_points�labelFontSizeList� labelMappabler Ztake�labelCValueList�mcolors�ListedColormap�cm�ScalarMappable�NoNorm�labelXYs�iterable�add_label_near�printr �labels�cbook�silent_list� labelTextsZlabelTextsList)r r r r r r r r r! �argsr* �indicesZlevlabs�i�levZ font_size_ptsr% r r Zblocking_contour_labelerr r r �clabel5 sd i � � � zContourLabeler.clabelz3.0rF )Zalternativec C s | j S �N)rF �r r r r �<lambda>� � zContourLabeler.<lambda>r? c C s | j S rL )r? rM r r r rN � rO �labelCValuesc C s | j S rL )rP rM r r r rN � rO c C s* t |�d| kp(tj|dd�d| k�� S )z5Return *False* if contours are too short for a label.� r �Zaxis�333333�?)r) r Zptp�any)r �linecontour� labelwidthr r r �print_label� s �zContourLabeler.print_labelc s( d| d � t � ��fdd�| jD ��S )z7Return *True* if a label is already near this location.rS � c 3 s2 | ]*}�|d d �|d d � k V qdS )r rX r"