Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- llava_video/lib/python3.10/site-packages/matplotlib/__init__.pyi +124 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_api/__init__.py +391 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_api/__init__.pyi +59 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_api/__pycache__/__init__.cpython-310.pyc +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_api/__pycache__/deprecation.cpython-310.pyc +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_api/deprecation.py +509 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_api/deprecation.pyi +75 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_blocking_input.py +30 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_cm.py +1460 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_cm_bivar.py +1312 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_cm_listed.py +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_color_data.py +1141 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_docstring.py +141 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_enums.pyi +18 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_image.pyi +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_mathtext.py +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_pylab_helpers.py +134 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_pylab_helpers.pyi +29 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_tight_layout.py +301 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_tri.pyi +36 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_type1font.py +879 -0
- llava_video/lib/python3.10/site-packages/matplotlib/_version.py +1 -0
- llava_video/lib/python3.10/site-packages/matplotlib/axis.pyi +280 -0
- llava_video/lib/python3.10/site-packages/matplotlib/backend_bases.py +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/cbook.pyi +173 -0
- llava_video/lib/python3.10/site-packages/matplotlib/cm.py +310 -0
- llava_video/lib/python3.10/site-packages/matplotlib/collections.pyi +262 -0
- llava_video/lib/python3.10/site-packages/matplotlib/colorbar.py +1568 -0
- llava_video/lib/python3.10/site-packages/matplotlib/colorizer.py +692 -0
- llava_video/lib/python3.10/site-packages/matplotlib/colorizer.pyi +102 -0
- llava_video/lib/python3.10/site-packages/matplotlib/colors.py +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/colors.pyi +449 -0
- llava_video/lib/python3.10/site-packages/matplotlib/container.py +141 -0
- llava_video/lib/python3.10/site-packages/matplotlib/dviread.py +1139 -0
- llava_video/lib/python3.10/site-packages/matplotlib/dviread.pyi +89 -0
- llava_video/lib/python3.10/site-packages/matplotlib/gridspec.py +788 -0
- llava_video/lib/python3.10/site-packages/matplotlib/inset.py +269 -0
- llava_video/lib/python3.10/site-packages/matplotlib/layout_engine.py +304 -0
- llava_video/lib/python3.10/site-packages/matplotlib/legend.py +1370 -0
- llava_video/lib/python3.10/site-packages/matplotlib/legend.pyi +152 -0
- llava_video/lib/python3.10/site-packages/matplotlib/markers.pyi +51 -0
- llava_video/lib/python3.10/site-packages/matplotlib/offsetbox.py +1573 -0
- llava_video/lib/python3.10/site-packages/matplotlib/patches.pyi +757 -0
- llava_video/lib/python3.10/site-packages/matplotlib/path.py +1093 -0
- llava_video/lib/python3.10/site-packages/matplotlib/path.pyi +140 -0
- llava_video/lib/python3.10/site-packages/matplotlib/py.typed +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/pyplot.py +0 -0
- llava_video/lib/python3.10/site-packages/matplotlib/quiver.pyi +184 -0
- llava_video/lib/python3.10/site-packages/matplotlib/rcsetup.py +1371 -0
- llava_video/lib/python3.10/site-packages/matplotlib/sankey.py +814 -0
llava_video/lib/python3.10/site-packages/matplotlib/__init__.pyi
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__all__ = [
|
| 2 |
+
"__bibtex__",
|
| 3 |
+
"__version__",
|
| 4 |
+
"__version_info__",
|
| 5 |
+
"set_loglevel",
|
| 6 |
+
"ExecutableNotFoundError",
|
| 7 |
+
"get_configdir",
|
| 8 |
+
"get_cachedir",
|
| 9 |
+
"get_data_path",
|
| 10 |
+
"matplotlib_fname",
|
| 11 |
+
"MatplotlibDeprecationWarning",
|
| 12 |
+
"RcParams",
|
| 13 |
+
"rc_params",
|
| 14 |
+
"rc_params_from_file",
|
| 15 |
+
"rcParamsDefault",
|
| 16 |
+
"rcParams",
|
| 17 |
+
"rcParamsOrig",
|
| 18 |
+
"defaultParams",
|
| 19 |
+
"rc",
|
| 20 |
+
"rcdefaults",
|
| 21 |
+
"rc_file_defaults",
|
| 22 |
+
"rc_file",
|
| 23 |
+
"rc_context",
|
| 24 |
+
"use",
|
| 25 |
+
"get_backend",
|
| 26 |
+
"interactive",
|
| 27 |
+
"is_interactive",
|
| 28 |
+
"colormaps",
|
| 29 |
+
"color_sequences",
|
| 30 |
+
]
|
| 31 |
+
|
| 32 |
+
import os
|
| 33 |
+
from pathlib import Path
|
| 34 |
+
|
| 35 |
+
from collections.abc import Callable, Generator
|
| 36 |
+
import contextlib
|
| 37 |
+
from packaging.version import Version
|
| 38 |
+
|
| 39 |
+
from matplotlib._api import MatplotlibDeprecationWarning
|
| 40 |
+
from typing import Any, Literal, NamedTuple, overload
|
| 41 |
+
|
| 42 |
+
class _VersionInfo(NamedTuple):
|
| 43 |
+
major: int
|
| 44 |
+
minor: int
|
| 45 |
+
micro: int
|
| 46 |
+
releaselevel: str
|
| 47 |
+
serial: int
|
| 48 |
+
|
| 49 |
+
__bibtex__: str
|
| 50 |
+
__version__: str
|
| 51 |
+
__version_info__: _VersionInfo
|
| 52 |
+
|
| 53 |
+
def set_loglevel(level: str) -> None: ...
|
| 54 |
+
|
| 55 |
+
class _ExecInfo(NamedTuple):
|
| 56 |
+
executable: str
|
| 57 |
+
raw_version: str
|
| 58 |
+
version: Version
|
| 59 |
+
|
| 60 |
+
class ExecutableNotFoundError(FileNotFoundError): ...
|
| 61 |
+
|
| 62 |
+
def _get_executable_info(name: str) -> _ExecInfo: ...
|
| 63 |
+
def get_configdir() -> str: ...
|
| 64 |
+
def get_cachedir() -> str: ...
|
| 65 |
+
def get_data_path() -> str: ...
|
| 66 |
+
def matplotlib_fname() -> str: ...
|
| 67 |
+
|
| 68 |
+
class RcParams(dict[str, Any]):
|
| 69 |
+
validate: dict[str, Callable]
|
| 70 |
+
def __init__(self, *args, **kwargs) -> None: ...
|
| 71 |
+
def _set(self, key: str, val: Any) -> None: ...
|
| 72 |
+
def _get(self, key: str) -> Any: ...
|
| 73 |
+
|
| 74 |
+
def _update_raw(self, other_params: dict | RcParams) -> None: ...
|
| 75 |
+
|
| 76 |
+
def _ensure_has_backend(self) -> None: ...
|
| 77 |
+
def __setitem__(self, key: str, val: Any) -> None: ...
|
| 78 |
+
def __getitem__(self, key: str) -> Any: ...
|
| 79 |
+
def __iter__(self) -> Generator[str, None, None]: ...
|
| 80 |
+
def __len__(self) -> int: ...
|
| 81 |
+
def find_all(self, pattern: str) -> RcParams: ...
|
| 82 |
+
def copy(self) -> RcParams: ...
|
| 83 |
+
|
| 84 |
+
def rc_params(fail_on_error: bool = ...) -> RcParams: ...
|
| 85 |
+
def rc_params_from_file(
|
| 86 |
+
fname: str | Path | os.PathLike,
|
| 87 |
+
fail_on_error: bool = ...,
|
| 88 |
+
use_default_template: bool = ...,
|
| 89 |
+
) -> RcParams: ...
|
| 90 |
+
|
| 91 |
+
rcParamsDefault: RcParams
|
| 92 |
+
rcParams: RcParams
|
| 93 |
+
rcParamsOrig: RcParams
|
| 94 |
+
defaultParams: dict[str, Any]
|
| 95 |
+
|
| 96 |
+
def rc(group: str, **kwargs) -> None: ...
|
| 97 |
+
def rcdefaults() -> None: ...
|
| 98 |
+
def rc_file_defaults() -> None: ...
|
| 99 |
+
def rc_file(
|
| 100 |
+
fname: str | Path | os.PathLike, *, use_default_template: bool = ...
|
| 101 |
+
) -> None: ...
|
| 102 |
+
@contextlib.contextmanager
|
| 103 |
+
def rc_context(
|
| 104 |
+
rc: dict[str, Any] | None = ..., fname: str | Path | os.PathLike | None = ...
|
| 105 |
+
) -> Generator[None, None, None]: ...
|
| 106 |
+
def use(backend: str, *, force: bool = ...) -> None: ...
|
| 107 |
+
@overload
|
| 108 |
+
def get_backend(*, auto_select: Literal[True] = True) -> str: ...
|
| 109 |
+
@overload
|
| 110 |
+
def get_backend(*, auto_select: Literal[False]) -> str | None: ...
|
| 111 |
+
def interactive(b: bool) -> None: ...
|
| 112 |
+
def is_interactive() -> bool: ...
|
| 113 |
+
|
| 114 |
+
def _preprocess_data(
|
| 115 |
+
func: Callable | None = ...,
|
| 116 |
+
*,
|
| 117 |
+
replace_names: list[str] | None = ...,
|
| 118 |
+
label_namer: str | None = ...
|
| 119 |
+
) -> Callable: ...
|
| 120 |
+
|
| 121 |
+
from matplotlib.cm import _colormaps as colormaps # noqa: E402
|
| 122 |
+
from matplotlib.cm import _multivar_colormaps as multivar_colormaps # noqa: E402
|
| 123 |
+
from matplotlib.cm import _bivar_colormaps as bivar_colormaps # noqa: E402
|
| 124 |
+
from matplotlib.colors import _color_sequences as color_sequences # noqa: E402
|
llava_video/lib/python3.10/site-packages/matplotlib/_api/__init__.py
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Helper functions for managing the Matplotlib API.
|
| 3 |
+
|
| 4 |
+
This documentation is only relevant for Matplotlib developers, not for users.
|
| 5 |
+
|
| 6 |
+
.. warning::
|
| 7 |
+
|
| 8 |
+
This module and its submodules are for internal use only. Do not use them
|
| 9 |
+
in your own code. We may change the API at any time with no warning.
|
| 10 |
+
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import functools
|
| 14 |
+
import itertools
|
| 15 |
+
import pathlib
|
| 16 |
+
import re
|
| 17 |
+
import sys
|
| 18 |
+
import warnings
|
| 19 |
+
|
| 20 |
+
from .deprecation import ( # noqa: F401
|
| 21 |
+
deprecated, warn_deprecated,
|
| 22 |
+
rename_parameter, delete_parameter, make_keyword_only,
|
| 23 |
+
deprecate_method_override, deprecate_privatize_attribute,
|
| 24 |
+
suppress_matplotlib_deprecation_warning,
|
| 25 |
+
MatplotlibDeprecationWarning)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class classproperty:
|
| 29 |
+
"""
|
| 30 |
+
Like `property`, but also triggers on access via the class, and it is the
|
| 31 |
+
*class* that's passed as argument.
|
| 32 |
+
|
| 33 |
+
Examples
|
| 34 |
+
--------
|
| 35 |
+
::
|
| 36 |
+
|
| 37 |
+
class C:
|
| 38 |
+
@classproperty
|
| 39 |
+
def foo(cls):
|
| 40 |
+
return cls.__name__
|
| 41 |
+
|
| 42 |
+
assert C.foo == "C"
|
| 43 |
+
"""
|
| 44 |
+
|
| 45 |
+
def __init__(self, fget, fset=None, fdel=None, doc=None):
|
| 46 |
+
self._fget = fget
|
| 47 |
+
if fset is not None or fdel is not None:
|
| 48 |
+
raise ValueError('classproperty only implements fget.')
|
| 49 |
+
self.fset = fset
|
| 50 |
+
self.fdel = fdel
|
| 51 |
+
# docs are ignored for now
|
| 52 |
+
self._doc = doc
|
| 53 |
+
|
| 54 |
+
def __get__(self, instance, owner):
|
| 55 |
+
return self._fget(owner)
|
| 56 |
+
|
| 57 |
+
@property
|
| 58 |
+
def fget(self):
|
| 59 |
+
return self._fget
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
# In the following check_foo() functions, the first parameter is positional-only to make
|
| 63 |
+
# e.g. `_api.check_isinstance([...], types=foo)` work.
|
| 64 |
+
|
| 65 |
+
def check_isinstance(types, /, **kwargs):
|
| 66 |
+
"""
|
| 67 |
+
For each *key, value* pair in *kwargs*, check that *value* is an instance
|
| 68 |
+
of one of *types*; if not, raise an appropriate TypeError.
|
| 69 |
+
|
| 70 |
+
As a special case, a ``None`` entry in *types* is treated as NoneType.
|
| 71 |
+
|
| 72 |
+
Examples
|
| 73 |
+
--------
|
| 74 |
+
>>> _api.check_isinstance((SomeClass, None), arg=arg)
|
| 75 |
+
"""
|
| 76 |
+
none_type = type(None)
|
| 77 |
+
types = ((types,) if isinstance(types, type) else
|
| 78 |
+
(none_type,) if types is None else
|
| 79 |
+
tuple(none_type if tp is None else tp for tp in types))
|
| 80 |
+
|
| 81 |
+
def type_name(tp):
|
| 82 |
+
return ("None" if tp is none_type
|
| 83 |
+
else tp.__qualname__ if tp.__module__ == "builtins"
|
| 84 |
+
else f"{tp.__module__}.{tp.__qualname__}")
|
| 85 |
+
|
| 86 |
+
for k, v in kwargs.items():
|
| 87 |
+
if not isinstance(v, types):
|
| 88 |
+
names = [*map(type_name, types)]
|
| 89 |
+
if "None" in names: # Move it to the end for better wording.
|
| 90 |
+
names.remove("None")
|
| 91 |
+
names.append("None")
|
| 92 |
+
raise TypeError(
|
| 93 |
+
"{!r} must be an instance of {}, not a {}".format(
|
| 94 |
+
k,
|
| 95 |
+
", ".join(names[:-1]) + " or " + names[-1]
|
| 96 |
+
if len(names) > 1 else names[0],
|
| 97 |
+
type_name(type(v))))
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def check_in_list(values, /, *, _print_supported_values=True, **kwargs):
|
| 101 |
+
"""
|
| 102 |
+
For each *key, value* pair in *kwargs*, check that *value* is in *values*;
|
| 103 |
+
if not, raise an appropriate ValueError.
|
| 104 |
+
|
| 105 |
+
Parameters
|
| 106 |
+
----------
|
| 107 |
+
values : iterable
|
| 108 |
+
Sequence of values to check on.
|
| 109 |
+
_print_supported_values : bool, default: True
|
| 110 |
+
Whether to print *values* when raising ValueError.
|
| 111 |
+
**kwargs : dict
|
| 112 |
+
*key, value* pairs as keyword arguments to find in *values*.
|
| 113 |
+
|
| 114 |
+
Raises
|
| 115 |
+
------
|
| 116 |
+
ValueError
|
| 117 |
+
If any *value* in *kwargs* is not found in *values*.
|
| 118 |
+
|
| 119 |
+
Examples
|
| 120 |
+
--------
|
| 121 |
+
>>> _api.check_in_list(["foo", "bar"], arg=arg, other_arg=other_arg)
|
| 122 |
+
"""
|
| 123 |
+
if not kwargs:
|
| 124 |
+
raise TypeError("No argument to check!")
|
| 125 |
+
for key, val in kwargs.items():
|
| 126 |
+
if val not in values:
|
| 127 |
+
msg = f"{val!r} is not a valid value for {key}"
|
| 128 |
+
if _print_supported_values:
|
| 129 |
+
msg += f"; supported values are {', '.join(map(repr, values))}"
|
| 130 |
+
raise ValueError(msg)
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def check_shape(shape, /, **kwargs):
|
| 134 |
+
"""
|
| 135 |
+
For each *key, value* pair in *kwargs*, check that *value* has the shape *shape*;
|
| 136 |
+
if not, raise an appropriate ValueError.
|
| 137 |
+
|
| 138 |
+
*None* in the shape is treated as a "free" size that can have any length.
|
| 139 |
+
e.g. (None, 2) -> (N, 2)
|
| 140 |
+
|
| 141 |
+
The values checked must be numpy arrays.
|
| 142 |
+
|
| 143 |
+
Examples
|
| 144 |
+
--------
|
| 145 |
+
To check for (N, 2) shaped arrays
|
| 146 |
+
|
| 147 |
+
>>> _api.check_shape((None, 2), arg=arg, other_arg=other_arg)
|
| 148 |
+
"""
|
| 149 |
+
for k, v in kwargs.items():
|
| 150 |
+
data_shape = v.shape
|
| 151 |
+
|
| 152 |
+
if (len(data_shape) != len(shape)
|
| 153 |
+
or any(s != t and t is not None for s, t in zip(data_shape, shape))):
|
| 154 |
+
dim_labels = iter(itertools.chain(
|
| 155 |
+
'NMLKJIH',
|
| 156 |
+
(f"D{i}" for i in itertools.count())))
|
| 157 |
+
text_shape = ", ".join([str(n) if n is not None else next(dim_labels)
|
| 158 |
+
for n in shape[::-1]][::-1])
|
| 159 |
+
if len(shape) == 1:
|
| 160 |
+
text_shape += ","
|
| 161 |
+
|
| 162 |
+
raise ValueError(
|
| 163 |
+
f"{k!r} must be {len(shape)}D with shape ({text_shape}), "
|
| 164 |
+
f"but your input has shape {v.shape}"
|
| 165 |
+
)
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
def check_getitem(mapping, /, **kwargs):
|
| 169 |
+
"""
|
| 170 |
+
*kwargs* must consist of a single *key, value* pair. If *key* is in
|
| 171 |
+
*mapping*, return ``mapping[value]``; else, raise an appropriate
|
| 172 |
+
ValueError.
|
| 173 |
+
|
| 174 |
+
Examples
|
| 175 |
+
--------
|
| 176 |
+
>>> _api.check_getitem({"foo": "bar"}, arg=arg)
|
| 177 |
+
"""
|
| 178 |
+
if len(kwargs) != 1:
|
| 179 |
+
raise ValueError("check_getitem takes a single keyword argument")
|
| 180 |
+
(k, v), = kwargs.items()
|
| 181 |
+
try:
|
| 182 |
+
return mapping[v]
|
| 183 |
+
except KeyError:
|
| 184 |
+
raise ValueError(
|
| 185 |
+
f"{v!r} is not a valid value for {k}; supported values are "
|
| 186 |
+
f"{', '.join(map(repr, mapping))}") from None
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def caching_module_getattr(cls):
|
| 190 |
+
"""
|
| 191 |
+
Helper decorator for implementing module-level ``__getattr__`` as a class.
|
| 192 |
+
|
| 193 |
+
This decorator must be used at the module toplevel as follows::
|
| 194 |
+
|
| 195 |
+
@caching_module_getattr
|
| 196 |
+
class __getattr__: # The class *must* be named ``__getattr__``.
|
| 197 |
+
@property # Only properties are taken into account.
|
| 198 |
+
def name(self): ...
|
| 199 |
+
|
| 200 |
+
The ``__getattr__`` class will be replaced by a ``__getattr__``
|
| 201 |
+
function such that trying to access ``name`` on the module will
|
| 202 |
+
resolve the corresponding property (which may be decorated e.g. with
|
| 203 |
+
``_api.deprecated`` for deprecating module globals). The properties are
|
| 204 |
+
all implicitly cached. Moreover, a suitable AttributeError is generated
|
| 205 |
+
and raised if no property with the given name exists.
|
| 206 |
+
"""
|
| 207 |
+
|
| 208 |
+
assert cls.__name__ == "__getattr__"
|
| 209 |
+
# Don't accidentally export cls dunders.
|
| 210 |
+
props = {name: prop for name, prop in vars(cls).items()
|
| 211 |
+
if isinstance(prop, property)}
|
| 212 |
+
instance = cls()
|
| 213 |
+
|
| 214 |
+
@functools.cache
|
| 215 |
+
def __getattr__(name):
|
| 216 |
+
if name in props:
|
| 217 |
+
return props[name].__get__(instance)
|
| 218 |
+
raise AttributeError(
|
| 219 |
+
f"module {cls.__module__!r} has no attribute {name!r}")
|
| 220 |
+
|
| 221 |
+
return __getattr__
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
def define_aliases(alias_d, cls=None):
|
| 225 |
+
"""
|
| 226 |
+
Class decorator for defining property aliases.
|
| 227 |
+
|
| 228 |
+
Use as ::
|
| 229 |
+
|
| 230 |
+
@_api.define_aliases({"property": ["alias", ...], ...})
|
| 231 |
+
class C: ...
|
| 232 |
+
|
| 233 |
+
For each property, if the corresponding ``get_property`` is defined in the
|
| 234 |
+
class so far, an alias named ``get_alias`` will be defined; the same will
|
| 235 |
+
be done for setters. If neither the getter nor the setter exists, an
|
| 236 |
+
exception will be raised.
|
| 237 |
+
|
| 238 |
+
The alias map is stored as the ``_alias_map`` attribute on the class and
|
| 239 |
+
can be used by `.normalize_kwargs` (which assumes that higher priority
|
| 240 |
+
aliases come last).
|
| 241 |
+
"""
|
| 242 |
+
if cls is None: # Return the actual class decorator.
|
| 243 |
+
return functools.partial(define_aliases, alias_d)
|
| 244 |
+
|
| 245 |
+
def make_alias(name): # Enforce a closure over *name*.
|
| 246 |
+
@functools.wraps(getattr(cls, name))
|
| 247 |
+
def method(self, *args, **kwargs):
|
| 248 |
+
return getattr(self, name)(*args, **kwargs)
|
| 249 |
+
return method
|
| 250 |
+
|
| 251 |
+
for prop, aliases in alias_d.items():
|
| 252 |
+
exists = False
|
| 253 |
+
for prefix in ["get_", "set_"]:
|
| 254 |
+
if prefix + prop in vars(cls):
|
| 255 |
+
exists = True
|
| 256 |
+
for alias in aliases:
|
| 257 |
+
method = make_alias(prefix + prop)
|
| 258 |
+
method.__name__ = prefix + alias
|
| 259 |
+
method.__doc__ = f"Alias for `{prefix + prop}`."
|
| 260 |
+
setattr(cls, prefix + alias, method)
|
| 261 |
+
if not exists:
|
| 262 |
+
raise ValueError(
|
| 263 |
+
f"Neither getter nor setter exists for {prop!r}")
|
| 264 |
+
|
| 265 |
+
def get_aliased_and_aliases(d):
|
| 266 |
+
return {*d, *(alias for aliases in d.values() for alias in aliases)}
|
| 267 |
+
|
| 268 |
+
preexisting_aliases = getattr(cls, "_alias_map", {})
|
| 269 |
+
conflicting = (get_aliased_and_aliases(preexisting_aliases)
|
| 270 |
+
& get_aliased_and_aliases(alias_d))
|
| 271 |
+
if conflicting:
|
| 272 |
+
# Need to decide on conflict resolution policy.
|
| 273 |
+
raise NotImplementedError(
|
| 274 |
+
f"Parent class already defines conflicting aliases: {conflicting}")
|
| 275 |
+
cls._alias_map = {**preexisting_aliases, **alias_d}
|
| 276 |
+
return cls
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def select_matching_signature(funcs, *args, **kwargs):
|
| 280 |
+
"""
|
| 281 |
+
Select and call the function that accepts ``*args, **kwargs``.
|
| 282 |
+
|
| 283 |
+
*funcs* is a list of functions which should not raise any exception (other
|
| 284 |
+
than `TypeError` if the arguments passed do not match their signature).
|
| 285 |
+
|
| 286 |
+
`select_matching_signature` tries to call each of the functions in *funcs*
|
| 287 |
+
with ``*args, **kwargs`` (in the order in which they are given). Calls
|
| 288 |
+
that fail with a `TypeError` are silently skipped. As soon as a call
|
| 289 |
+
succeeds, `select_matching_signature` returns its return value. If no
|
| 290 |
+
function accepts ``*args, **kwargs``, then the `TypeError` raised by the
|
| 291 |
+
last failing call is re-raised.
|
| 292 |
+
|
| 293 |
+
Callers should normally make sure that any ``*args, **kwargs`` can only
|
| 294 |
+
bind a single *func* (to avoid any ambiguity), although this is not checked
|
| 295 |
+
by `select_matching_signature`.
|
| 296 |
+
|
| 297 |
+
Notes
|
| 298 |
+
-----
|
| 299 |
+
`select_matching_signature` is intended to help implementing
|
| 300 |
+
signature-overloaded functions. In general, such functions should be
|
| 301 |
+
avoided, except for back-compatibility concerns. A typical use pattern is
|
| 302 |
+
::
|
| 303 |
+
|
| 304 |
+
def my_func(*args, **kwargs):
|
| 305 |
+
params = select_matching_signature(
|
| 306 |
+
[lambda old1, old2: locals(), lambda new: locals()],
|
| 307 |
+
*args, **kwargs)
|
| 308 |
+
if "old1" in params:
|
| 309 |
+
warn_deprecated(...)
|
| 310 |
+
old1, old2 = params.values() # note that locals() is ordered.
|
| 311 |
+
else:
|
| 312 |
+
new, = params.values()
|
| 313 |
+
# do things with params
|
| 314 |
+
|
| 315 |
+
which allows *my_func* to be called either with two parameters (*old1* and
|
| 316 |
+
*old2*) or a single one (*new*). Note that the new signature is given
|
| 317 |
+
last, so that callers get a `TypeError` corresponding to the new signature
|
| 318 |
+
if the arguments they passed in do not match any signature.
|
| 319 |
+
"""
|
| 320 |
+
# Rather than relying on locals() ordering, one could have just used func's
|
| 321 |
+
# signature (``bound = inspect.signature(func).bind(*args, **kwargs);
|
| 322 |
+
# bound.apply_defaults(); return bound``) but that is significantly slower.
|
| 323 |
+
for i, func in enumerate(funcs):
|
| 324 |
+
try:
|
| 325 |
+
return func(*args, **kwargs)
|
| 326 |
+
except TypeError:
|
| 327 |
+
if i == len(funcs) - 1:
|
| 328 |
+
raise
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
def nargs_error(name, takes, given):
|
| 332 |
+
"""Generate a TypeError to be raised by function calls with wrong arity."""
|
| 333 |
+
return TypeError(f"{name}() takes {takes} positional arguments but "
|
| 334 |
+
f"{given} were given")
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
def kwarg_error(name, kw):
|
| 338 |
+
"""
|
| 339 |
+
Generate a TypeError to be raised by function calls with wrong kwarg.
|
| 340 |
+
|
| 341 |
+
Parameters
|
| 342 |
+
----------
|
| 343 |
+
name : str
|
| 344 |
+
The name of the calling function.
|
| 345 |
+
kw : str or Iterable[str]
|
| 346 |
+
Either the invalid keyword argument name, or an iterable yielding
|
| 347 |
+
invalid keyword arguments (e.g., a ``kwargs`` dict).
|
| 348 |
+
"""
|
| 349 |
+
if not isinstance(kw, str):
|
| 350 |
+
kw = next(iter(kw))
|
| 351 |
+
return TypeError(f"{name}() got an unexpected keyword argument '{kw}'")
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
def recursive_subclasses(cls):
|
| 355 |
+
"""Yield *cls* and direct and indirect subclasses of *cls*."""
|
| 356 |
+
yield cls
|
| 357 |
+
for subcls in cls.__subclasses__():
|
| 358 |
+
yield from recursive_subclasses(subcls)
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
def warn_external(message, category=None):
|
| 362 |
+
"""
|
| 363 |
+
`warnings.warn` wrapper that sets *stacklevel* to "outside Matplotlib".
|
| 364 |
+
|
| 365 |
+
The original emitter of the warning can be obtained by patching this
|
| 366 |
+
function back to `warnings.warn`, i.e. ``_api.warn_external =
|
| 367 |
+
warnings.warn`` (or ``functools.partial(warnings.warn, stacklevel=2)``,
|
| 368 |
+
etc.).
|
| 369 |
+
"""
|
| 370 |
+
kwargs = {}
|
| 371 |
+
if sys.version_info[:2] >= (3, 12):
|
| 372 |
+
# Go to Python's `site-packages` or `lib` from an editable install.
|
| 373 |
+
basedir = pathlib.Path(__file__).parents[2]
|
| 374 |
+
kwargs['skip_file_prefixes'] = (str(basedir / 'matplotlib'),
|
| 375 |
+
str(basedir / 'mpl_toolkits'))
|
| 376 |
+
else:
|
| 377 |
+
frame = sys._getframe()
|
| 378 |
+
for stacklevel in itertools.count(1):
|
| 379 |
+
if frame is None:
|
| 380 |
+
# when called in embedded context may hit frame is None
|
| 381 |
+
kwargs['stacklevel'] = stacklevel
|
| 382 |
+
break
|
| 383 |
+
if not re.match(r"\A(matplotlib|mpl_toolkits)(\Z|\.(?!tests\.))",
|
| 384 |
+
# Work around sphinx-gallery not setting __name__.
|
| 385 |
+
frame.f_globals.get("__name__", "")):
|
| 386 |
+
kwargs['stacklevel'] = stacklevel
|
| 387 |
+
break
|
| 388 |
+
frame = frame.f_back
|
| 389 |
+
# preemptively break reference cycle between locals and the frame
|
| 390 |
+
del frame
|
| 391 |
+
warnings.warn(message, category, **kwargs)
|
llava_video/lib/python3.10/site-packages/matplotlib/_api/__init__.pyi
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable, Generator, Iterable, Mapping, Sequence
|
| 2 |
+
from typing import Any, TypeVar, overload
|
| 3 |
+
from typing_extensions import Self # < Py 3.11
|
| 4 |
+
|
| 5 |
+
from numpy.typing import NDArray
|
| 6 |
+
|
| 7 |
+
from .deprecation import ( # noqa: F401, re-exported API
|
| 8 |
+
deprecated as deprecated,
|
| 9 |
+
warn_deprecated as warn_deprecated,
|
| 10 |
+
rename_parameter as rename_parameter,
|
| 11 |
+
delete_parameter as delete_parameter,
|
| 12 |
+
make_keyword_only as make_keyword_only,
|
| 13 |
+
deprecate_method_override as deprecate_method_override,
|
| 14 |
+
deprecate_privatize_attribute as deprecate_privatize_attribute,
|
| 15 |
+
suppress_matplotlib_deprecation_warning as suppress_matplotlib_deprecation_warning,
|
| 16 |
+
MatplotlibDeprecationWarning as MatplotlibDeprecationWarning,
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
_T = TypeVar("_T")
|
| 20 |
+
|
| 21 |
+
class classproperty(Any):
|
| 22 |
+
def __init__(
|
| 23 |
+
self,
|
| 24 |
+
fget: Callable[[_T], Any],
|
| 25 |
+
fset: None = ...,
|
| 26 |
+
fdel: None = ...,
|
| 27 |
+
doc: str | None = None,
|
| 28 |
+
): ...
|
| 29 |
+
@overload
|
| 30 |
+
def __get__(self, instance: None, owner: None) -> Self: ...
|
| 31 |
+
@overload
|
| 32 |
+
def __get__(self, instance: object, owner: type[object]) -> Any: ...
|
| 33 |
+
@property
|
| 34 |
+
def fget(self) -> Callable[[_T], Any]: ...
|
| 35 |
+
|
| 36 |
+
def check_isinstance(
|
| 37 |
+
types: type | tuple[type | None, ...], /, **kwargs: Any
|
| 38 |
+
) -> None: ...
|
| 39 |
+
def check_in_list(
|
| 40 |
+
values: Sequence[Any], /, *, _print_supported_values: bool = ..., **kwargs: Any
|
| 41 |
+
) -> None: ...
|
| 42 |
+
def check_shape(shape: tuple[int | None, ...], /, **kwargs: NDArray) -> None: ...
|
| 43 |
+
def check_getitem(mapping: Mapping[Any, Any], /, **kwargs: Any) -> Any: ...
|
| 44 |
+
def caching_module_getattr(cls: type) -> Callable[[str], Any]: ...
|
| 45 |
+
@overload
|
| 46 |
+
def define_aliases(
|
| 47 |
+
alias_d: dict[str, list[str]], cls: None = ...
|
| 48 |
+
) -> Callable[[type[_T]], type[_T]]: ...
|
| 49 |
+
@overload
|
| 50 |
+
def define_aliases(alias_d: dict[str, list[str]], cls: type[_T]) -> type[_T]: ...
|
| 51 |
+
def select_matching_signature(
|
| 52 |
+
funcs: list[Callable], *args: Any, **kwargs: Any
|
| 53 |
+
) -> Any: ...
|
| 54 |
+
def nargs_error(name: str, takes: int | str, given: int) -> TypeError: ...
|
| 55 |
+
def kwarg_error(name: str, kw: str | Iterable[str]) -> TypeError: ...
|
| 56 |
+
def recursive_subclasses(cls: type) -> Generator[type, None, None]: ...
|
| 57 |
+
def warn_external(
|
| 58 |
+
message: str | Warning, category: type[Warning] | None = ...
|
| 59 |
+
) -> None: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/_api/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (13.7 kB). View file
|
|
|
llava_video/lib/python3.10/site-packages/matplotlib/_api/__pycache__/deprecation.cpython-310.pyc
ADDED
|
Binary file (17.8 kB). View file
|
|
|
llava_video/lib/python3.10/site-packages/matplotlib/_api/deprecation.py
ADDED
|
@@ -0,0 +1,509 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Helper functions for deprecating parts of the Matplotlib API.
|
| 3 |
+
|
| 4 |
+
This documentation is only relevant for Matplotlib developers, not for users.
|
| 5 |
+
|
| 6 |
+
.. warning::
|
| 7 |
+
|
| 8 |
+
This module is for internal use only. Do not use it in your own code.
|
| 9 |
+
We may change the API at any time with no warning.
|
| 10 |
+
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import contextlib
|
| 14 |
+
import functools
|
| 15 |
+
import inspect
|
| 16 |
+
import math
|
| 17 |
+
import warnings
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class MatplotlibDeprecationWarning(DeprecationWarning):
|
| 21 |
+
"""A class for issuing deprecation warnings for Matplotlib users."""
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _generate_deprecation_warning(
|
| 25 |
+
since, message='', name='', alternative='', pending=False, obj_type='',
|
| 26 |
+
addendum='', *, removal=''):
|
| 27 |
+
if pending:
|
| 28 |
+
if removal:
|
| 29 |
+
raise ValueError("A pending deprecation cannot have a scheduled removal")
|
| 30 |
+
elif removal == '':
|
| 31 |
+
macro, meso, *_ = since.split('.')
|
| 32 |
+
removal = f'{macro}.{int(meso) + 2}'
|
| 33 |
+
if not message:
|
| 34 |
+
message = (
|
| 35 |
+
("The %(name)s %(obj_type)s" if obj_type else "%(name)s") +
|
| 36 |
+
(" will be deprecated in a future version" if pending else
|
| 37 |
+
(" was deprecated in Matplotlib %(since)s" +
|
| 38 |
+
(" and will be removed in %(removal)s" if removal else ""))) +
|
| 39 |
+
"." +
|
| 40 |
+
(" Use %(alternative)s instead." if alternative else "") +
|
| 41 |
+
(" %(addendum)s" if addendum else ""))
|
| 42 |
+
warning_cls = PendingDeprecationWarning if pending else MatplotlibDeprecationWarning
|
| 43 |
+
return warning_cls(message % dict(
|
| 44 |
+
func=name, name=name, obj_type=obj_type, since=since, removal=removal,
|
| 45 |
+
alternative=alternative, addendum=addendum))
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def warn_deprecated(
|
| 49 |
+
since, *, message='', name='', alternative='', pending=False,
|
| 50 |
+
obj_type='', addendum='', removal=''):
|
| 51 |
+
"""
|
| 52 |
+
Display a standardized deprecation.
|
| 53 |
+
|
| 54 |
+
Parameters
|
| 55 |
+
----------
|
| 56 |
+
since : str
|
| 57 |
+
The release at which this API became deprecated.
|
| 58 |
+
message : str, optional
|
| 59 |
+
Override the default deprecation message. The ``%(since)s``,
|
| 60 |
+
``%(name)s``, ``%(alternative)s``, ``%(obj_type)s``, ``%(addendum)s``,
|
| 61 |
+
and ``%(removal)s`` format specifiers will be replaced by the values
|
| 62 |
+
of the respective arguments passed to this function.
|
| 63 |
+
name : str, optional
|
| 64 |
+
The name of the deprecated object.
|
| 65 |
+
alternative : str, optional
|
| 66 |
+
An alternative API that the user may use in place of the deprecated
|
| 67 |
+
API. The deprecation warning will tell the user about this alternative
|
| 68 |
+
if provided.
|
| 69 |
+
pending : bool, optional
|
| 70 |
+
If True, uses a PendingDeprecationWarning instead of a
|
| 71 |
+
DeprecationWarning. Cannot be used together with *removal*.
|
| 72 |
+
obj_type : str, optional
|
| 73 |
+
The object type being deprecated.
|
| 74 |
+
addendum : str, optional
|
| 75 |
+
Additional text appended directly to the final message.
|
| 76 |
+
removal : str, optional
|
| 77 |
+
The expected removal version. With the default (an empty string), a
|
| 78 |
+
removal version is automatically computed from *since*. Set to other
|
| 79 |
+
Falsy values to not schedule a removal date. Cannot be used together
|
| 80 |
+
with *pending*.
|
| 81 |
+
|
| 82 |
+
Examples
|
| 83 |
+
--------
|
| 84 |
+
::
|
| 85 |
+
|
| 86 |
+
# To warn of the deprecation of "matplotlib.name_of_module"
|
| 87 |
+
warn_deprecated('1.4.0', name='matplotlib.name_of_module',
|
| 88 |
+
obj_type='module')
|
| 89 |
+
"""
|
| 90 |
+
warning = _generate_deprecation_warning(
|
| 91 |
+
since, message, name, alternative, pending, obj_type, addendum,
|
| 92 |
+
removal=removal)
|
| 93 |
+
from . import warn_external
|
| 94 |
+
warn_external(warning, category=MatplotlibDeprecationWarning)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def deprecated(since, *, message='', name='', alternative='', pending=False,
|
| 98 |
+
obj_type=None, addendum='', removal=''):
|
| 99 |
+
"""
|
| 100 |
+
Decorator to mark a function, a class, or a property as deprecated.
|
| 101 |
+
|
| 102 |
+
When deprecating a classmethod, a staticmethod, or a property, the
|
| 103 |
+
``@deprecated`` decorator should go *under* ``@classmethod`` and
|
| 104 |
+
``@staticmethod`` (i.e., `deprecated` should directly decorate the
|
| 105 |
+
underlying callable), but *over* ``@property``.
|
| 106 |
+
|
| 107 |
+
When deprecating a class ``C`` intended to be used as a base class in a
|
| 108 |
+
multiple inheritance hierarchy, ``C`` *must* define an ``__init__`` method
|
| 109 |
+
(if ``C`` instead inherited its ``__init__`` from its own base class, then
|
| 110 |
+
``@deprecated`` would mess up ``__init__`` inheritance when installing its
|
| 111 |
+
own (deprecation-emitting) ``C.__init__``).
|
| 112 |
+
|
| 113 |
+
Parameters are the same as for `warn_deprecated`, except that *obj_type*
|
| 114 |
+
defaults to 'class' if decorating a class, 'attribute' if decorating a
|
| 115 |
+
property, and 'function' otherwise.
|
| 116 |
+
|
| 117 |
+
Examples
|
| 118 |
+
--------
|
| 119 |
+
::
|
| 120 |
+
|
| 121 |
+
@deprecated('1.4.0')
|
| 122 |
+
def the_function_to_deprecate():
|
| 123 |
+
pass
|
| 124 |
+
"""
|
| 125 |
+
|
| 126 |
+
def deprecate(obj, message=message, name=name, alternative=alternative,
|
| 127 |
+
pending=pending, obj_type=obj_type, addendum=addendum):
|
| 128 |
+
from matplotlib._api import classproperty
|
| 129 |
+
|
| 130 |
+
if isinstance(obj, type):
|
| 131 |
+
if obj_type is None:
|
| 132 |
+
obj_type = "class"
|
| 133 |
+
func = obj.__init__
|
| 134 |
+
name = name or obj.__name__
|
| 135 |
+
old_doc = obj.__doc__
|
| 136 |
+
|
| 137 |
+
def finalize(wrapper, new_doc):
|
| 138 |
+
try:
|
| 139 |
+
obj.__doc__ = new_doc
|
| 140 |
+
except AttributeError: # Can't set on some extension objects.
|
| 141 |
+
pass
|
| 142 |
+
obj.__init__ = functools.wraps(obj.__init__)(wrapper)
|
| 143 |
+
return obj
|
| 144 |
+
|
| 145 |
+
elif isinstance(obj, (property, classproperty)):
|
| 146 |
+
if obj_type is None:
|
| 147 |
+
obj_type = "attribute"
|
| 148 |
+
func = None
|
| 149 |
+
name = name or obj.fget.__name__
|
| 150 |
+
old_doc = obj.__doc__
|
| 151 |
+
|
| 152 |
+
class _deprecated_property(type(obj)):
|
| 153 |
+
def __get__(self, instance, owner=None):
|
| 154 |
+
if instance is not None or owner is not None \
|
| 155 |
+
and isinstance(self, classproperty):
|
| 156 |
+
emit_warning()
|
| 157 |
+
return super().__get__(instance, owner)
|
| 158 |
+
|
| 159 |
+
def __set__(self, instance, value):
|
| 160 |
+
if instance is not None:
|
| 161 |
+
emit_warning()
|
| 162 |
+
return super().__set__(instance, value)
|
| 163 |
+
|
| 164 |
+
def __delete__(self, instance):
|
| 165 |
+
if instance is not None:
|
| 166 |
+
emit_warning()
|
| 167 |
+
return super().__delete__(instance)
|
| 168 |
+
|
| 169 |
+
def __set_name__(self, owner, set_name):
|
| 170 |
+
nonlocal name
|
| 171 |
+
if name == "<lambda>":
|
| 172 |
+
name = set_name
|
| 173 |
+
|
| 174 |
+
def finalize(_, new_doc):
|
| 175 |
+
return _deprecated_property(
|
| 176 |
+
fget=obj.fget, fset=obj.fset, fdel=obj.fdel, doc=new_doc)
|
| 177 |
+
|
| 178 |
+
else:
|
| 179 |
+
if obj_type is None:
|
| 180 |
+
obj_type = "function"
|
| 181 |
+
func = obj
|
| 182 |
+
name = name or obj.__name__
|
| 183 |
+
old_doc = func.__doc__
|
| 184 |
+
|
| 185 |
+
def finalize(wrapper, new_doc):
|
| 186 |
+
wrapper = functools.wraps(func)(wrapper)
|
| 187 |
+
wrapper.__doc__ = new_doc
|
| 188 |
+
return wrapper
|
| 189 |
+
|
| 190 |
+
def emit_warning():
|
| 191 |
+
warn_deprecated(
|
| 192 |
+
since, message=message, name=name, alternative=alternative,
|
| 193 |
+
pending=pending, obj_type=obj_type, addendum=addendum,
|
| 194 |
+
removal=removal)
|
| 195 |
+
|
| 196 |
+
def wrapper(*args, **kwargs):
|
| 197 |
+
emit_warning()
|
| 198 |
+
return func(*args, **kwargs)
|
| 199 |
+
|
| 200 |
+
old_doc = inspect.cleandoc(old_doc or '').strip('\n')
|
| 201 |
+
|
| 202 |
+
notes_header = '\nNotes\n-----'
|
| 203 |
+
second_arg = ' '.join([t.strip() for t in
|
| 204 |
+
(message, f"Use {alternative} instead."
|
| 205 |
+
if alternative else "", addendum) if t])
|
| 206 |
+
new_doc = (f"[*Deprecated*] {old_doc}\n"
|
| 207 |
+
f"{notes_header if notes_header not in old_doc else ''}\n"
|
| 208 |
+
f".. deprecated:: {since}\n"
|
| 209 |
+
f" {second_arg}")
|
| 210 |
+
|
| 211 |
+
if not old_doc:
|
| 212 |
+
# This is to prevent a spurious 'unexpected unindent' warning from
|
| 213 |
+
# docutils when the original docstring was blank.
|
| 214 |
+
new_doc += r'\ '
|
| 215 |
+
|
| 216 |
+
return finalize(wrapper, new_doc)
|
| 217 |
+
|
| 218 |
+
return deprecate
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
class deprecate_privatize_attribute:
|
| 222 |
+
"""
|
| 223 |
+
Helper to deprecate public access to an attribute (or method).
|
| 224 |
+
|
| 225 |
+
This helper should only be used at class scope, as follows::
|
| 226 |
+
|
| 227 |
+
class Foo:
|
| 228 |
+
attr = _deprecate_privatize_attribute(*args, **kwargs)
|
| 229 |
+
|
| 230 |
+
where *all* parameters are forwarded to `deprecated`. This form makes
|
| 231 |
+
``attr`` a property which forwards read and write access to ``self._attr``
|
| 232 |
+
(same name but with a leading underscore), with a deprecation warning.
|
| 233 |
+
Note that the attribute name is derived from *the name this helper is
|
| 234 |
+
assigned to*. This helper also works for deprecating methods.
|
| 235 |
+
"""
|
| 236 |
+
|
| 237 |
+
def __init__(self, *args, **kwargs):
|
| 238 |
+
self.deprecator = deprecated(*args, **kwargs)
|
| 239 |
+
|
| 240 |
+
def __set_name__(self, owner, name):
|
| 241 |
+
setattr(owner, name, self.deprecator(
|
| 242 |
+
property(lambda self: getattr(self, f"_{name}"),
|
| 243 |
+
lambda self, value: setattr(self, f"_{name}", value)),
|
| 244 |
+
name=name))
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
# Used by _copy_docstring_and_deprecators to redecorate pyplot wrappers and
|
| 248 |
+
# boilerplate.py to retrieve original signatures. It may seem natural to store
|
| 249 |
+
# this information as an attribute on the wrapper, but if the wrapper gets
|
| 250 |
+
# itself functools.wraps()ed, then such attributes are silently propagated to
|
| 251 |
+
# the outer wrapper, which is not desired.
|
| 252 |
+
DECORATORS = {}
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
def rename_parameter(since, old, new, func=None):
|
| 256 |
+
"""
|
| 257 |
+
Decorator indicating that parameter *old* of *func* is renamed to *new*.
|
| 258 |
+
|
| 259 |
+
The actual implementation of *func* should use *new*, not *old*. If *old*
|
| 260 |
+
is passed to *func*, a DeprecationWarning is emitted, and its value is
|
| 261 |
+
used, even if *new* is also passed by keyword (this is to simplify pyplot
|
| 262 |
+
wrapper functions, which always pass *new* explicitly to the Axes method).
|
| 263 |
+
If *new* is also passed but positionally, a TypeError will be raised by the
|
| 264 |
+
underlying function during argument binding.
|
| 265 |
+
|
| 266 |
+
Examples
|
| 267 |
+
--------
|
| 268 |
+
::
|
| 269 |
+
|
| 270 |
+
@_api.rename_parameter("3.1", "bad_name", "good_name")
|
| 271 |
+
def func(good_name): ...
|
| 272 |
+
"""
|
| 273 |
+
|
| 274 |
+
decorator = functools.partial(rename_parameter, since, old, new)
|
| 275 |
+
|
| 276 |
+
if func is None:
|
| 277 |
+
return decorator
|
| 278 |
+
|
| 279 |
+
signature = inspect.signature(func)
|
| 280 |
+
assert old not in signature.parameters, (
|
| 281 |
+
f"Matplotlib internal error: {old!r} cannot be a parameter for "
|
| 282 |
+
f"{func.__name__}()")
|
| 283 |
+
assert new in signature.parameters, (
|
| 284 |
+
f"Matplotlib internal error: {new!r} must be a parameter for "
|
| 285 |
+
f"{func.__name__}()")
|
| 286 |
+
|
| 287 |
+
@functools.wraps(func)
|
| 288 |
+
def wrapper(*args, **kwargs):
|
| 289 |
+
if old in kwargs:
|
| 290 |
+
warn_deprecated(
|
| 291 |
+
since, message=f"The {old!r} parameter of {func.__name__}() "
|
| 292 |
+
f"has been renamed {new!r} since Matplotlib {since}; support "
|
| 293 |
+
f"for the old name will be dropped in %(removal)s.")
|
| 294 |
+
kwargs[new] = kwargs.pop(old)
|
| 295 |
+
return func(*args, **kwargs)
|
| 296 |
+
|
| 297 |
+
# wrapper() must keep the same documented signature as func(): if we
|
| 298 |
+
# instead made both *old* and *new* appear in wrapper()'s signature, they
|
| 299 |
+
# would both show up in the pyplot function for an Axes method as well and
|
| 300 |
+
# pyplot would explicitly pass both arguments to the Axes method.
|
| 301 |
+
|
| 302 |
+
DECORATORS[wrapper] = decorator
|
| 303 |
+
return wrapper
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
class _deprecated_parameter_class:
|
| 307 |
+
def __repr__(self):
|
| 308 |
+
return "<deprecated parameter>"
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
_deprecated_parameter = _deprecated_parameter_class()
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
def delete_parameter(since, name, func=None, **kwargs):
|
| 315 |
+
"""
|
| 316 |
+
Decorator indicating that parameter *name* of *func* is being deprecated.
|
| 317 |
+
|
| 318 |
+
The actual implementation of *func* should keep the *name* parameter in its
|
| 319 |
+
signature, or accept a ``**kwargs`` argument (through which *name* would be
|
| 320 |
+
passed).
|
| 321 |
+
|
| 322 |
+
Parameters that come after the deprecated parameter effectively become
|
| 323 |
+
keyword-only (as they cannot be passed positionally without triggering the
|
| 324 |
+
DeprecationWarning on the deprecated parameter), and should be marked as
|
| 325 |
+
such after the deprecation period has passed and the deprecated parameter
|
| 326 |
+
is removed.
|
| 327 |
+
|
| 328 |
+
Parameters other than *since*, *name*, and *func* are keyword-only and
|
| 329 |
+
forwarded to `.warn_deprecated`.
|
| 330 |
+
|
| 331 |
+
Examples
|
| 332 |
+
--------
|
| 333 |
+
::
|
| 334 |
+
|
| 335 |
+
@_api.delete_parameter("3.1", "unused")
|
| 336 |
+
def func(used_arg, other_arg, unused, more_args): ...
|
| 337 |
+
"""
|
| 338 |
+
|
| 339 |
+
decorator = functools.partial(delete_parameter, since, name, **kwargs)
|
| 340 |
+
|
| 341 |
+
if func is None:
|
| 342 |
+
return decorator
|
| 343 |
+
|
| 344 |
+
signature = inspect.signature(func)
|
| 345 |
+
# Name of `**kwargs` parameter of the decorated function, typically
|
| 346 |
+
# "kwargs" if such a parameter exists, or None if the decorated function
|
| 347 |
+
# doesn't accept `**kwargs`.
|
| 348 |
+
kwargs_name = next((param.name for param in signature.parameters.values()
|
| 349 |
+
if param.kind == inspect.Parameter.VAR_KEYWORD), None)
|
| 350 |
+
if name in signature.parameters:
|
| 351 |
+
kind = signature.parameters[name].kind
|
| 352 |
+
is_varargs = kind is inspect.Parameter.VAR_POSITIONAL
|
| 353 |
+
is_varkwargs = kind is inspect.Parameter.VAR_KEYWORD
|
| 354 |
+
if not is_varargs and not is_varkwargs:
|
| 355 |
+
name_idx = (
|
| 356 |
+
# Deprecated parameter can't be passed positionally.
|
| 357 |
+
math.inf if kind is inspect.Parameter.KEYWORD_ONLY
|
| 358 |
+
# If call site has no more than this number of parameters, the
|
| 359 |
+
# deprecated parameter can't have been passed positionally.
|
| 360 |
+
else [*signature.parameters].index(name))
|
| 361 |
+
func.__signature__ = signature = signature.replace(parameters=[
|
| 362 |
+
param.replace(default=_deprecated_parameter)
|
| 363 |
+
if param.name == name else param
|
| 364 |
+
for param in signature.parameters.values()])
|
| 365 |
+
else:
|
| 366 |
+
name_idx = -1 # Deprecated parameter can always have been passed.
|
| 367 |
+
else:
|
| 368 |
+
is_varargs = is_varkwargs = False
|
| 369 |
+
# Deprecated parameter can't be passed positionally.
|
| 370 |
+
name_idx = math.inf
|
| 371 |
+
assert kwargs_name, (
|
| 372 |
+
f"Matplotlib internal error: {name!r} must be a parameter for "
|
| 373 |
+
f"{func.__name__}()")
|
| 374 |
+
|
| 375 |
+
addendum = kwargs.pop('addendum', None)
|
| 376 |
+
|
| 377 |
+
@functools.wraps(func)
|
| 378 |
+
def wrapper(*inner_args, **inner_kwargs):
|
| 379 |
+
if len(inner_args) <= name_idx and name not in inner_kwargs:
|
| 380 |
+
# Early return in the simple, non-deprecated case (much faster than
|
| 381 |
+
# calling bind()).
|
| 382 |
+
return func(*inner_args, **inner_kwargs)
|
| 383 |
+
arguments = signature.bind(*inner_args, **inner_kwargs).arguments
|
| 384 |
+
if is_varargs and arguments.get(name):
|
| 385 |
+
warn_deprecated(
|
| 386 |
+
since, message=f"Additional positional arguments to "
|
| 387 |
+
f"{func.__name__}() are deprecated since %(since)s and "
|
| 388 |
+
f"support for them will be removed in %(removal)s.")
|
| 389 |
+
elif is_varkwargs and arguments.get(name):
|
| 390 |
+
warn_deprecated(
|
| 391 |
+
since, message=f"Additional keyword arguments to "
|
| 392 |
+
f"{func.__name__}() are deprecated since %(since)s and "
|
| 393 |
+
f"support for them will be removed in %(removal)s.")
|
| 394 |
+
# We cannot just check `name not in arguments` because the pyplot
|
| 395 |
+
# wrappers always pass all arguments explicitly.
|
| 396 |
+
elif any(name in d and d[name] != _deprecated_parameter
|
| 397 |
+
for d in [arguments, arguments.get(kwargs_name, {})]):
|
| 398 |
+
deprecation_addendum = (
|
| 399 |
+
f"If any parameter follows {name!r}, they should be passed as "
|
| 400 |
+
f"keyword, not positionally.")
|
| 401 |
+
warn_deprecated(
|
| 402 |
+
since,
|
| 403 |
+
name=repr(name),
|
| 404 |
+
obj_type=f"parameter of {func.__name__}()",
|
| 405 |
+
addendum=(addendum + " " + deprecation_addendum) if addendum
|
| 406 |
+
else deprecation_addendum,
|
| 407 |
+
**kwargs)
|
| 408 |
+
return func(*inner_args, **inner_kwargs)
|
| 409 |
+
|
| 410 |
+
DECORATORS[wrapper] = decorator
|
| 411 |
+
return wrapper
|
| 412 |
+
|
| 413 |
+
|
| 414 |
+
def make_keyword_only(since, name, func=None):
|
| 415 |
+
"""
|
| 416 |
+
Decorator indicating that passing parameter *name* (or any of the following
|
| 417 |
+
ones) positionally to *func* is being deprecated.
|
| 418 |
+
|
| 419 |
+
When used on a method that has a pyplot wrapper, this should be the
|
| 420 |
+
outermost decorator, so that :file:`boilerplate.py` can access the original
|
| 421 |
+
signature.
|
| 422 |
+
"""
|
| 423 |
+
|
| 424 |
+
decorator = functools.partial(make_keyword_only, since, name)
|
| 425 |
+
|
| 426 |
+
if func is None:
|
| 427 |
+
return decorator
|
| 428 |
+
|
| 429 |
+
signature = inspect.signature(func)
|
| 430 |
+
POK = inspect.Parameter.POSITIONAL_OR_KEYWORD
|
| 431 |
+
KWO = inspect.Parameter.KEYWORD_ONLY
|
| 432 |
+
assert (name in signature.parameters
|
| 433 |
+
and signature.parameters[name].kind == POK), (
|
| 434 |
+
f"Matplotlib internal error: {name!r} must be a positional-or-keyword "
|
| 435 |
+
f"parameter for {func.__name__}(). If this error happens on a function with a "
|
| 436 |
+
f"pyplot wrapper, make sure make_keyword_only() is the outermost decorator.")
|
| 437 |
+
names = [*signature.parameters]
|
| 438 |
+
name_idx = names.index(name)
|
| 439 |
+
kwonly = [name for name in names[name_idx:]
|
| 440 |
+
if signature.parameters[name].kind == POK]
|
| 441 |
+
|
| 442 |
+
@functools.wraps(func)
|
| 443 |
+
def wrapper(*args, **kwargs):
|
| 444 |
+
# Don't use signature.bind here, as it would fail when stacked with
|
| 445 |
+
# rename_parameter and an "old" argument name is passed in
|
| 446 |
+
# (signature.bind would fail, but the actual call would succeed).
|
| 447 |
+
if len(args) > name_idx:
|
| 448 |
+
warn_deprecated(
|
| 449 |
+
since, message="Passing the %(name)s %(obj_type)s "
|
| 450 |
+
"positionally is deprecated since Matplotlib %(since)s; the "
|
| 451 |
+
"parameter will become keyword-only in %(removal)s.",
|
| 452 |
+
name=name, obj_type=f"parameter of {func.__name__}()")
|
| 453 |
+
return func(*args, **kwargs)
|
| 454 |
+
|
| 455 |
+
# Don't modify *func*'s signature, as boilerplate.py needs it.
|
| 456 |
+
wrapper.__signature__ = signature.replace(parameters=[
|
| 457 |
+
param.replace(kind=KWO) if param.name in kwonly else param
|
| 458 |
+
for param in signature.parameters.values()])
|
| 459 |
+
DECORATORS[wrapper] = decorator
|
| 460 |
+
return wrapper
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
def deprecate_method_override(method, obj, *, allow_empty=False, **kwargs):
|
| 464 |
+
"""
|
| 465 |
+
Return ``obj.method`` with a deprecation if it was overridden, else None.
|
| 466 |
+
|
| 467 |
+
Parameters
|
| 468 |
+
----------
|
| 469 |
+
method
|
| 470 |
+
An unbound method, i.e. an expression of the form
|
| 471 |
+
``Class.method_name``. Remember that within the body of a method, one
|
| 472 |
+
can always use ``__class__`` to refer to the class that is currently
|
| 473 |
+
being defined.
|
| 474 |
+
obj
|
| 475 |
+
Either an object of the class where *method* is defined, or a subclass
|
| 476 |
+
of that class.
|
| 477 |
+
allow_empty : bool, default: False
|
| 478 |
+
Whether to allow overrides by "empty" methods without emitting a
|
| 479 |
+
warning.
|
| 480 |
+
**kwargs
|
| 481 |
+
Additional parameters passed to `warn_deprecated` to generate the
|
| 482 |
+
deprecation warning; must at least include the "since" key.
|
| 483 |
+
"""
|
| 484 |
+
|
| 485 |
+
def empty(): pass
|
| 486 |
+
def empty_with_docstring(): """doc"""
|
| 487 |
+
|
| 488 |
+
name = method.__name__
|
| 489 |
+
bound_child = getattr(obj, name)
|
| 490 |
+
bound_base = (
|
| 491 |
+
method # If obj is a class, then we need to use unbound methods.
|
| 492 |
+
if isinstance(bound_child, type(empty)) and isinstance(obj, type)
|
| 493 |
+
else method.__get__(obj))
|
| 494 |
+
if (bound_child != bound_base
|
| 495 |
+
and (not allow_empty
|
| 496 |
+
or (getattr(getattr(bound_child, "__code__", None),
|
| 497 |
+
"co_code", None)
|
| 498 |
+
not in [empty.__code__.co_code,
|
| 499 |
+
empty_with_docstring.__code__.co_code]))):
|
| 500 |
+
warn_deprecated(**{"name": name, "obj_type": "method", **kwargs})
|
| 501 |
+
return bound_child
|
| 502 |
+
return None
|
| 503 |
+
|
| 504 |
+
|
| 505 |
+
@contextlib.contextmanager
|
| 506 |
+
def suppress_matplotlib_deprecation_warning():
|
| 507 |
+
with warnings.catch_warnings():
|
| 508 |
+
warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
|
| 509 |
+
yield
|
llava_video/lib/python3.10/site-packages/matplotlib/_api/deprecation.pyi
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable
|
| 2 |
+
import contextlib
|
| 3 |
+
from typing import Any, Literal, ParamSpec, TypedDict, TypeVar, overload
|
| 4 |
+
from typing_extensions import (
|
| 5 |
+
Unpack, # < Py 3.11
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
_P = ParamSpec("_P")
|
| 9 |
+
_R = TypeVar("_R")
|
| 10 |
+
_T = TypeVar("_T")
|
| 11 |
+
|
| 12 |
+
class MatplotlibDeprecationWarning(DeprecationWarning): ...
|
| 13 |
+
|
| 14 |
+
class DeprecationKwargs(TypedDict, total=False):
|
| 15 |
+
message: str
|
| 16 |
+
alternative: str
|
| 17 |
+
pending: bool
|
| 18 |
+
obj_type: str
|
| 19 |
+
addendum: str
|
| 20 |
+
removal: str | Literal[False]
|
| 21 |
+
|
| 22 |
+
class NamedDeprecationKwargs(DeprecationKwargs, total=False):
|
| 23 |
+
name: str
|
| 24 |
+
|
| 25 |
+
def warn_deprecated(since: str, **kwargs: Unpack[NamedDeprecationKwargs]) -> None: ...
|
| 26 |
+
def deprecated(
|
| 27 |
+
since: str, **kwargs: Unpack[NamedDeprecationKwargs]
|
| 28 |
+
) -> Callable[[_T], _T]: ...
|
| 29 |
+
|
| 30 |
+
class deprecate_privatize_attribute(Any):
|
| 31 |
+
def __init__(self, since: str, **kwargs: Unpack[NamedDeprecationKwargs]): ...
|
| 32 |
+
def __set_name__(self, owner: type[object], name: str) -> None: ...
|
| 33 |
+
|
| 34 |
+
DECORATORS: dict[Callable, Callable] = ...
|
| 35 |
+
|
| 36 |
+
@overload
|
| 37 |
+
def rename_parameter(
|
| 38 |
+
since: str, old: str, new: str, func: None = ...
|
| 39 |
+
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
|
| 40 |
+
@overload
|
| 41 |
+
def rename_parameter(
|
| 42 |
+
since: str, old: str, new: str, func: Callable[_P, _R]
|
| 43 |
+
) -> Callable[_P, _R]: ...
|
| 44 |
+
|
| 45 |
+
class _deprecated_parameter_class: ...
|
| 46 |
+
|
| 47 |
+
_deprecated_parameter: _deprecated_parameter_class
|
| 48 |
+
|
| 49 |
+
@overload
|
| 50 |
+
def delete_parameter(
|
| 51 |
+
since: str, name: str, func: None = ..., **kwargs: Unpack[DeprecationKwargs]
|
| 52 |
+
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
|
| 53 |
+
@overload
|
| 54 |
+
def delete_parameter(
|
| 55 |
+
since: str, name: str, func: Callable[_P, _R], **kwargs: Unpack[DeprecationKwargs]
|
| 56 |
+
) -> Callable[_P, _R]: ...
|
| 57 |
+
@overload
|
| 58 |
+
def make_keyword_only(
|
| 59 |
+
since: str, name: str, func: None = ...
|
| 60 |
+
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ...
|
| 61 |
+
@overload
|
| 62 |
+
def make_keyword_only(
|
| 63 |
+
since: str, name: str, func: Callable[_P, _R]
|
| 64 |
+
) -> Callable[_P, _R]: ...
|
| 65 |
+
def deprecate_method_override(
|
| 66 |
+
method: Callable[_P, _R],
|
| 67 |
+
obj: object | type,
|
| 68 |
+
*,
|
| 69 |
+
allow_empty: bool = ...,
|
| 70 |
+
since: str,
|
| 71 |
+
**kwargs: Unpack[NamedDeprecationKwargs]
|
| 72 |
+
) -> Callable[_P, _R]: ...
|
| 73 |
+
def suppress_matplotlib_deprecation_warning() -> (
|
| 74 |
+
contextlib.AbstractContextManager[None]
|
| 75 |
+
): ...
|
llava_video/lib/python3.10/site-packages/matplotlib/_blocking_input.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def blocking_input_loop(figure, event_names, timeout, handler):
|
| 2 |
+
"""
|
| 3 |
+
Run *figure*'s event loop while listening to interactive events.
|
| 4 |
+
|
| 5 |
+
The events listed in *event_names* are passed to *handler*.
|
| 6 |
+
|
| 7 |
+
This function is used to implement `.Figure.waitforbuttonpress`,
|
| 8 |
+
`.Figure.ginput`, and `.Axes.clabel`.
|
| 9 |
+
|
| 10 |
+
Parameters
|
| 11 |
+
----------
|
| 12 |
+
figure : `~matplotlib.figure.Figure`
|
| 13 |
+
event_names : list of str
|
| 14 |
+
The names of the events passed to *handler*.
|
| 15 |
+
timeout : float
|
| 16 |
+
If positive, the event loop is stopped after *timeout* seconds.
|
| 17 |
+
handler : Callable[[Event], Any]
|
| 18 |
+
Function called for each event; it can force an early exit of the event
|
| 19 |
+
loop by calling ``canvas.stop_event_loop()``.
|
| 20 |
+
"""
|
| 21 |
+
if figure.canvas.manager:
|
| 22 |
+
figure.show() # Ensure that the figure is shown if we are managing it.
|
| 23 |
+
# Connect the events to the on_event function call.
|
| 24 |
+
cids = [figure.canvas.mpl_connect(name, handler) for name in event_names]
|
| 25 |
+
try:
|
| 26 |
+
figure.canvas.start_event_loop(timeout) # Start event loop.
|
| 27 |
+
finally: # Run even on exception like ctrl-c.
|
| 28 |
+
# Disconnect the callbacks.
|
| 29 |
+
for cid in cids:
|
| 30 |
+
figure.canvas.mpl_disconnect(cid)
|
llava_video/lib/python3.10/site-packages/matplotlib/_cm.py
ADDED
|
@@ -0,0 +1,1460 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Nothing here but dictionaries for generating LinearSegmentedColormaps,
|
| 3 |
+
and a dictionary of these dictionaries.
|
| 4 |
+
|
| 5 |
+
Documentation for each is in pyplot.colormaps(). Please update this
|
| 6 |
+
with the purpose and type of your colormap if you add data for one here.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from functools import partial
|
| 10 |
+
|
| 11 |
+
import numpy as np
|
| 12 |
+
|
| 13 |
+
_binary_data = {
|
| 14 |
+
'red': ((0., 1., 1.), (1., 0., 0.)),
|
| 15 |
+
'green': ((0., 1., 1.), (1., 0., 0.)),
|
| 16 |
+
'blue': ((0., 1., 1.), (1., 0., 0.))
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
_autumn_data = {'red': ((0., 1.0, 1.0), (1.0, 1.0, 1.0)),
|
| 20 |
+
'green': ((0., 0., 0.), (1.0, 1.0, 1.0)),
|
| 21 |
+
'blue': ((0., 0., 0.), (1.0, 0., 0.))}
|
| 22 |
+
|
| 23 |
+
_bone_data = {'red': ((0., 0., 0.),
|
| 24 |
+
(0.746032, 0.652778, 0.652778),
|
| 25 |
+
(1.0, 1.0, 1.0)),
|
| 26 |
+
'green': ((0., 0., 0.),
|
| 27 |
+
(0.365079, 0.319444, 0.319444),
|
| 28 |
+
(0.746032, 0.777778, 0.777778),
|
| 29 |
+
(1.0, 1.0, 1.0)),
|
| 30 |
+
'blue': ((0., 0., 0.),
|
| 31 |
+
(0.365079, 0.444444, 0.444444),
|
| 32 |
+
(1.0, 1.0, 1.0))}
|
| 33 |
+
|
| 34 |
+
_cool_data = {'red': ((0., 0., 0.), (1.0, 1.0, 1.0)),
|
| 35 |
+
'green': ((0., 1., 1.), (1.0, 0., 0.)),
|
| 36 |
+
'blue': ((0., 1., 1.), (1.0, 1., 1.))}
|
| 37 |
+
|
| 38 |
+
_copper_data = {'red': ((0., 0., 0.),
|
| 39 |
+
(0.809524, 1.000000, 1.000000),
|
| 40 |
+
(1.0, 1.0, 1.0)),
|
| 41 |
+
'green': ((0., 0., 0.),
|
| 42 |
+
(1.0, 0.7812, 0.7812)),
|
| 43 |
+
'blue': ((0., 0., 0.),
|
| 44 |
+
(1.0, 0.4975, 0.4975))}
|
| 45 |
+
|
| 46 |
+
def _flag_red(x): return 0.75 * np.sin((x * 31.5 + 0.25) * np.pi) + 0.5
|
| 47 |
+
def _flag_green(x): return np.sin(x * 31.5 * np.pi)
|
| 48 |
+
def _flag_blue(x): return 0.75 * np.sin((x * 31.5 - 0.25) * np.pi) + 0.5
|
| 49 |
+
_flag_data = {'red': _flag_red, 'green': _flag_green, 'blue': _flag_blue}
|
| 50 |
+
|
| 51 |
+
def _prism_red(x): return 0.75 * np.sin((x * 20.9 + 0.25) * np.pi) + 0.67
|
| 52 |
+
def _prism_green(x): return 0.75 * np.sin((x * 20.9 - 0.25) * np.pi) + 0.33
|
| 53 |
+
def _prism_blue(x): return -1.1 * np.sin((x * 20.9) * np.pi)
|
| 54 |
+
_prism_data = {'red': _prism_red, 'green': _prism_green, 'blue': _prism_blue}
|
| 55 |
+
|
| 56 |
+
def _ch_helper(gamma, s, r, h, p0, p1, x):
|
| 57 |
+
"""Helper function for generating picklable cubehelix colormaps."""
|
| 58 |
+
# Apply gamma factor to emphasise low or high intensity values
|
| 59 |
+
xg = x ** gamma
|
| 60 |
+
# Calculate amplitude and angle of deviation from the black to white
|
| 61 |
+
# diagonal in the plane of constant perceived intensity.
|
| 62 |
+
a = h * xg * (1 - xg) / 2
|
| 63 |
+
phi = 2 * np.pi * (s / 3 + r * x)
|
| 64 |
+
return xg + a * (p0 * np.cos(phi) + p1 * np.sin(phi))
|
| 65 |
+
|
| 66 |
+
def cubehelix(gamma=1.0, s=0.5, r=-1.5, h=1.0):
|
| 67 |
+
"""
|
| 68 |
+
Return custom data dictionary of (r, g, b) conversion functions, which can
|
| 69 |
+
be used with `.ColormapRegistry.register`, for the cubehelix color scheme.
|
| 70 |
+
|
| 71 |
+
Unlike most other color schemes cubehelix was designed by D.A. Green to
|
| 72 |
+
be monotonically increasing in terms of perceived brightness.
|
| 73 |
+
Also, when printed on a black and white postscript printer, the scheme
|
| 74 |
+
results in a greyscale with monotonically increasing brightness.
|
| 75 |
+
This color scheme is named cubehelix because the (r, g, b) values produced
|
| 76 |
+
can be visualised as a squashed helix around the diagonal in the
|
| 77 |
+
(r, g, b) color cube.
|
| 78 |
+
|
| 79 |
+
For a unit color cube (i.e. 3D coordinates for (r, g, b) each in the
|
| 80 |
+
range 0 to 1) the color scheme starts at (r, g, b) = (0, 0, 0), i.e. black,
|
| 81 |
+
and finishes at (r, g, b) = (1, 1, 1), i.e. white. For some fraction *x*,
|
| 82 |
+
between 0 and 1, the color is the corresponding grey value at that
|
| 83 |
+
fraction along the black to white diagonal (x, x, x) plus a color
|
| 84 |
+
element. This color element is calculated in a plane of constant
|
| 85 |
+
perceived intensity and controlled by the following parameters.
|
| 86 |
+
|
| 87 |
+
Parameters
|
| 88 |
+
----------
|
| 89 |
+
gamma : float, default: 1
|
| 90 |
+
Gamma factor emphasizing either low intensity values (gamma < 1), or
|
| 91 |
+
high intensity values (gamma > 1).
|
| 92 |
+
s : float, default: 0.5 (purple)
|
| 93 |
+
The starting color.
|
| 94 |
+
r : float, default: -1.5
|
| 95 |
+
The number of r, g, b rotations in color that are made from the start
|
| 96 |
+
to the end of the color scheme. The default of -1.5 corresponds to ->
|
| 97 |
+
B -> G -> R -> B.
|
| 98 |
+
h : float, default: 1
|
| 99 |
+
The hue, i.e. how saturated the colors are. If this parameter is zero
|
| 100 |
+
then the color scheme is purely a greyscale.
|
| 101 |
+
"""
|
| 102 |
+
return {'red': partial(_ch_helper, gamma, s, r, h, -0.14861, 1.78277),
|
| 103 |
+
'green': partial(_ch_helper, gamma, s, r, h, -0.29227, -0.90649),
|
| 104 |
+
'blue': partial(_ch_helper, gamma, s, r, h, 1.97294, 0.0)}
|
| 105 |
+
|
| 106 |
+
_cubehelix_data = cubehelix()
|
| 107 |
+
|
| 108 |
+
_bwr_data = ((0.0, 0.0, 1.0), (1.0, 1.0, 1.0), (1.0, 0.0, 0.0))
|
| 109 |
+
_brg_data = ((0.0, 0.0, 1.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0))
|
| 110 |
+
|
| 111 |
+
# Gnuplot palette functions
|
| 112 |
+
def _g0(x): return 0
|
| 113 |
+
def _g1(x): return 0.5
|
| 114 |
+
def _g2(x): return 1
|
| 115 |
+
def _g3(x): return x
|
| 116 |
+
def _g4(x): return x ** 2
|
| 117 |
+
def _g5(x): return x ** 3
|
| 118 |
+
def _g6(x): return x ** 4
|
| 119 |
+
def _g7(x): return np.sqrt(x)
|
| 120 |
+
def _g8(x): return np.sqrt(np.sqrt(x))
|
| 121 |
+
def _g9(x): return np.sin(x * np.pi / 2)
|
| 122 |
+
def _g10(x): return np.cos(x * np.pi / 2)
|
| 123 |
+
def _g11(x): return np.abs(x - 0.5)
|
| 124 |
+
def _g12(x): return (2 * x - 1) ** 2
|
| 125 |
+
def _g13(x): return np.sin(x * np.pi)
|
| 126 |
+
def _g14(x): return np.abs(np.cos(x * np.pi))
|
| 127 |
+
def _g15(x): return np.sin(x * 2 * np.pi)
|
| 128 |
+
def _g16(x): return np.cos(x * 2 * np.pi)
|
| 129 |
+
def _g17(x): return np.abs(np.sin(x * 2 * np.pi))
|
| 130 |
+
def _g18(x): return np.abs(np.cos(x * 2 * np.pi))
|
| 131 |
+
def _g19(x): return np.abs(np.sin(x * 4 * np.pi))
|
| 132 |
+
def _g20(x): return np.abs(np.cos(x * 4 * np.pi))
|
| 133 |
+
def _g21(x): return 3 * x
|
| 134 |
+
def _g22(x): return 3 * x - 1
|
| 135 |
+
def _g23(x): return 3 * x - 2
|
| 136 |
+
def _g24(x): return np.abs(3 * x - 1)
|
| 137 |
+
def _g25(x): return np.abs(3 * x - 2)
|
| 138 |
+
def _g26(x): return (3 * x - 1) / 2
|
| 139 |
+
def _g27(x): return (3 * x - 2) / 2
|
| 140 |
+
def _g28(x): return np.abs((3 * x - 1) / 2)
|
| 141 |
+
def _g29(x): return np.abs((3 * x - 2) / 2)
|
| 142 |
+
def _g30(x): return x / 0.32 - 0.78125
|
| 143 |
+
def _g31(x): return 2 * x - 0.84
|
| 144 |
+
def _g32(x):
|
| 145 |
+
ret = np.zeros(len(x))
|
| 146 |
+
m = (x < 0.25)
|
| 147 |
+
ret[m] = 4 * x[m]
|
| 148 |
+
m = (x >= 0.25) & (x < 0.92)
|
| 149 |
+
ret[m] = -2 * x[m] + 1.84
|
| 150 |
+
m = (x >= 0.92)
|
| 151 |
+
ret[m] = x[m] / 0.08 - 11.5
|
| 152 |
+
return ret
|
| 153 |
+
def _g33(x): return np.abs(2 * x - 0.5)
|
| 154 |
+
def _g34(x): return 2 * x
|
| 155 |
+
def _g35(x): return 2 * x - 0.5
|
| 156 |
+
def _g36(x): return 2 * x - 1
|
| 157 |
+
|
| 158 |
+
gfunc = {i: globals()[f"_g{i}"] for i in range(37)}
|
| 159 |
+
|
| 160 |
+
_gnuplot_data = {
|
| 161 |
+
'red': gfunc[7],
|
| 162 |
+
'green': gfunc[5],
|
| 163 |
+
'blue': gfunc[15],
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
_gnuplot2_data = {
|
| 167 |
+
'red': gfunc[30],
|
| 168 |
+
'green': gfunc[31],
|
| 169 |
+
'blue': gfunc[32],
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
_ocean_data = {
|
| 173 |
+
'red': gfunc[23],
|
| 174 |
+
'green': gfunc[28],
|
| 175 |
+
'blue': gfunc[3],
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
_afmhot_data = {
|
| 179 |
+
'red': gfunc[34],
|
| 180 |
+
'green': gfunc[35],
|
| 181 |
+
'blue': gfunc[36],
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
_rainbow_data = {
|
| 185 |
+
'red': gfunc[33],
|
| 186 |
+
'green': gfunc[13],
|
| 187 |
+
'blue': gfunc[10],
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
_seismic_data = (
|
| 191 |
+
(0.0, 0.0, 0.3), (0.0, 0.0, 1.0),
|
| 192 |
+
(1.0, 1.0, 1.0), (1.0, 0.0, 0.0),
|
| 193 |
+
(0.5, 0.0, 0.0))
|
| 194 |
+
|
| 195 |
+
_terrain_data = (
|
| 196 |
+
(0.00, (0.2, 0.2, 0.6)),
|
| 197 |
+
(0.15, (0.0, 0.6, 1.0)),
|
| 198 |
+
(0.25, (0.0, 0.8, 0.4)),
|
| 199 |
+
(0.50, (1.0, 1.0, 0.6)),
|
| 200 |
+
(0.75, (0.5, 0.36, 0.33)),
|
| 201 |
+
(1.00, (1.0, 1.0, 1.0)))
|
| 202 |
+
|
| 203 |
+
_gray_data = {'red': ((0., 0, 0), (1., 1, 1)),
|
| 204 |
+
'green': ((0., 0, 0), (1., 1, 1)),
|
| 205 |
+
'blue': ((0., 0, 0), (1., 1, 1))}
|
| 206 |
+
|
| 207 |
+
_hot_data = {'red': ((0., 0.0416, 0.0416),
|
| 208 |
+
(0.365079, 1.000000, 1.000000),
|
| 209 |
+
(1.0, 1.0, 1.0)),
|
| 210 |
+
'green': ((0., 0., 0.),
|
| 211 |
+
(0.365079, 0.000000, 0.000000),
|
| 212 |
+
(0.746032, 1.000000, 1.000000),
|
| 213 |
+
(1.0, 1.0, 1.0)),
|
| 214 |
+
'blue': ((0., 0., 0.),
|
| 215 |
+
(0.746032, 0.000000, 0.000000),
|
| 216 |
+
(1.0, 1.0, 1.0))}
|
| 217 |
+
|
| 218 |
+
_hsv_data = {'red': ((0., 1., 1.),
|
| 219 |
+
(0.158730, 1.000000, 1.000000),
|
| 220 |
+
(0.174603, 0.968750, 0.968750),
|
| 221 |
+
(0.333333, 0.031250, 0.031250),
|
| 222 |
+
(0.349206, 0.000000, 0.000000),
|
| 223 |
+
(0.666667, 0.000000, 0.000000),
|
| 224 |
+
(0.682540, 0.031250, 0.031250),
|
| 225 |
+
(0.841270, 0.968750, 0.968750),
|
| 226 |
+
(0.857143, 1.000000, 1.000000),
|
| 227 |
+
(1.0, 1.0, 1.0)),
|
| 228 |
+
'green': ((0., 0., 0.),
|
| 229 |
+
(0.158730, 0.937500, 0.937500),
|
| 230 |
+
(0.174603, 1.000000, 1.000000),
|
| 231 |
+
(0.507937, 1.000000, 1.000000),
|
| 232 |
+
(0.666667, 0.062500, 0.062500),
|
| 233 |
+
(0.682540, 0.000000, 0.000000),
|
| 234 |
+
(1.0, 0., 0.)),
|
| 235 |
+
'blue': ((0., 0., 0.),
|
| 236 |
+
(0.333333, 0.000000, 0.000000),
|
| 237 |
+
(0.349206, 0.062500, 0.062500),
|
| 238 |
+
(0.507937, 1.000000, 1.000000),
|
| 239 |
+
(0.841270, 1.000000, 1.000000),
|
| 240 |
+
(0.857143, 0.937500, 0.937500),
|
| 241 |
+
(1.0, 0.09375, 0.09375))}
|
| 242 |
+
|
| 243 |
+
_jet_data = {'red': ((0.00, 0, 0),
|
| 244 |
+
(0.35, 0, 0),
|
| 245 |
+
(0.66, 1, 1),
|
| 246 |
+
(0.89, 1, 1),
|
| 247 |
+
(1.00, 0.5, 0.5)),
|
| 248 |
+
'green': ((0.000, 0, 0),
|
| 249 |
+
(0.125, 0, 0),
|
| 250 |
+
(0.375, 1, 1),
|
| 251 |
+
(0.640, 1, 1),
|
| 252 |
+
(0.910, 0, 0),
|
| 253 |
+
(1.000, 0, 0)),
|
| 254 |
+
'blue': ((0.00, 0.5, 0.5),
|
| 255 |
+
(0.11, 1, 1),
|
| 256 |
+
(0.34, 1, 1),
|
| 257 |
+
(0.65, 0, 0),
|
| 258 |
+
(1.00, 0, 0))}
|
| 259 |
+
|
| 260 |
+
_pink_data = {'red': ((0., 0.1178, 0.1178), (0.015873, 0.195857, 0.195857),
|
| 261 |
+
(0.031746, 0.250661, 0.250661),
|
| 262 |
+
(0.047619, 0.295468, 0.295468),
|
| 263 |
+
(0.063492, 0.334324, 0.334324),
|
| 264 |
+
(0.079365, 0.369112, 0.369112),
|
| 265 |
+
(0.095238, 0.400892, 0.400892),
|
| 266 |
+
(0.111111, 0.430331, 0.430331),
|
| 267 |
+
(0.126984, 0.457882, 0.457882),
|
| 268 |
+
(0.142857, 0.483867, 0.483867),
|
| 269 |
+
(0.158730, 0.508525, 0.508525),
|
| 270 |
+
(0.174603, 0.532042, 0.532042),
|
| 271 |
+
(0.190476, 0.554563, 0.554563),
|
| 272 |
+
(0.206349, 0.576204, 0.576204),
|
| 273 |
+
(0.222222, 0.597061, 0.597061),
|
| 274 |
+
(0.238095, 0.617213, 0.617213),
|
| 275 |
+
(0.253968, 0.636729, 0.636729),
|
| 276 |
+
(0.269841, 0.655663, 0.655663),
|
| 277 |
+
(0.285714, 0.674066, 0.674066),
|
| 278 |
+
(0.301587, 0.691980, 0.691980),
|
| 279 |
+
(0.317460, 0.709441, 0.709441),
|
| 280 |
+
(0.333333, 0.726483, 0.726483),
|
| 281 |
+
(0.349206, 0.743134, 0.743134),
|
| 282 |
+
(0.365079, 0.759421, 0.759421),
|
| 283 |
+
(0.380952, 0.766356, 0.766356),
|
| 284 |
+
(0.396825, 0.773229, 0.773229),
|
| 285 |
+
(0.412698, 0.780042, 0.780042),
|
| 286 |
+
(0.428571, 0.786796, 0.786796),
|
| 287 |
+
(0.444444, 0.793492, 0.793492),
|
| 288 |
+
(0.460317, 0.800132, 0.800132),
|
| 289 |
+
(0.476190, 0.806718, 0.806718),
|
| 290 |
+
(0.492063, 0.813250, 0.813250),
|
| 291 |
+
(0.507937, 0.819730, 0.819730),
|
| 292 |
+
(0.523810, 0.826160, 0.826160),
|
| 293 |
+
(0.539683, 0.832539, 0.832539),
|
| 294 |
+
(0.555556, 0.838870, 0.838870),
|
| 295 |
+
(0.571429, 0.845154, 0.845154),
|
| 296 |
+
(0.587302, 0.851392, 0.851392),
|
| 297 |
+
(0.603175, 0.857584, 0.857584),
|
| 298 |
+
(0.619048, 0.863731, 0.863731),
|
| 299 |
+
(0.634921, 0.869835, 0.869835),
|
| 300 |
+
(0.650794, 0.875897, 0.875897),
|
| 301 |
+
(0.666667, 0.881917, 0.881917),
|
| 302 |
+
(0.682540, 0.887896, 0.887896),
|
| 303 |
+
(0.698413, 0.893835, 0.893835),
|
| 304 |
+
(0.714286, 0.899735, 0.899735),
|
| 305 |
+
(0.730159, 0.905597, 0.905597),
|
| 306 |
+
(0.746032, 0.911421, 0.911421),
|
| 307 |
+
(0.761905, 0.917208, 0.917208),
|
| 308 |
+
(0.777778, 0.922958, 0.922958),
|
| 309 |
+
(0.793651, 0.928673, 0.928673),
|
| 310 |
+
(0.809524, 0.934353, 0.934353),
|
| 311 |
+
(0.825397, 0.939999, 0.939999),
|
| 312 |
+
(0.841270, 0.945611, 0.945611),
|
| 313 |
+
(0.857143, 0.951190, 0.951190),
|
| 314 |
+
(0.873016, 0.956736, 0.956736),
|
| 315 |
+
(0.888889, 0.962250, 0.962250),
|
| 316 |
+
(0.904762, 0.967733, 0.967733),
|
| 317 |
+
(0.920635, 0.973185, 0.973185),
|
| 318 |
+
(0.936508, 0.978607, 0.978607),
|
| 319 |
+
(0.952381, 0.983999, 0.983999),
|
| 320 |
+
(0.968254, 0.989361, 0.989361),
|
| 321 |
+
(0.984127, 0.994695, 0.994695), (1.0, 1.0, 1.0)),
|
| 322 |
+
'green': ((0., 0., 0.), (0.015873, 0.102869, 0.102869),
|
| 323 |
+
(0.031746, 0.145479, 0.145479),
|
| 324 |
+
(0.047619, 0.178174, 0.178174),
|
| 325 |
+
(0.063492, 0.205738, 0.205738),
|
| 326 |
+
(0.079365, 0.230022, 0.230022),
|
| 327 |
+
(0.095238, 0.251976, 0.251976),
|
| 328 |
+
(0.111111, 0.272166, 0.272166),
|
| 329 |
+
(0.126984, 0.290957, 0.290957),
|
| 330 |
+
(0.142857, 0.308607, 0.308607),
|
| 331 |
+
(0.158730, 0.325300, 0.325300),
|
| 332 |
+
(0.174603, 0.341178, 0.341178),
|
| 333 |
+
(0.190476, 0.356348, 0.356348),
|
| 334 |
+
(0.206349, 0.370899, 0.370899),
|
| 335 |
+
(0.222222, 0.384900, 0.384900),
|
| 336 |
+
(0.238095, 0.398410, 0.398410),
|
| 337 |
+
(0.253968, 0.411476, 0.411476),
|
| 338 |
+
(0.269841, 0.424139, 0.424139),
|
| 339 |
+
(0.285714, 0.436436, 0.436436),
|
| 340 |
+
(0.301587, 0.448395, 0.448395),
|
| 341 |
+
(0.317460, 0.460044, 0.460044),
|
| 342 |
+
(0.333333, 0.471405, 0.471405),
|
| 343 |
+
(0.349206, 0.482498, 0.482498),
|
| 344 |
+
(0.365079, 0.493342, 0.493342),
|
| 345 |
+
(0.380952, 0.517549, 0.517549),
|
| 346 |
+
(0.396825, 0.540674, 0.540674),
|
| 347 |
+
(0.412698, 0.562849, 0.562849),
|
| 348 |
+
(0.428571, 0.584183, 0.584183),
|
| 349 |
+
(0.444444, 0.604765, 0.604765),
|
| 350 |
+
(0.460317, 0.624669, 0.624669),
|
| 351 |
+
(0.476190, 0.643958, 0.643958),
|
| 352 |
+
(0.492063, 0.662687, 0.662687),
|
| 353 |
+
(0.507937, 0.680900, 0.680900),
|
| 354 |
+
(0.523810, 0.698638, 0.698638),
|
| 355 |
+
(0.539683, 0.715937, 0.715937),
|
| 356 |
+
(0.555556, 0.732828, 0.732828),
|
| 357 |
+
(0.571429, 0.749338, 0.749338),
|
| 358 |
+
(0.587302, 0.765493, 0.765493),
|
| 359 |
+
(0.603175, 0.781313, 0.781313),
|
| 360 |
+
(0.619048, 0.796819, 0.796819),
|
| 361 |
+
(0.634921, 0.812029, 0.812029),
|
| 362 |
+
(0.650794, 0.826960, 0.826960),
|
| 363 |
+
(0.666667, 0.841625, 0.841625),
|
| 364 |
+
(0.682540, 0.856040, 0.856040),
|
| 365 |
+
(0.698413, 0.870216, 0.870216),
|
| 366 |
+
(0.714286, 0.884164, 0.884164),
|
| 367 |
+
(0.730159, 0.897896, 0.897896),
|
| 368 |
+
(0.746032, 0.911421, 0.911421),
|
| 369 |
+
(0.761905, 0.917208, 0.917208),
|
| 370 |
+
(0.777778, 0.922958, 0.922958),
|
| 371 |
+
(0.793651, 0.928673, 0.928673),
|
| 372 |
+
(0.809524, 0.934353, 0.934353),
|
| 373 |
+
(0.825397, 0.939999, 0.939999),
|
| 374 |
+
(0.841270, 0.945611, 0.945611),
|
| 375 |
+
(0.857143, 0.951190, 0.951190),
|
| 376 |
+
(0.873016, 0.956736, 0.956736),
|
| 377 |
+
(0.888889, 0.962250, 0.962250),
|
| 378 |
+
(0.904762, 0.967733, 0.967733),
|
| 379 |
+
(0.920635, 0.973185, 0.973185),
|
| 380 |
+
(0.936508, 0.978607, 0.978607),
|
| 381 |
+
(0.952381, 0.983999, 0.983999),
|
| 382 |
+
(0.968254, 0.989361, 0.989361),
|
| 383 |
+
(0.984127, 0.994695, 0.994695), (1.0, 1.0, 1.0)),
|
| 384 |
+
'blue': ((0., 0., 0.), (0.015873, 0.102869, 0.102869),
|
| 385 |
+
(0.031746, 0.145479, 0.145479),
|
| 386 |
+
(0.047619, 0.178174, 0.178174),
|
| 387 |
+
(0.063492, 0.205738, 0.205738),
|
| 388 |
+
(0.079365, 0.230022, 0.230022),
|
| 389 |
+
(0.095238, 0.251976, 0.251976),
|
| 390 |
+
(0.111111, 0.272166, 0.272166),
|
| 391 |
+
(0.126984, 0.290957, 0.290957),
|
| 392 |
+
(0.142857, 0.308607, 0.308607),
|
| 393 |
+
(0.158730, 0.325300, 0.325300),
|
| 394 |
+
(0.174603, 0.341178, 0.341178),
|
| 395 |
+
(0.190476, 0.356348, 0.356348),
|
| 396 |
+
(0.206349, 0.370899, 0.370899),
|
| 397 |
+
(0.222222, 0.384900, 0.384900),
|
| 398 |
+
(0.238095, 0.398410, 0.398410),
|
| 399 |
+
(0.253968, 0.411476, 0.411476),
|
| 400 |
+
(0.269841, 0.424139, 0.424139),
|
| 401 |
+
(0.285714, 0.436436, 0.436436),
|
| 402 |
+
(0.301587, 0.448395, 0.448395),
|
| 403 |
+
(0.317460, 0.460044, 0.460044),
|
| 404 |
+
(0.333333, 0.471405, 0.471405),
|
| 405 |
+
(0.349206, 0.482498, 0.482498),
|
| 406 |
+
(0.365079, 0.493342, 0.493342),
|
| 407 |
+
(0.380952, 0.503953, 0.503953),
|
| 408 |
+
(0.396825, 0.514344, 0.514344),
|
| 409 |
+
(0.412698, 0.524531, 0.524531),
|
| 410 |
+
(0.428571, 0.534522, 0.534522),
|
| 411 |
+
(0.444444, 0.544331, 0.544331),
|
| 412 |
+
(0.460317, 0.553966, 0.553966),
|
| 413 |
+
(0.476190, 0.563436, 0.563436),
|
| 414 |
+
(0.492063, 0.572750, 0.572750),
|
| 415 |
+
(0.507937, 0.581914, 0.581914),
|
| 416 |
+
(0.523810, 0.590937, 0.590937),
|
| 417 |
+
(0.539683, 0.599824, 0.599824),
|
| 418 |
+
(0.555556, 0.608581, 0.608581),
|
| 419 |
+
(0.571429, 0.617213, 0.617213),
|
| 420 |
+
(0.587302, 0.625727, 0.625727),
|
| 421 |
+
(0.603175, 0.634126, 0.634126),
|
| 422 |
+
(0.619048, 0.642416, 0.642416),
|
| 423 |
+
(0.634921, 0.650600, 0.650600),
|
| 424 |
+
(0.650794, 0.658682, 0.658682),
|
| 425 |
+
(0.666667, 0.666667, 0.666667),
|
| 426 |
+
(0.682540, 0.674556, 0.674556),
|
| 427 |
+
(0.698413, 0.682355, 0.682355),
|
| 428 |
+
(0.714286, 0.690066, 0.690066),
|
| 429 |
+
(0.730159, 0.697691, 0.697691),
|
| 430 |
+
(0.746032, 0.705234, 0.705234),
|
| 431 |
+
(0.761905, 0.727166, 0.727166),
|
| 432 |
+
(0.777778, 0.748455, 0.748455),
|
| 433 |
+
(0.793651, 0.769156, 0.769156),
|
| 434 |
+
(0.809524, 0.789314, 0.789314),
|
| 435 |
+
(0.825397, 0.808969, 0.808969),
|
| 436 |
+
(0.841270, 0.828159, 0.828159),
|
| 437 |
+
(0.857143, 0.846913, 0.846913),
|
| 438 |
+
(0.873016, 0.865261, 0.865261),
|
| 439 |
+
(0.888889, 0.883229, 0.883229),
|
| 440 |
+
(0.904762, 0.900837, 0.900837),
|
| 441 |
+
(0.920635, 0.918109, 0.918109),
|
| 442 |
+
(0.936508, 0.935061, 0.935061),
|
| 443 |
+
(0.952381, 0.951711, 0.951711),
|
| 444 |
+
(0.968254, 0.968075, 0.968075),
|
| 445 |
+
(0.984127, 0.984167, 0.984167), (1.0, 1.0, 1.0))}
|
| 446 |
+
|
| 447 |
+
_spring_data = {'red': ((0., 1., 1.), (1.0, 1.0, 1.0)),
|
| 448 |
+
'green': ((0., 0., 0.), (1.0, 1.0, 1.0)),
|
| 449 |
+
'blue': ((0., 1., 1.), (1.0, 0.0, 0.0))}
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
_summer_data = {'red': ((0., 0., 0.), (1.0, 1.0, 1.0)),
|
| 453 |
+
'green': ((0., 0.5, 0.5), (1.0, 1.0, 1.0)),
|
| 454 |
+
'blue': ((0., 0.4, 0.4), (1.0, 0.4, 0.4))}
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
_winter_data = {'red': ((0., 0., 0.), (1.0, 0.0, 0.0)),
|
| 458 |
+
'green': ((0., 0., 0.), (1.0, 1.0, 1.0)),
|
| 459 |
+
'blue': ((0., 1., 1.), (1.0, 0.5, 0.5))}
|
| 460 |
+
|
| 461 |
+
_nipy_spectral_data = {
|
| 462 |
+
'red': [
|
| 463 |
+
(0.0, 0.0, 0.0), (0.05, 0.4667, 0.4667),
|
| 464 |
+
(0.10, 0.5333, 0.5333), (0.15, 0.0, 0.0),
|
| 465 |
+
(0.20, 0.0, 0.0), (0.25, 0.0, 0.0),
|
| 466 |
+
(0.30, 0.0, 0.0), (0.35, 0.0, 0.0),
|
| 467 |
+
(0.40, 0.0, 0.0), (0.45, 0.0, 0.0),
|
| 468 |
+
(0.50, 0.0, 0.0), (0.55, 0.0, 0.0),
|
| 469 |
+
(0.60, 0.0, 0.0), (0.65, 0.7333, 0.7333),
|
| 470 |
+
(0.70, 0.9333, 0.9333), (0.75, 1.0, 1.0),
|
| 471 |
+
(0.80, 1.0, 1.0), (0.85, 1.0, 1.0),
|
| 472 |
+
(0.90, 0.8667, 0.8667), (0.95, 0.80, 0.80),
|
| 473 |
+
(1.0, 0.80, 0.80),
|
| 474 |
+
],
|
| 475 |
+
'green': [
|
| 476 |
+
(0.0, 0.0, 0.0), (0.05, 0.0, 0.0),
|
| 477 |
+
(0.10, 0.0, 0.0), (0.15, 0.0, 0.0),
|
| 478 |
+
(0.20, 0.0, 0.0), (0.25, 0.4667, 0.4667),
|
| 479 |
+
(0.30, 0.6000, 0.6000), (0.35, 0.6667, 0.6667),
|
| 480 |
+
(0.40, 0.6667, 0.6667), (0.45, 0.6000, 0.6000),
|
| 481 |
+
(0.50, 0.7333, 0.7333), (0.55, 0.8667, 0.8667),
|
| 482 |
+
(0.60, 1.0, 1.0), (0.65, 1.0, 1.0),
|
| 483 |
+
(0.70, 0.9333, 0.9333), (0.75, 0.8000, 0.8000),
|
| 484 |
+
(0.80, 0.6000, 0.6000), (0.85, 0.0, 0.0),
|
| 485 |
+
(0.90, 0.0, 0.0), (0.95, 0.0, 0.0),
|
| 486 |
+
(1.0, 0.80, 0.80),
|
| 487 |
+
],
|
| 488 |
+
'blue': [
|
| 489 |
+
(0.0, 0.0, 0.0), (0.05, 0.5333, 0.5333),
|
| 490 |
+
(0.10, 0.6000, 0.6000), (0.15, 0.6667, 0.6667),
|
| 491 |
+
(0.20, 0.8667, 0.8667), (0.25, 0.8667, 0.8667),
|
| 492 |
+
(0.30, 0.8667, 0.8667), (0.35, 0.6667, 0.6667),
|
| 493 |
+
(0.40, 0.5333, 0.5333), (0.45, 0.0, 0.0),
|
| 494 |
+
(0.5, 0.0, 0.0), (0.55, 0.0, 0.0),
|
| 495 |
+
(0.60, 0.0, 0.0), (0.65, 0.0, 0.0),
|
| 496 |
+
(0.70, 0.0, 0.0), (0.75, 0.0, 0.0),
|
| 497 |
+
(0.80, 0.0, 0.0), (0.85, 0.0, 0.0),
|
| 498 |
+
(0.90, 0.0, 0.0), (0.95, 0.0, 0.0),
|
| 499 |
+
(1.0, 0.80, 0.80),
|
| 500 |
+
],
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
# 34 colormaps based on color specifications and designs
|
| 505 |
+
# developed by Cynthia Brewer (https://colorbrewer2.org/).
|
| 506 |
+
# The ColorBrewer palettes have been included under the terms
|
| 507 |
+
# of an Apache-stype license (for details, see the file
|
| 508 |
+
# LICENSE_COLORBREWER in the license directory of the matplotlib
|
| 509 |
+
# source distribution).
|
| 510 |
+
|
| 511 |
+
# RGB values taken from Brewer's Excel sheet, divided by 255
|
| 512 |
+
|
| 513 |
+
_Blues_data = (
|
| 514 |
+
(0.96862745098039216, 0.98431372549019602, 1.0 ),
|
| 515 |
+
(0.87058823529411766, 0.92156862745098034, 0.96862745098039216),
|
| 516 |
+
(0.77647058823529413, 0.85882352941176465, 0.93725490196078431),
|
| 517 |
+
(0.61960784313725492, 0.792156862745098 , 0.88235294117647056),
|
| 518 |
+
(0.41960784313725491, 0.68235294117647061, 0.83921568627450982),
|
| 519 |
+
(0.25882352941176473, 0.5725490196078431 , 0.77647058823529413),
|
| 520 |
+
(0.12941176470588237, 0.44313725490196076, 0.70980392156862748),
|
| 521 |
+
(0.03137254901960784, 0.31764705882352939, 0.61176470588235299),
|
| 522 |
+
(0.03137254901960784, 0.18823529411764706, 0.41960784313725491)
|
| 523 |
+
)
|
| 524 |
+
|
| 525 |
+
_BrBG_data = (
|
| 526 |
+
(0.32941176470588235, 0.18823529411764706, 0.0196078431372549 ),
|
| 527 |
+
(0.5490196078431373 , 0.31764705882352939, 0.0392156862745098 ),
|
| 528 |
+
(0.74901960784313726, 0.50588235294117645, 0.17647058823529413),
|
| 529 |
+
(0.87450980392156863, 0.76078431372549016, 0.49019607843137253),
|
| 530 |
+
(0.96470588235294119, 0.90980392156862744, 0.76470588235294112),
|
| 531 |
+
(0.96078431372549022, 0.96078431372549022, 0.96078431372549022),
|
| 532 |
+
(0.7803921568627451 , 0.91764705882352937, 0.89803921568627454),
|
| 533 |
+
(0.50196078431372548, 0.80392156862745101, 0.75686274509803919),
|
| 534 |
+
(0.20784313725490197, 0.59215686274509804, 0.5607843137254902 ),
|
| 535 |
+
(0.00392156862745098, 0.4 , 0.36862745098039218),
|
| 536 |
+
(0.0 , 0.23529411764705882, 0.18823529411764706)
|
| 537 |
+
)
|
| 538 |
+
|
| 539 |
+
_BuGn_data = (
|
| 540 |
+
(0.96862745098039216, 0.9882352941176471 , 0.99215686274509807),
|
| 541 |
+
(0.89803921568627454, 0.96078431372549022, 0.97647058823529409),
|
| 542 |
+
(0.8 , 0.92549019607843142, 0.90196078431372551),
|
| 543 |
+
(0.6 , 0.84705882352941175, 0.78823529411764703),
|
| 544 |
+
(0.4 , 0.76078431372549016, 0.64313725490196083),
|
| 545 |
+
(0.25490196078431371, 0.68235294117647061, 0.46274509803921571),
|
| 546 |
+
(0.13725490196078433, 0.54509803921568623, 0.27058823529411763),
|
| 547 |
+
(0.0 , 0.42745098039215684, 0.17254901960784313),
|
| 548 |
+
(0.0 , 0.26666666666666666, 0.10588235294117647)
|
| 549 |
+
)
|
| 550 |
+
|
| 551 |
+
_BuPu_data = (
|
| 552 |
+
(0.96862745098039216, 0.9882352941176471 , 0.99215686274509807),
|
| 553 |
+
(0.8784313725490196 , 0.92549019607843142, 0.95686274509803926),
|
| 554 |
+
(0.74901960784313726, 0.82745098039215681, 0.90196078431372551),
|
| 555 |
+
(0.61960784313725492, 0.73725490196078436, 0.85490196078431369),
|
| 556 |
+
(0.5490196078431373 , 0.58823529411764708, 0.77647058823529413),
|
| 557 |
+
(0.5490196078431373 , 0.41960784313725491, 0.69411764705882351),
|
| 558 |
+
(0.53333333333333333, 0.25490196078431371, 0.61568627450980395),
|
| 559 |
+
(0.50588235294117645, 0.05882352941176471, 0.48627450980392156),
|
| 560 |
+
(0.30196078431372547, 0.0 , 0.29411764705882354)
|
| 561 |
+
)
|
| 562 |
+
|
| 563 |
+
_GnBu_data = (
|
| 564 |
+
(0.96862745098039216, 0.9882352941176471 , 0.94117647058823528),
|
| 565 |
+
(0.8784313725490196 , 0.95294117647058818, 0.85882352941176465),
|
| 566 |
+
(0.8 , 0.92156862745098034, 0.77254901960784317),
|
| 567 |
+
(0.6588235294117647 , 0.8666666666666667 , 0.70980392156862748),
|
| 568 |
+
(0.4823529411764706 , 0.8 , 0.7686274509803922 ),
|
| 569 |
+
(0.30588235294117649, 0.70196078431372544, 0.82745098039215681),
|
| 570 |
+
(0.16862745098039217, 0.5490196078431373 , 0.74509803921568629),
|
| 571 |
+
(0.03137254901960784, 0.40784313725490196, 0.67450980392156867),
|
| 572 |
+
(0.03137254901960784, 0.25098039215686274, 0.50588235294117645)
|
| 573 |
+
)
|
| 574 |
+
|
| 575 |
+
_Greens_data = (
|
| 576 |
+
(0.96862745098039216, 0.9882352941176471 , 0.96078431372549022),
|
| 577 |
+
(0.89803921568627454, 0.96078431372549022, 0.8784313725490196 ),
|
| 578 |
+
(0.7803921568627451 , 0.9137254901960784 , 0.75294117647058822),
|
| 579 |
+
(0.63137254901960782, 0.85098039215686272, 0.60784313725490191),
|
| 580 |
+
(0.45490196078431372, 0.7686274509803922 , 0.46274509803921571),
|
| 581 |
+
(0.25490196078431371, 0.6705882352941176 , 0.36470588235294116),
|
| 582 |
+
(0.13725490196078433, 0.54509803921568623, 0.27058823529411763),
|
| 583 |
+
(0.0 , 0.42745098039215684, 0.17254901960784313),
|
| 584 |
+
(0.0 , 0.26666666666666666, 0.10588235294117647)
|
| 585 |
+
)
|
| 586 |
+
|
| 587 |
+
_Greys_data = (
|
| 588 |
+
(1.0 , 1.0 , 1.0 ),
|
| 589 |
+
(0.94117647058823528, 0.94117647058823528, 0.94117647058823528),
|
| 590 |
+
(0.85098039215686272, 0.85098039215686272, 0.85098039215686272),
|
| 591 |
+
(0.74117647058823533, 0.74117647058823533, 0.74117647058823533),
|
| 592 |
+
(0.58823529411764708, 0.58823529411764708, 0.58823529411764708),
|
| 593 |
+
(0.45098039215686275, 0.45098039215686275, 0.45098039215686275),
|
| 594 |
+
(0.32156862745098042, 0.32156862745098042, 0.32156862745098042),
|
| 595 |
+
(0.14509803921568629, 0.14509803921568629, 0.14509803921568629),
|
| 596 |
+
(0.0 , 0.0 , 0.0 )
|
| 597 |
+
)
|
| 598 |
+
|
| 599 |
+
_Oranges_data = (
|
| 600 |
+
(1.0 , 0.96078431372549022, 0.92156862745098034),
|
| 601 |
+
(0.99607843137254903, 0.90196078431372551, 0.80784313725490198),
|
| 602 |
+
(0.99215686274509807, 0.81568627450980391, 0.63529411764705879),
|
| 603 |
+
(0.99215686274509807, 0.68235294117647061, 0.41960784313725491),
|
| 604 |
+
(0.99215686274509807, 0.55294117647058827, 0.23529411764705882),
|
| 605 |
+
(0.94509803921568625, 0.41176470588235292, 0.07450980392156863),
|
| 606 |
+
(0.85098039215686272, 0.28235294117647058, 0.00392156862745098),
|
| 607 |
+
(0.65098039215686276, 0.21176470588235294, 0.01176470588235294),
|
| 608 |
+
(0.49803921568627452, 0.15294117647058825, 0.01568627450980392)
|
| 609 |
+
)
|
| 610 |
+
|
| 611 |
+
_OrRd_data = (
|
| 612 |
+
(1.0 , 0.96862745098039216, 0.92549019607843142),
|
| 613 |
+
(0.99607843137254903, 0.90980392156862744, 0.78431372549019607),
|
| 614 |
+
(0.99215686274509807, 0.83137254901960789, 0.61960784313725492),
|
| 615 |
+
(0.99215686274509807, 0.73333333333333328, 0.51764705882352946),
|
| 616 |
+
(0.9882352941176471 , 0.55294117647058827, 0.34901960784313724),
|
| 617 |
+
(0.93725490196078431, 0.396078431372549 , 0.28235294117647058),
|
| 618 |
+
(0.84313725490196079, 0.18823529411764706, 0.12156862745098039),
|
| 619 |
+
(0.70196078431372544, 0.0 , 0.0 ),
|
| 620 |
+
(0.49803921568627452, 0.0 , 0.0 )
|
| 621 |
+
)
|
| 622 |
+
|
| 623 |
+
_PiYG_data = (
|
| 624 |
+
(0.55686274509803924, 0.00392156862745098, 0.32156862745098042),
|
| 625 |
+
(0.77254901960784317, 0.10588235294117647, 0.49019607843137253),
|
| 626 |
+
(0.87058823529411766, 0.46666666666666667, 0.68235294117647061),
|
| 627 |
+
(0.94509803921568625, 0.71372549019607845, 0.85490196078431369),
|
| 628 |
+
(0.99215686274509807, 0.8784313725490196 , 0.93725490196078431),
|
| 629 |
+
(0.96862745098039216, 0.96862745098039216, 0.96862745098039216),
|
| 630 |
+
(0.90196078431372551, 0.96078431372549022, 0.81568627450980391),
|
| 631 |
+
(0.72156862745098038, 0.88235294117647056, 0.52549019607843139),
|
| 632 |
+
(0.49803921568627452, 0.73725490196078436, 0.25490196078431371),
|
| 633 |
+
(0.30196078431372547, 0.5725490196078431 , 0.12941176470588237),
|
| 634 |
+
(0.15294117647058825, 0.39215686274509803, 0.09803921568627451)
|
| 635 |
+
)
|
| 636 |
+
|
| 637 |
+
_PRGn_data = (
|
| 638 |
+
(0.25098039215686274, 0.0 , 0.29411764705882354),
|
| 639 |
+
(0.46274509803921571, 0.16470588235294117, 0.51372549019607838),
|
| 640 |
+
(0.6 , 0.4392156862745098 , 0.6705882352941176 ),
|
| 641 |
+
(0.76078431372549016, 0.6470588235294118 , 0.81176470588235294),
|
| 642 |
+
(0.90588235294117647, 0.83137254901960789, 0.90980392156862744),
|
| 643 |
+
(0.96862745098039216, 0.96862745098039216, 0.96862745098039216),
|
| 644 |
+
(0.85098039215686272, 0.94117647058823528, 0.82745098039215681),
|
| 645 |
+
(0.65098039215686276, 0.85882352941176465, 0.62745098039215685),
|
| 646 |
+
(0.35294117647058826, 0.68235294117647061, 0.38039215686274508),
|
| 647 |
+
(0.10588235294117647, 0.47058823529411764, 0.21568627450980393),
|
| 648 |
+
(0.0 , 0.26666666666666666, 0.10588235294117647)
|
| 649 |
+
)
|
| 650 |
+
|
| 651 |
+
_PuBu_data = (
|
| 652 |
+
(1.0 , 0.96862745098039216, 0.98431372549019602),
|
| 653 |
+
(0.92549019607843142, 0.90588235294117647, 0.94901960784313721),
|
| 654 |
+
(0.81568627450980391, 0.81960784313725488, 0.90196078431372551),
|
| 655 |
+
(0.65098039215686276, 0.74117647058823533, 0.85882352941176465),
|
| 656 |
+
(0.45490196078431372, 0.66274509803921566, 0.81176470588235294),
|
| 657 |
+
(0.21176470588235294, 0.56470588235294117, 0.75294117647058822),
|
| 658 |
+
(0.0196078431372549 , 0.4392156862745098 , 0.69019607843137254),
|
| 659 |
+
(0.01568627450980392, 0.35294117647058826, 0.55294117647058827),
|
| 660 |
+
(0.00784313725490196, 0.2196078431372549 , 0.34509803921568627)
|
| 661 |
+
)
|
| 662 |
+
|
| 663 |
+
_PuBuGn_data = (
|
| 664 |
+
(1.0 , 0.96862745098039216, 0.98431372549019602),
|
| 665 |
+
(0.92549019607843142, 0.88627450980392153, 0.94117647058823528),
|
| 666 |
+
(0.81568627450980391, 0.81960784313725488, 0.90196078431372551),
|
| 667 |
+
(0.65098039215686276, 0.74117647058823533, 0.85882352941176465),
|
| 668 |
+
(0.40392156862745099, 0.66274509803921566, 0.81176470588235294),
|
| 669 |
+
(0.21176470588235294, 0.56470588235294117, 0.75294117647058822),
|
| 670 |
+
(0.00784313725490196, 0.50588235294117645, 0.54117647058823526),
|
| 671 |
+
(0.00392156862745098, 0.42352941176470588, 0.34901960784313724),
|
| 672 |
+
(0.00392156862745098, 0.27450980392156865, 0.21176470588235294)
|
| 673 |
+
)
|
| 674 |
+
|
| 675 |
+
_PuOr_data = (
|
| 676 |
+
(0.49803921568627452, 0.23137254901960785, 0.03137254901960784),
|
| 677 |
+
(0.70196078431372544, 0.34509803921568627, 0.02352941176470588),
|
| 678 |
+
(0.8784313725490196 , 0.50980392156862742, 0.07843137254901961),
|
| 679 |
+
(0.99215686274509807, 0.72156862745098038, 0.38823529411764707),
|
| 680 |
+
(0.99607843137254903, 0.8784313725490196 , 0.71372549019607845),
|
| 681 |
+
(0.96862745098039216, 0.96862745098039216, 0.96862745098039216),
|
| 682 |
+
(0.84705882352941175, 0.85490196078431369, 0.92156862745098034),
|
| 683 |
+
(0.69803921568627447, 0.6705882352941176 , 0.82352941176470584),
|
| 684 |
+
(0.50196078431372548, 0.45098039215686275, 0.67450980392156867),
|
| 685 |
+
(0.32941176470588235, 0.15294117647058825, 0.53333333333333333),
|
| 686 |
+
(0.17647058823529413, 0.0 , 0.29411764705882354)
|
| 687 |
+
)
|
| 688 |
+
|
| 689 |
+
_PuRd_data = (
|
| 690 |
+
(0.96862745098039216, 0.95686274509803926, 0.97647058823529409),
|
| 691 |
+
(0.90588235294117647, 0.88235294117647056, 0.93725490196078431),
|
| 692 |
+
(0.83137254901960789, 0.72549019607843135, 0.85490196078431369),
|
| 693 |
+
(0.78823529411764703, 0.58039215686274515, 0.7803921568627451 ),
|
| 694 |
+
(0.87450980392156863, 0.396078431372549 , 0.69019607843137254),
|
| 695 |
+
(0.90588235294117647, 0.16078431372549021, 0.54117647058823526),
|
| 696 |
+
(0.80784313725490198, 0.07058823529411765, 0.33725490196078434),
|
| 697 |
+
(0.59607843137254901, 0.0 , 0.2627450980392157 ),
|
| 698 |
+
(0.40392156862745099, 0.0 , 0.12156862745098039)
|
| 699 |
+
)
|
| 700 |
+
|
| 701 |
+
_Purples_data = (
|
| 702 |
+
(0.9882352941176471 , 0.98431372549019602, 0.99215686274509807),
|
| 703 |
+
(0.93725490196078431, 0.92941176470588238, 0.96078431372549022),
|
| 704 |
+
(0.85490196078431369, 0.85490196078431369, 0.92156862745098034),
|
| 705 |
+
(0.73725490196078436, 0.74117647058823533, 0.86274509803921573),
|
| 706 |
+
(0.61960784313725492, 0.60392156862745094, 0.78431372549019607),
|
| 707 |
+
(0.50196078431372548, 0.49019607843137253, 0.72941176470588232),
|
| 708 |
+
(0.41568627450980394, 0.31764705882352939, 0.63921568627450975),
|
| 709 |
+
(0.32941176470588235, 0.15294117647058825, 0.5607843137254902 ),
|
| 710 |
+
(0.24705882352941178, 0.0 , 0.49019607843137253)
|
| 711 |
+
)
|
| 712 |
+
|
| 713 |
+
_RdBu_data = (
|
| 714 |
+
(0.40392156862745099, 0.0 , 0.12156862745098039),
|
| 715 |
+
(0.69803921568627447, 0.09411764705882353, 0.16862745098039217),
|
| 716 |
+
(0.83921568627450982, 0.37647058823529411, 0.30196078431372547),
|
| 717 |
+
(0.95686274509803926, 0.6470588235294118 , 0.50980392156862742),
|
| 718 |
+
(0.99215686274509807, 0.85882352941176465, 0.7803921568627451 ),
|
| 719 |
+
(0.96862745098039216, 0.96862745098039216, 0.96862745098039216),
|
| 720 |
+
(0.81960784313725488, 0.89803921568627454, 0.94117647058823528),
|
| 721 |
+
(0.5725490196078431 , 0.77254901960784317, 0.87058823529411766),
|
| 722 |
+
(0.2627450980392157 , 0.57647058823529407, 0.76470588235294112),
|
| 723 |
+
(0.12941176470588237, 0.4 , 0.67450980392156867),
|
| 724 |
+
(0.0196078431372549 , 0.18823529411764706, 0.38039215686274508)
|
| 725 |
+
)
|
| 726 |
+
|
| 727 |
+
_RdGy_data = (
|
| 728 |
+
(0.40392156862745099, 0.0 , 0.12156862745098039),
|
| 729 |
+
(0.69803921568627447, 0.09411764705882353, 0.16862745098039217),
|
| 730 |
+
(0.83921568627450982, 0.37647058823529411, 0.30196078431372547),
|
| 731 |
+
(0.95686274509803926, 0.6470588235294118 , 0.50980392156862742),
|
| 732 |
+
(0.99215686274509807, 0.85882352941176465, 0.7803921568627451 ),
|
| 733 |
+
(1.0 , 1.0 , 1.0 ),
|
| 734 |
+
(0.8784313725490196 , 0.8784313725490196 , 0.8784313725490196 ),
|
| 735 |
+
(0.72941176470588232, 0.72941176470588232, 0.72941176470588232),
|
| 736 |
+
(0.52941176470588236, 0.52941176470588236, 0.52941176470588236),
|
| 737 |
+
(0.30196078431372547, 0.30196078431372547, 0.30196078431372547),
|
| 738 |
+
(0.10196078431372549, 0.10196078431372549, 0.10196078431372549)
|
| 739 |
+
)
|
| 740 |
+
|
| 741 |
+
_RdPu_data = (
|
| 742 |
+
(1.0 , 0.96862745098039216, 0.95294117647058818),
|
| 743 |
+
(0.99215686274509807, 0.8784313725490196 , 0.86666666666666667),
|
| 744 |
+
(0.9882352941176471 , 0.77254901960784317, 0.75294117647058822),
|
| 745 |
+
(0.98039215686274506, 0.62352941176470589, 0.70980392156862748),
|
| 746 |
+
(0.96862745098039216, 0.40784313725490196, 0.63137254901960782),
|
| 747 |
+
(0.86666666666666667, 0.20392156862745098, 0.59215686274509804),
|
| 748 |
+
(0.68235294117647061, 0.00392156862745098, 0.49411764705882355),
|
| 749 |
+
(0.47843137254901963, 0.00392156862745098, 0.46666666666666667),
|
| 750 |
+
(0.28627450980392155, 0.0 , 0.41568627450980394)
|
| 751 |
+
)
|
| 752 |
+
|
| 753 |
+
_RdYlBu_data = (
|
| 754 |
+
(0.6470588235294118 , 0.0 , 0.14901960784313725),
|
| 755 |
+
(0.84313725490196079, 0.18823529411764706 , 0.15294117647058825),
|
| 756 |
+
(0.95686274509803926, 0.42745098039215684 , 0.2627450980392157 ),
|
| 757 |
+
(0.99215686274509807, 0.68235294117647061 , 0.38039215686274508),
|
| 758 |
+
(0.99607843137254903, 0.8784313725490196 , 0.56470588235294117),
|
| 759 |
+
(1.0 , 1.0 , 0.74901960784313726),
|
| 760 |
+
(0.8784313725490196 , 0.95294117647058818 , 0.97254901960784312),
|
| 761 |
+
(0.6705882352941176 , 0.85098039215686272 , 0.9137254901960784 ),
|
| 762 |
+
(0.45490196078431372, 0.67843137254901964 , 0.81960784313725488),
|
| 763 |
+
(0.27058823529411763, 0.45882352941176469 , 0.70588235294117652),
|
| 764 |
+
(0.19215686274509805, 0.21176470588235294 , 0.58431372549019611)
|
| 765 |
+
)
|
| 766 |
+
|
| 767 |
+
_RdYlGn_data = (
|
| 768 |
+
(0.6470588235294118 , 0.0 , 0.14901960784313725),
|
| 769 |
+
(0.84313725490196079, 0.18823529411764706 , 0.15294117647058825),
|
| 770 |
+
(0.95686274509803926, 0.42745098039215684 , 0.2627450980392157 ),
|
| 771 |
+
(0.99215686274509807, 0.68235294117647061 , 0.38039215686274508),
|
| 772 |
+
(0.99607843137254903, 0.8784313725490196 , 0.54509803921568623),
|
| 773 |
+
(1.0 , 1.0 , 0.74901960784313726),
|
| 774 |
+
(0.85098039215686272, 0.93725490196078431 , 0.54509803921568623),
|
| 775 |
+
(0.65098039215686276, 0.85098039215686272 , 0.41568627450980394),
|
| 776 |
+
(0.4 , 0.74117647058823533 , 0.38823529411764707),
|
| 777 |
+
(0.10196078431372549, 0.59607843137254901 , 0.31372549019607843),
|
| 778 |
+
(0.0 , 0.40784313725490196 , 0.21568627450980393)
|
| 779 |
+
)
|
| 780 |
+
|
| 781 |
+
_Reds_data = (
|
| 782 |
+
(1.0 , 0.96078431372549022 , 0.94117647058823528),
|
| 783 |
+
(0.99607843137254903, 0.8784313725490196 , 0.82352941176470584),
|
| 784 |
+
(0.9882352941176471 , 0.73333333333333328 , 0.63137254901960782),
|
| 785 |
+
(0.9882352941176471 , 0.5725490196078431 , 0.44705882352941179),
|
| 786 |
+
(0.98431372549019602, 0.41568627450980394 , 0.29019607843137257),
|
| 787 |
+
(0.93725490196078431, 0.23137254901960785 , 0.17254901960784313),
|
| 788 |
+
(0.79607843137254897, 0.094117647058823528, 0.11372549019607843),
|
| 789 |
+
(0.6470588235294118 , 0.058823529411764705, 0.08235294117647058),
|
| 790 |
+
(0.40392156862745099, 0.0 , 0.05098039215686274)
|
| 791 |
+
)
|
| 792 |
+
|
| 793 |
+
_Spectral_data = (
|
| 794 |
+
(0.61960784313725492, 0.003921568627450980, 0.25882352941176473),
|
| 795 |
+
(0.83529411764705885, 0.24313725490196078 , 0.30980392156862746),
|
| 796 |
+
(0.95686274509803926, 0.42745098039215684 , 0.2627450980392157 ),
|
| 797 |
+
(0.99215686274509807, 0.68235294117647061 , 0.38039215686274508),
|
| 798 |
+
(0.99607843137254903, 0.8784313725490196 , 0.54509803921568623),
|
| 799 |
+
(1.0 , 1.0 , 0.74901960784313726),
|
| 800 |
+
(0.90196078431372551, 0.96078431372549022 , 0.59607843137254901),
|
| 801 |
+
(0.6705882352941176 , 0.8666666666666667 , 0.64313725490196083),
|
| 802 |
+
(0.4 , 0.76078431372549016 , 0.6470588235294118 ),
|
| 803 |
+
(0.19607843137254902, 0.53333333333333333 , 0.74117647058823533),
|
| 804 |
+
(0.36862745098039218, 0.30980392156862746 , 0.63529411764705879)
|
| 805 |
+
)
|
| 806 |
+
|
| 807 |
+
_YlGn_data = (
|
| 808 |
+
(1.0 , 1.0 , 0.89803921568627454),
|
| 809 |
+
(0.96862745098039216, 0.9882352941176471 , 0.72549019607843135),
|
| 810 |
+
(0.85098039215686272, 0.94117647058823528 , 0.63921568627450975),
|
| 811 |
+
(0.67843137254901964, 0.8666666666666667 , 0.55686274509803924),
|
| 812 |
+
(0.47058823529411764, 0.77647058823529413 , 0.47450980392156861),
|
| 813 |
+
(0.25490196078431371, 0.6705882352941176 , 0.36470588235294116),
|
| 814 |
+
(0.13725490196078433, 0.51764705882352946 , 0.2627450980392157 ),
|
| 815 |
+
(0.0 , 0.40784313725490196 , 0.21568627450980393),
|
| 816 |
+
(0.0 , 0.27058823529411763 , 0.16078431372549021)
|
| 817 |
+
)
|
| 818 |
+
|
| 819 |
+
_YlGnBu_data = (
|
| 820 |
+
(1.0 , 1.0 , 0.85098039215686272),
|
| 821 |
+
(0.92941176470588238, 0.97254901960784312 , 0.69411764705882351),
|
| 822 |
+
(0.7803921568627451 , 0.9137254901960784 , 0.70588235294117652),
|
| 823 |
+
(0.49803921568627452, 0.80392156862745101 , 0.73333333333333328),
|
| 824 |
+
(0.25490196078431371, 0.71372549019607845 , 0.7686274509803922 ),
|
| 825 |
+
(0.11372549019607843, 0.56862745098039214 , 0.75294117647058822),
|
| 826 |
+
(0.13333333333333333, 0.36862745098039218 , 0.6588235294117647 ),
|
| 827 |
+
(0.14509803921568629, 0.20392156862745098 , 0.58039215686274515),
|
| 828 |
+
(0.03137254901960784, 0.11372549019607843 , 0.34509803921568627)
|
| 829 |
+
)
|
| 830 |
+
|
| 831 |
+
_YlOrBr_data = (
|
| 832 |
+
(1.0 , 1.0 , 0.89803921568627454),
|
| 833 |
+
(1.0 , 0.96862745098039216 , 0.73725490196078436),
|
| 834 |
+
(0.99607843137254903, 0.8901960784313725 , 0.56862745098039214),
|
| 835 |
+
(0.99607843137254903, 0.7686274509803922 , 0.30980392156862746),
|
| 836 |
+
(0.99607843137254903, 0.6 , 0.16078431372549021),
|
| 837 |
+
(0.92549019607843142, 0.4392156862745098 , 0.07843137254901961),
|
| 838 |
+
(0.8 , 0.29803921568627451 , 0.00784313725490196),
|
| 839 |
+
(0.6 , 0.20392156862745098 , 0.01568627450980392),
|
| 840 |
+
(0.4 , 0.14509803921568629 , 0.02352941176470588)
|
| 841 |
+
)
|
| 842 |
+
|
| 843 |
+
_YlOrRd_data = (
|
| 844 |
+
(1.0 , 1.0 , 0.8 ),
|
| 845 |
+
(1.0 , 0.92941176470588238 , 0.62745098039215685),
|
| 846 |
+
(0.99607843137254903, 0.85098039215686272 , 0.46274509803921571),
|
| 847 |
+
(0.99607843137254903, 0.69803921568627447 , 0.29803921568627451),
|
| 848 |
+
(0.99215686274509807, 0.55294117647058827 , 0.23529411764705882),
|
| 849 |
+
(0.9882352941176471 , 0.30588235294117649 , 0.16470588235294117),
|
| 850 |
+
(0.8901960784313725 , 0.10196078431372549 , 0.10980392156862745),
|
| 851 |
+
(0.74117647058823533, 0.0 , 0.14901960784313725),
|
| 852 |
+
(0.50196078431372548, 0.0 , 0.14901960784313725)
|
| 853 |
+
)
|
| 854 |
+
|
| 855 |
+
|
| 856 |
+
# ColorBrewer's qualitative maps, implemented using ListedColormap
|
| 857 |
+
# for use with mpl.colors.NoNorm
|
| 858 |
+
|
| 859 |
+
_Accent_data = (
|
| 860 |
+
(0.49803921568627452, 0.78823529411764703, 0.49803921568627452),
|
| 861 |
+
(0.74509803921568629, 0.68235294117647061, 0.83137254901960789),
|
| 862 |
+
(0.99215686274509807, 0.75294117647058822, 0.52549019607843139),
|
| 863 |
+
(1.0, 1.0, 0.6 ),
|
| 864 |
+
(0.2196078431372549, 0.42352941176470588, 0.69019607843137254),
|
| 865 |
+
(0.94117647058823528, 0.00784313725490196, 0.49803921568627452),
|
| 866 |
+
(0.74901960784313726, 0.35686274509803922, 0.09019607843137254),
|
| 867 |
+
(0.4, 0.4, 0.4 ),
|
| 868 |
+
)
|
| 869 |
+
|
| 870 |
+
_Dark2_data = (
|
| 871 |
+
(0.10588235294117647, 0.61960784313725492, 0.46666666666666667),
|
| 872 |
+
(0.85098039215686272, 0.37254901960784315, 0.00784313725490196),
|
| 873 |
+
(0.45882352941176469, 0.4392156862745098, 0.70196078431372544),
|
| 874 |
+
(0.90588235294117647, 0.16078431372549021, 0.54117647058823526),
|
| 875 |
+
(0.4, 0.65098039215686276, 0.11764705882352941),
|
| 876 |
+
(0.90196078431372551, 0.6705882352941176, 0.00784313725490196),
|
| 877 |
+
(0.65098039215686276, 0.46274509803921571, 0.11372549019607843),
|
| 878 |
+
(0.4, 0.4, 0.4 ),
|
| 879 |
+
)
|
| 880 |
+
|
| 881 |
+
_Paired_data = (
|
| 882 |
+
(0.65098039215686276, 0.80784313725490198, 0.8901960784313725 ),
|
| 883 |
+
(0.12156862745098039, 0.47058823529411764, 0.70588235294117652),
|
| 884 |
+
(0.69803921568627447, 0.87450980392156863, 0.54117647058823526),
|
| 885 |
+
(0.2, 0.62745098039215685, 0.17254901960784313),
|
| 886 |
+
(0.98431372549019602, 0.60392156862745094, 0.6 ),
|
| 887 |
+
(0.8901960784313725, 0.10196078431372549, 0.10980392156862745),
|
| 888 |
+
(0.99215686274509807, 0.74901960784313726, 0.43529411764705883),
|
| 889 |
+
(1.0, 0.49803921568627452, 0.0 ),
|
| 890 |
+
(0.792156862745098, 0.69803921568627447, 0.83921568627450982),
|
| 891 |
+
(0.41568627450980394, 0.23921568627450981, 0.60392156862745094),
|
| 892 |
+
(1.0, 1.0, 0.6 ),
|
| 893 |
+
(0.69411764705882351, 0.34901960784313724, 0.15686274509803921),
|
| 894 |
+
)
|
| 895 |
+
|
| 896 |
+
_Pastel1_data = (
|
| 897 |
+
(0.98431372549019602, 0.70588235294117652, 0.68235294117647061),
|
| 898 |
+
(0.70196078431372544, 0.80392156862745101, 0.8901960784313725 ),
|
| 899 |
+
(0.8, 0.92156862745098034, 0.77254901960784317),
|
| 900 |
+
(0.87058823529411766, 0.79607843137254897, 0.89411764705882357),
|
| 901 |
+
(0.99607843137254903, 0.85098039215686272, 0.65098039215686276),
|
| 902 |
+
(1.0, 1.0, 0.8 ),
|
| 903 |
+
(0.89803921568627454, 0.84705882352941175, 0.74117647058823533),
|
| 904 |
+
(0.99215686274509807, 0.85490196078431369, 0.92549019607843142),
|
| 905 |
+
(0.94901960784313721, 0.94901960784313721, 0.94901960784313721),
|
| 906 |
+
)
|
| 907 |
+
|
| 908 |
+
_Pastel2_data = (
|
| 909 |
+
(0.70196078431372544, 0.88627450980392153, 0.80392156862745101),
|
| 910 |
+
(0.99215686274509807, 0.80392156862745101, 0.67450980392156867),
|
| 911 |
+
(0.79607843137254897, 0.83529411764705885, 0.90980392156862744),
|
| 912 |
+
(0.95686274509803926, 0.792156862745098, 0.89411764705882357),
|
| 913 |
+
(0.90196078431372551, 0.96078431372549022, 0.78823529411764703),
|
| 914 |
+
(1.0, 0.94901960784313721, 0.68235294117647061),
|
| 915 |
+
(0.94509803921568625, 0.88627450980392153, 0.8 ),
|
| 916 |
+
(0.8, 0.8, 0.8 ),
|
| 917 |
+
)
|
| 918 |
+
|
| 919 |
+
_Set1_data = (
|
| 920 |
+
(0.89411764705882357, 0.10196078431372549, 0.10980392156862745),
|
| 921 |
+
(0.21568627450980393, 0.49411764705882355, 0.72156862745098038),
|
| 922 |
+
(0.30196078431372547, 0.68627450980392157, 0.29019607843137257),
|
| 923 |
+
(0.59607843137254901, 0.30588235294117649, 0.63921568627450975),
|
| 924 |
+
(1.0, 0.49803921568627452, 0.0 ),
|
| 925 |
+
(1.0, 1.0, 0.2 ),
|
| 926 |
+
(0.65098039215686276, 0.33725490196078434, 0.15686274509803921),
|
| 927 |
+
(0.96862745098039216, 0.50588235294117645, 0.74901960784313726),
|
| 928 |
+
(0.6, 0.6, 0.6),
|
| 929 |
+
)
|
| 930 |
+
|
| 931 |
+
_Set2_data = (
|
| 932 |
+
(0.4, 0.76078431372549016, 0.6470588235294118 ),
|
| 933 |
+
(0.9882352941176471, 0.55294117647058827, 0.3843137254901961 ),
|
| 934 |
+
(0.55294117647058827, 0.62745098039215685, 0.79607843137254897),
|
| 935 |
+
(0.90588235294117647, 0.54117647058823526, 0.76470588235294112),
|
| 936 |
+
(0.65098039215686276, 0.84705882352941175, 0.32941176470588235),
|
| 937 |
+
(1.0, 0.85098039215686272, 0.18431372549019609),
|
| 938 |
+
(0.89803921568627454, 0.7686274509803922, 0.58039215686274515),
|
| 939 |
+
(0.70196078431372544, 0.70196078431372544, 0.70196078431372544),
|
| 940 |
+
)
|
| 941 |
+
|
| 942 |
+
_Set3_data = (
|
| 943 |
+
(0.55294117647058827, 0.82745098039215681, 0.7803921568627451 ),
|
| 944 |
+
(1.0, 1.0, 0.70196078431372544),
|
| 945 |
+
(0.74509803921568629, 0.72941176470588232, 0.85490196078431369),
|
| 946 |
+
(0.98431372549019602, 0.50196078431372548, 0.44705882352941179),
|
| 947 |
+
(0.50196078431372548, 0.69411764705882351, 0.82745098039215681),
|
| 948 |
+
(0.99215686274509807, 0.70588235294117652, 0.3843137254901961 ),
|
| 949 |
+
(0.70196078431372544, 0.87058823529411766, 0.41176470588235292),
|
| 950 |
+
(0.9882352941176471, 0.80392156862745101, 0.89803921568627454),
|
| 951 |
+
(0.85098039215686272, 0.85098039215686272, 0.85098039215686272),
|
| 952 |
+
(0.73725490196078436, 0.50196078431372548, 0.74117647058823533),
|
| 953 |
+
(0.8, 0.92156862745098034, 0.77254901960784317),
|
| 954 |
+
(1.0, 0.92941176470588238, 0.43529411764705883),
|
| 955 |
+
)
|
| 956 |
+
|
| 957 |
+
|
| 958 |
+
# The next 7 palettes are from the Yorick scientific visualization package,
|
| 959 |
+
# an evolution of the GIST package, both by David H. Munro.
|
| 960 |
+
# They are released under a BSD-like license (see LICENSE_YORICK in
|
| 961 |
+
# the license directory of the matplotlib source distribution).
|
| 962 |
+
#
|
| 963 |
+
# Most palette functions have been reduced to simple function descriptions
|
| 964 |
+
# by Reinier Heeres, since the rgb components were mostly straight lines.
|
| 965 |
+
# gist_earth_data and gist_ncar_data were simplified by a script and some
|
| 966 |
+
# manual effort.
|
| 967 |
+
|
| 968 |
+
_gist_earth_data = {
|
| 969 |
+
'red': (
|
| 970 |
+
(0.0, 0.0, 0.0000),
|
| 971 |
+
(0.2824, 0.1882, 0.1882),
|
| 972 |
+
(0.4588, 0.2714, 0.2714),
|
| 973 |
+
(0.5490, 0.4719, 0.4719),
|
| 974 |
+
(0.6980, 0.7176, 0.7176),
|
| 975 |
+
(0.7882, 0.7553, 0.7553),
|
| 976 |
+
(1.0000, 0.9922, 0.9922),
|
| 977 |
+
),
|
| 978 |
+
'green': (
|
| 979 |
+
(0.0, 0.0, 0.0000),
|
| 980 |
+
(0.0275, 0.0000, 0.0000),
|
| 981 |
+
(0.1098, 0.1893, 0.1893),
|
| 982 |
+
(0.1647, 0.3035, 0.3035),
|
| 983 |
+
(0.2078, 0.3841, 0.3841),
|
| 984 |
+
(0.2824, 0.5020, 0.5020),
|
| 985 |
+
(0.5216, 0.6397, 0.6397),
|
| 986 |
+
(0.6980, 0.7171, 0.7171),
|
| 987 |
+
(0.7882, 0.6392, 0.6392),
|
| 988 |
+
(0.7922, 0.6413, 0.6413),
|
| 989 |
+
(0.8000, 0.6447, 0.6447),
|
| 990 |
+
(0.8078, 0.6481, 0.6481),
|
| 991 |
+
(0.8157, 0.6549, 0.6549),
|
| 992 |
+
(0.8667, 0.6991, 0.6991),
|
| 993 |
+
(0.8745, 0.7103, 0.7103),
|
| 994 |
+
(0.8824, 0.7216, 0.7216),
|
| 995 |
+
(0.8902, 0.7323, 0.7323),
|
| 996 |
+
(0.8980, 0.7430, 0.7430),
|
| 997 |
+
(0.9412, 0.8275, 0.8275),
|
| 998 |
+
(0.9569, 0.8635, 0.8635),
|
| 999 |
+
(0.9647, 0.8816, 0.8816),
|
| 1000 |
+
(0.9961, 0.9733, 0.9733),
|
| 1001 |
+
(1.0000, 0.9843, 0.9843),
|
| 1002 |
+
),
|
| 1003 |
+
'blue': (
|
| 1004 |
+
(0.0, 0.0, 0.0000),
|
| 1005 |
+
(0.0039, 0.1684, 0.1684),
|
| 1006 |
+
(0.0078, 0.2212, 0.2212),
|
| 1007 |
+
(0.0275, 0.4329, 0.4329),
|
| 1008 |
+
(0.0314, 0.4549, 0.4549),
|
| 1009 |
+
(0.2824, 0.5004, 0.5004),
|
| 1010 |
+
(0.4667, 0.2748, 0.2748),
|
| 1011 |
+
(0.5451, 0.3205, 0.3205),
|
| 1012 |
+
(0.7843, 0.3961, 0.3961),
|
| 1013 |
+
(0.8941, 0.6651, 0.6651),
|
| 1014 |
+
(1.0000, 0.9843, 0.9843),
|
| 1015 |
+
)
|
| 1016 |
+
}
|
| 1017 |
+
|
| 1018 |
+
_gist_gray_data = {
|
| 1019 |
+
'red': gfunc[3],
|
| 1020 |
+
'green': gfunc[3],
|
| 1021 |
+
'blue': gfunc[3],
|
| 1022 |
+
}
|
| 1023 |
+
|
| 1024 |
+
def _gist_heat_red(x): return 1.5 * x
|
| 1025 |
+
def _gist_heat_green(x): return 2 * x - 1
|
| 1026 |
+
def _gist_heat_blue(x): return 4 * x - 3
|
| 1027 |
+
_gist_heat_data = {
|
| 1028 |
+
'red': _gist_heat_red, 'green': _gist_heat_green, 'blue': _gist_heat_blue}
|
| 1029 |
+
|
| 1030 |
+
_gist_ncar_data = {
|
| 1031 |
+
'red': (
|
| 1032 |
+
(0.0, 0.0, 0.0000),
|
| 1033 |
+
(0.3098, 0.0000, 0.0000),
|
| 1034 |
+
(0.3725, 0.3993, 0.3993),
|
| 1035 |
+
(0.4235, 0.5003, 0.5003),
|
| 1036 |
+
(0.5333, 1.0000, 1.0000),
|
| 1037 |
+
(0.7922, 1.0000, 1.0000),
|
| 1038 |
+
(0.8471, 0.6218, 0.6218),
|
| 1039 |
+
(0.8980, 0.9235, 0.9235),
|
| 1040 |
+
(1.0000, 0.9961, 0.9961),
|
| 1041 |
+
),
|
| 1042 |
+
'green': (
|
| 1043 |
+
(0.0, 0.0, 0.0000),
|
| 1044 |
+
(0.0510, 0.3722, 0.3722),
|
| 1045 |
+
(0.1059, 0.0000, 0.0000),
|
| 1046 |
+
(0.1569, 0.7202, 0.7202),
|
| 1047 |
+
(0.1608, 0.7537, 0.7537),
|
| 1048 |
+
(0.1647, 0.7752, 0.7752),
|
| 1049 |
+
(0.2157, 1.0000, 1.0000),
|
| 1050 |
+
(0.2588, 0.9804, 0.9804),
|
| 1051 |
+
(0.2706, 0.9804, 0.9804),
|
| 1052 |
+
(0.3176, 1.0000, 1.0000),
|
| 1053 |
+
(0.3686, 0.8081, 0.8081),
|
| 1054 |
+
(0.4275, 1.0000, 1.0000),
|
| 1055 |
+
(0.5216, 1.0000, 1.0000),
|
| 1056 |
+
(0.6314, 0.7292, 0.7292),
|
| 1057 |
+
(0.6863, 0.2796, 0.2796),
|
| 1058 |
+
(0.7451, 0.0000, 0.0000),
|
| 1059 |
+
(0.7922, 0.0000, 0.0000),
|
| 1060 |
+
(0.8431, 0.1753, 0.1753),
|
| 1061 |
+
(0.8980, 0.5000, 0.5000),
|
| 1062 |
+
(1.0000, 0.9725, 0.9725),
|
| 1063 |
+
),
|
| 1064 |
+
'blue': (
|
| 1065 |
+
(0.0, 0.5020, 0.5020),
|
| 1066 |
+
(0.0510, 0.0222, 0.0222),
|
| 1067 |
+
(0.1098, 1.0000, 1.0000),
|
| 1068 |
+
(0.2039, 1.0000, 1.0000),
|
| 1069 |
+
(0.2627, 0.6145, 0.6145),
|
| 1070 |
+
(0.3216, 0.0000, 0.0000),
|
| 1071 |
+
(0.4157, 0.0000, 0.0000),
|
| 1072 |
+
(0.4745, 0.2342, 0.2342),
|
| 1073 |
+
(0.5333, 0.0000, 0.0000),
|
| 1074 |
+
(0.5804, 0.0000, 0.0000),
|
| 1075 |
+
(0.6314, 0.0549, 0.0549),
|
| 1076 |
+
(0.6902, 0.0000, 0.0000),
|
| 1077 |
+
(0.7373, 0.0000, 0.0000),
|
| 1078 |
+
(0.7922, 0.9738, 0.9738),
|
| 1079 |
+
(0.8000, 1.0000, 1.0000),
|
| 1080 |
+
(0.8431, 1.0000, 1.0000),
|
| 1081 |
+
(0.8980, 0.9341, 0.9341),
|
| 1082 |
+
(1.0000, 0.9961, 0.9961),
|
| 1083 |
+
)
|
| 1084 |
+
}
|
| 1085 |
+
|
| 1086 |
+
_gist_rainbow_data = (
|
| 1087 |
+
(0.000, (1.00, 0.00, 0.16)),
|
| 1088 |
+
(0.030, (1.00, 0.00, 0.00)),
|
| 1089 |
+
(0.215, (1.00, 1.00, 0.00)),
|
| 1090 |
+
(0.400, (0.00, 1.00, 0.00)),
|
| 1091 |
+
(0.586, (0.00, 1.00, 1.00)),
|
| 1092 |
+
(0.770, (0.00, 0.00, 1.00)),
|
| 1093 |
+
(0.954, (1.00, 0.00, 1.00)),
|
| 1094 |
+
(1.000, (1.00, 0.00, 0.75))
|
| 1095 |
+
)
|
| 1096 |
+
|
| 1097 |
+
_gist_stern_data = {
|
| 1098 |
+
'red': (
|
| 1099 |
+
(0.000, 0.000, 0.000), (0.0547, 1.000, 1.000),
|
| 1100 |
+
(0.250, 0.027, 0.250), # (0.2500, 0.250, 0.250),
|
| 1101 |
+
(1.000, 1.000, 1.000)),
|
| 1102 |
+
'green': ((0, 0, 0), (1, 1, 1)),
|
| 1103 |
+
'blue': (
|
| 1104 |
+
(0.000, 0.000, 0.000), (0.500, 1.000, 1.000),
|
| 1105 |
+
(0.735, 0.000, 0.000), (1.000, 1.000, 1.000))
|
| 1106 |
+
}
|
| 1107 |
+
|
| 1108 |
+
def _gist_yarg(x): return 1 - x
|
| 1109 |
+
_gist_yarg_data = {'red': _gist_yarg, 'green': _gist_yarg, 'blue': _gist_yarg}
|
| 1110 |
+
|
| 1111 |
+
# This bipolar colormap was generated from CoolWarmFloat33.csv of
|
| 1112 |
+
# "Diverging Color Maps for Scientific Visualization" by Kenneth Moreland.
|
| 1113 |
+
# <http://www.kennethmoreland.com/color-maps/>
|
| 1114 |
+
_coolwarm_data = {
|
| 1115 |
+
'red': [
|
| 1116 |
+
(0.0, 0.2298057, 0.2298057),
|
| 1117 |
+
(0.03125, 0.26623388, 0.26623388),
|
| 1118 |
+
(0.0625, 0.30386891, 0.30386891),
|
| 1119 |
+
(0.09375, 0.342804478, 0.342804478),
|
| 1120 |
+
(0.125, 0.38301334, 0.38301334),
|
| 1121 |
+
(0.15625, 0.424369608, 0.424369608),
|
| 1122 |
+
(0.1875, 0.46666708, 0.46666708),
|
| 1123 |
+
(0.21875, 0.509635204, 0.509635204),
|
| 1124 |
+
(0.25, 0.552953156, 0.552953156),
|
| 1125 |
+
(0.28125, 0.596262162, 0.596262162),
|
| 1126 |
+
(0.3125, 0.639176211, 0.639176211),
|
| 1127 |
+
(0.34375, 0.681291281, 0.681291281),
|
| 1128 |
+
(0.375, 0.722193294, 0.722193294),
|
| 1129 |
+
(0.40625, 0.761464949, 0.761464949),
|
| 1130 |
+
(0.4375, 0.798691636, 0.798691636),
|
| 1131 |
+
(0.46875, 0.833466556, 0.833466556),
|
| 1132 |
+
(0.5, 0.865395197, 0.865395197),
|
| 1133 |
+
(0.53125, 0.897787179, 0.897787179),
|
| 1134 |
+
(0.5625, 0.924127593, 0.924127593),
|
| 1135 |
+
(0.59375, 0.944468518, 0.944468518),
|
| 1136 |
+
(0.625, 0.958852946, 0.958852946),
|
| 1137 |
+
(0.65625, 0.96732803, 0.96732803),
|
| 1138 |
+
(0.6875, 0.969954137, 0.969954137),
|
| 1139 |
+
(0.71875, 0.966811177, 0.966811177),
|
| 1140 |
+
(0.75, 0.958003065, 0.958003065),
|
| 1141 |
+
(0.78125, 0.943660866, 0.943660866),
|
| 1142 |
+
(0.8125, 0.923944917, 0.923944917),
|
| 1143 |
+
(0.84375, 0.89904617, 0.89904617),
|
| 1144 |
+
(0.875, 0.869186849, 0.869186849),
|
| 1145 |
+
(0.90625, 0.834620542, 0.834620542),
|
| 1146 |
+
(0.9375, 0.795631745, 0.795631745),
|
| 1147 |
+
(0.96875, 0.752534934, 0.752534934),
|
| 1148 |
+
(1.0, 0.705673158, 0.705673158)],
|
| 1149 |
+
'green': [
|
| 1150 |
+
(0.0, 0.298717966, 0.298717966),
|
| 1151 |
+
(0.03125, 0.353094838, 0.353094838),
|
| 1152 |
+
(0.0625, 0.406535296, 0.406535296),
|
| 1153 |
+
(0.09375, 0.458757618, 0.458757618),
|
| 1154 |
+
(0.125, 0.50941904, 0.50941904),
|
| 1155 |
+
(0.15625, 0.558148092, 0.558148092),
|
| 1156 |
+
(0.1875, 0.604562568, 0.604562568),
|
| 1157 |
+
(0.21875, 0.648280772, 0.648280772),
|
| 1158 |
+
(0.25, 0.688929332, 0.688929332),
|
| 1159 |
+
(0.28125, 0.726149107, 0.726149107),
|
| 1160 |
+
(0.3125, 0.759599947, 0.759599947),
|
| 1161 |
+
(0.34375, 0.788964712, 0.788964712),
|
| 1162 |
+
(0.375, 0.813952739, 0.813952739),
|
| 1163 |
+
(0.40625, 0.834302879, 0.834302879),
|
| 1164 |
+
(0.4375, 0.849786142, 0.849786142),
|
| 1165 |
+
(0.46875, 0.860207984, 0.860207984),
|
| 1166 |
+
(0.5, 0.86541021, 0.86541021),
|
| 1167 |
+
(0.53125, 0.848937047, 0.848937047),
|
| 1168 |
+
(0.5625, 0.827384882, 0.827384882),
|
| 1169 |
+
(0.59375, 0.800927443, 0.800927443),
|
| 1170 |
+
(0.625, 0.769767752, 0.769767752),
|
| 1171 |
+
(0.65625, 0.734132809, 0.734132809),
|
| 1172 |
+
(0.6875, 0.694266682, 0.694266682),
|
| 1173 |
+
(0.71875, 0.650421156, 0.650421156),
|
| 1174 |
+
(0.75, 0.602842431, 0.602842431),
|
| 1175 |
+
(0.78125, 0.551750968, 0.551750968),
|
| 1176 |
+
(0.8125, 0.49730856, 0.49730856),
|
| 1177 |
+
(0.84375, 0.439559467, 0.439559467),
|
| 1178 |
+
(0.875, 0.378313092, 0.378313092),
|
| 1179 |
+
(0.90625, 0.312874446, 0.312874446),
|
| 1180 |
+
(0.9375, 0.24128379, 0.24128379),
|
| 1181 |
+
(0.96875, 0.157246067, 0.157246067),
|
| 1182 |
+
(1.0, 0.01555616, 0.01555616)],
|
| 1183 |
+
'blue': [
|
| 1184 |
+
(0.0, 0.753683153, 0.753683153),
|
| 1185 |
+
(0.03125, 0.801466763, 0.801466763),
|
| 1186 |
+
(0.0625, 0.84495867, 0.84495867),
|
| 1187 |
+
(0.09375, 0.883725899, 0.883725899),
|
| 1188 |
+
(0.125, 0.917387822, 0.917387822),
|
| 1189 |
+
(0.15625, 0.945619588, 0.945619588),
|
| 1190 |
+
(0.1875, 0.968154911, 0.968154911),
|
| 1191 |
+
(0.21875, 0.98478814, 0.98478814),
|
| 1192 |
+
(0.25, 0.995375608, 0.995375608),
|
| 1193 |
+
(0.28125, 0.999836203, 0.999836203),
|
| 1194 |
+
(0.3125, 0.998151185, 0.998151185),
|
| 1195 |
+
(0.34375, 0.990363227, 0.990363227),
|
| 1196 |
+
(0.375, 0.976574709, 0.976574709),
|
| 1197 |
+
(0.40625, 0.956945269, 0.956945269),
|
| 1198 |
+
(0.4375, 0.931688648, 0.931688648),
|
| 1199 |
+
(0.46875, 0.901068838, 0.901068838),
|
| 1200 |
+
(0.5, 0.865395561, 0.865395561),
|
| 1201 |
+
(0.53125, 0.820880546, 0.820880546),
|
| 1202 |
+
(0.5625, 0.774508472, 0.774508472),
|
| 1203 |
+
(0.59375, 0.726736146, 0.726736146),
|
| 1204 |
+
(0.625, 0.678007945, 0.678007945),
|
| 1205 |
+
(0.65625, 0.628751763, 0.628751763),
|
| 1206 |
+
(0.6875, 0.579375448, 0.579375448),
|
| 1207 |
+
(0.71875, 0.530263762, 0.530263762),
|
| 1208 |
+
(0.75, 0.481775914, 0.481775914),
|
| 1209 |
+
(0.78125, 0.434243684, 0.434243684),
|
| 1210 |
+
(0.8125, 0.387970225, 0.387970225),
|
| 1211 |
+
(0.84375, 0.343229596, 0.343229596),
|
| 1212 |
+
(0.875, 0.300267182, 0.300267182),
|
| 1213 |
+
(0.90625, 0.259301199, 0.259301199),
|
| 1214 |
+
(0.9375, 0.220525627, 0.220525627),
|
| 1215 |
+
(0.96875, 0.184115123, 0.184115123),
|
| 1216 |
+
(1.0, 0.150232812, 0.150232812)]
|
| 1217 |
+
}
|
| 1218 |
+
|
| 1219 |
+
# Implementation of Carey Rappaport's CMRmap.
|
| 1220 |
+
# See `A Color Map for Effective Black-and-White Rendering of Color-Scale
|
| 1221 |
+
# Images' by Carey Rappaport
|
| 1222 |
+
# https://www.mathworks.com/matlabcentral/fileexchange/2662-cmrmap-m
|
| 1223 |
+
_CMRmap_data = {'red': ((0.000, 0.00, 0.00),
|
| 1224 |
+
(0.125, 0.15, 0.15),
|
| 1225 |
+
(0.250, 0.30, 0.30),
|
| 1226 |
+
(0.375, 0.60, 0.60),
|
| 1227 |
+
(0.500, 1.00, 1.00),
|
| 1228 |
+
(0.625, 0.90, 0.90),
|
| 1229 |
+
(0.750, 0.90, 0.90),
|
| 1230 |
+
(0.875, 0.90, 0.90),
|
| 1231 |
+
(1.000, 1.00, 1.00)),
|
| 1232 |
+
'green': ((0.000, 0.00, 0.00),
|
| 1233 |
+
(0.125, 0.15, 0.15),
|
| 1234 |
+
(0.250, 0.15, 0.15),
|
| 1235 |
+
(0.375, 0.20, 0.20),
|
| 1236 |
+
(0.500, 0.25, 0.25),
|
| 1237 |
+
(0.625, 0.50, 0.50),
|
| 1238 |
+
(0.750, 0.75, 0.75),
|
| 1239 |
+
(0.875, 0.90, 0.90),
|
| 1240 |
+
(1.000, 1.00, 1.00)),
|
| 1241 |
+
'blue': ((0.000, 0.00, 0.00),
|
| 1242 |
+
(0.125, 0.50, 0.50),
|
| 1243 |
+
(0.250, 0.75, 0.75),
|
| 1244 |
+
(0.375, 0.50, 0.50),
|
| 1245 |
+
(0.500, 0.15, 0.15),
|
| 1246 |
+
(0.625, 0.00, 0.00),
|
| 1247 |
+
(0.750, 0.10, 0.10),
|
| 1248 |
+
(0.875, 0.50, 0.50),
|
| 1249 |
+
(1.000, 1.00, 1.00))}
|
| 1250 |
+
|
| 1251 |
+
|
| 1252 |
+
# An MIT licensed, colorblind-friendly heatmap from Wistia:
|
| 1253 |
+
# https://github.com/wistia/heatmap-palette
|
| 1254 |
+
# https://wistia.com/learn/culture/heatmaps-for-colorblindness
|
| 1255 |
+
#
|
| 1256 |
+
# >>> import matplotlib.colors as c
|
| 1257 |
+
# >>> colors = ["#e4ff7a", "#ffe81a", "#ffbd00", "#ffa000", "#fc7f00"]
|
| 1258 |
+
# >>> cm = c.LinearSegmentedColormap.from_list('wistia', colors)
|
| 1259 |
+
# >>> _wistia_data = cm._segmentdata
|
| 1260 |
+
# >>> del _wistia_data['alpha']
|
| 1261 |
+
#
|
| 1262 |
+
_wistia_data = {
|
| 1263 |
+
'red': [(0.0, 0.8941176470588236, 0.8941176470588236),
|
| 1264 |
+
(0.25, 1.0, 1.0),
|
| 1265 |
+
(0.5, 1.0, 1.0),
|
| 1266 |
+
(0.75, 1.0, 1.0),
|
| 1267 |
+
(1.0, 0.9882352941176471, 0.9882352941176471)],
|
| 1268 |
+
'green': [(0.0, 1.0, 1.0),
|
| 1269 |
+
(0.25, 0.9098039215686274, 0.9098039215686274),
|
| 1270 |
+
(0.5, 0.7411764705882353, 0.7411764705882353),
|
| 1271 |
+
(0.75, 0.6274509803921569, 0.6274509803921569),
|
| 1272 |
+
(1.0, 0.4980392156862745, 0.4980392156862745)],
|
| 1273 |
+
'blue': [(0.0, 0.47843137254901963, 0.47843137254901963),
|
| 1274 |
+
(0.25, 0.10196078431372549, 0.10196078431372549),
|
| 1275 |
+
(0.5, 0.0, 0.0),
|
| 1276 |
+
(0.75, 0.0, 0.0),
|
| 1277 |
+
(1.0, 0.0, 0.0)],
|
| 1278 |
+
}
|
| 1279 |
+
|
| 1280 |
+
|
| 1281 |
+
# Categorical palettes from Vega:
|
| 1282 |
+
# https://github.com/vega/vega/wiki/Scales
|
| 1283 |
+
# (divided by 255)
|
| 1284 |
+
#
|
| 1285 |
+
|
| 1286 |
+
_tab10_data = (
|
| 1287 |
+
(0.12156862745098039, 0.4666666666666667, 0.7058823529411765 ), # 1f77b4
|
| 1288 |
+
(1.0, 0.4980392156862745, 0.054901960784313725), # ff7f0e
|
| 1289 |
+
(0.17254901960784313, 0.6274509803921569, 0.17254901960784313 ), # 2ca02c
|
| 1290 |
+
(0.8392156862745098, 0.15294117647058825, 0.1568627450980392 ), # d62728
|
| 1291 |
+
(0.5803921568627451, 0.403921568627451, 0.7411764705882353 ), # 9467bd
|
| 1292 |
+
(0.5490196078431373, 0.33725490196078434, 0.29411764705882354 ), # 8c564b
|
| 1293 |
+
(0.8901960784313725, 0.4666666666666667, 0.7607843137254902 ), # e377c2
|
| 1294 |
+
(0.4980392156862745, 0.4980392156862745, 0.4980392156862745 ), # 7f7f7f
|
| 1295 |
+
(0.7372549019607844, 0.7411764705882353, 0.13333333333333333 ), # bcbd22
|
| 1296 |
+
(0.09019607843137255, 0.7450980392156863, 0.8117647058823529), # 17becf
|
| 1297 |
+
)
|
| 1298 |
+
|
| 1299 |
+
_tab20_data = (
|
| 1300 |
+
(0.12156862745098039, 0.4666666666666667, 0.7058823529411765 ), # 1f77b4
|
| 1301 |
+
(0.6823529411764706, 0.7803921568627451, 0.9098039215686274 ), # aec7e8
|
| 1302 |
+
(1.0, 0.4980392156862745, 0.054901960784313725), # ff7f0e
|
| 1303 |
+
(1.0, 0.7333333333333333, 0.47058823529411764 ), # ffbb78
|
| 1304 |
+
(0.17254901960784313, 0.6274509803921569, 0.17254901960784313 ), # 2ca02c
|
| 1305 |
+
(0.596078431372549, 0.8745098039215686, 0.5411764705882353 ), # 98df8a
|
| 1306 |
+
(0.8392156862745098, 0.15294117647058825, 0.1568627450980392 ), # d62728
|
| 1307 |
+
(1.0, 0.596078431372549, 0.5882352941176471 ), # ff9896
|
| 1308 |
+
(0.5803921568627451, 0.403921568627451, 0.7411764705882353 ), # 9467bd
|
| 1309 |
+
(0.7725490196078432, 0.6901960784313725, 0.8352941176470589 ), # c5b0d5
|
| 1310 |
+
(0.5490196078431373, 0.33725490196078434, 0.29411764705882354 ), # 8c564b
|
| 1311 |
+
(0.7686274509803922, 0.611764705882353, 0.5803921568627451 ), # c49c94
|
| 1312 |
+
(0.8901960784313725, 0.4666666666666667, 0.7607843137254902 ), # e377c2
|
| 1313 |
+
(0.9686274509803922, 0.7137254901960784, 0.8235294117647058 ), # f7b6d2
|
| 1314 |
+
(0.4980392156862745, 0.4980392156862745, 0.4980392156862745 ), # 7f7f7f
|
| 1315 |
+
(0.7803921568627451, 0.7803921568627451, 0.7803921568627451 ), # c7c7c7
|
| 1316 |
+
(0.7372549019607844, 0.7411764705882353, 0.13333333333333333 ), # bcbd22
|
| 1317 |
+
(0.8588235294117647, 0.8588235294117647, 0.5529411764705883 ), # dbdb8d
|
| 1318 |
+
(0.09019607843137255, 0.7450980392156863, 0.8117647058823529 ), # 17becf
|
| 1319 |
+
(0.6196078431372549, 0.8549019607843137, 0.8980392156862745), # 9edae5
|
| 1320 |
+
)
|
| 1321 |
+
|
| 1322 |
+
_tab20b_data = (
|
| 1323 |
+
(0.2235294117647059, 0.23137254901960785, 0.4745098039215686 ), # 393b79
|
| 1324 |
+
(0.3215686274509804, 0.32941176470588235, 0.6392156862745098 ), # 5254a3
|
| 1325 |
+
(0.4196078431372549, 0.43137254901960786, 0.8117647058823529 ), # 6b6ecf
|
| 1326 |
+
(0.611764705882353, 0.6196078431372549, 0.8705882352941177 ), # 9c9ede
|
| 1327 |
+
(0.38823529411764707, 0.4745098039215686, 0.2235294117647059 ), # 637939
|
| 1328 |
+
(0.5490196078431373, 0.6352941176470588, 0.3215686274509804 ), # 8ca252
|
| 1329 |
+
(0.7098039215686275, 0.8117647058823529, 0.4196078431372549 ), # b5cf6b
|
| 1330 |
+
(0.807843137254902, 0.8588235294117647, 0.611764705882353 ), # cedb9c
|
| 1331 |
+
(0.5490196078431373, 0.42745098039215684, 0.19215686274509805), # 8c6d31
|
| 1332 |
+
(0.7411764705882353, 0.6196078431372549, 0.2235294117647059 ), # bd9e39
|
| 1333 |
+
(0.9058823529411765, 0.7294117647058823, 0.3215686274509804 ), # e7ba52
|
| 1334 |
+
(0.9058823529411765, 0.796078431372549, 0.5803921568627451 ), # e7cb94
|
| 1335 |
+
(0.5176470588235295, 0.23529411764705882, 0.2235294117647059 ), # 843c39
|
| 1336 |
+
(0.6784313725490196, 0.28627450980392155, 0.2901960784313726 ), # ad494a
|
| 1337 |
+
(0.8392156862745098, 0.3803921568627451, 0.4196078431372549 ), # d6616b
|
| 1338 |
+
(0.9058823529411765, 0.5882352941176471, 0.611764705882353 ), # e7969c
|
| 1339 |
+
(0.4823529411764706, 0.2549019607843137, 0.45098039215686275), # 7b4173
|
| 1340 |
+
(0.6470588235294118, 0.3176470588235294, 0.5803921568627451 ), # a55194
|
| 1341 |
+
(0.807843137254902, 0.42745098039215684, 0.7411764705882353 ), # ce6dbd
|
| 1342 |
+
(0.8705882352941177, 0.6196078431372549, 0.8392156862745098 ), # de9ed6
|
| 1343 |
+
)
|
| 1344 |
+
|
| 1345 |
+
_tab20c_data = (
|
| 1346 |
+
(0.19215686274509805, 0.5098039215686274, 0.7411764705882353 ), # 3182bd
|
| 1347 |
+
(0.4196078431372549, 0.6823529411764706, 0.8392156862745098 ), # 6baed6
|
| 1348 |
+
(0.6196078431372549, 0.792156862745098, 0.8823529411764706 ), # 9ecae1
|
| 1349 |
+
(0.7764705882352941, 0.8588235294117647, 0.9372549019607843 ), # c6dbef
|
| 1350 |
+
(0.9019607843137255, 0.3333333333333333, 0.050980392156862744), # e6550d
|
| 1351 |
+
(0.9921568627450981, 0.5529411764705883, 0.23529411764705882 ), # fd8d3c
|
| 1352 |
+
(0.9921568627450981, 0.6823529411764706, 0.4196078431372549 ), # fdae6b
|
| 1353 |
+
(0.9921568627450981, 0.8156862745098039, 0.6352941176470588 ), # fdd0a2
|
| 1354 |
+
(0.19215686274509805, 0.6392156862745098, 0.32941176470588235 ), # 31a354
|
| 1355 |
+
(0.4549019607843137, 0.7686274509803922, 0.4627450980392157 ), # 74c476
|
| 1356 |
+
(0.6313725490196078, 0.8509803921568627, 0.6078431372549019 ), # a1d99b
|
| 1357 |
+
(0.7803921568627451, 0.9137254901960784, 0.7529411764705882 ), # c7e9c0
|
| 1358 |
+
(0.4588235294117647, 0.4196078431372549, 0.6941176470588235 ), # 756bb1
|
| 1359 |
+
(0.6196078431372549, 0.6039215686274509, 0.7843137254901961 ), # 9e9ac8
|
| 1360 |
+
(0.7372549019607844, 0.7411764705882353, 0.8627450980392157 ), # bcbddc
|
| 1361 |
+
(0.8549019607843137, 0.8549019607843137, 0.9215686274509803 ), # dadaeb
|
| 1362 |
+
(0.38823529411764707, 0.38823529411764707, 0.38823529411764707 ), # 636363
|
| 1363 |
+
(0.5882352941176471, 0.5882352941176471, 0.5882352941176471 ), # 969696
|
| 1364 |
+
(0.7411764705882353, 0.7411764705882353, 0.7411764705882353 ), # bdbdbd
|
| 1365 |
+
(0.8509803921568627, 0.8509803921568627, 0.8509803921568627 ), # d9d9d9
|
| 1366 |
+
)
|
| 1367 |
+
|
| 1368 |
+
|
| 1369 |
+
_petroff10_data = (
|
| 1370 |
+
(0.24705882352941178, 0.5647058823529412, 0.8549019607843137), # 3f90da
|
| 1371 |
+
(1.0, 0.6627450980392157, 0.054901960784313725), # ffa90e
|
| 1372 |
+
(0.7411764705882353, 0.12156862745098039, 0.00392156862745098), # bd1f01
|
| 1373 |
+
(0.5803921568627451, 0.6431372549019608, 0.6352941176470588), # 94a4a2
|
| 1374 |
+
(0.5137254901960784, 0.17647058823529413, 0.7137254901960784), # 832db6
|
| 1375 |
+
(0.6627450980392157, 0.4196078431372549, 0.34901960784313724), # a96b59
|
| 1376 |
+
(0.9058823529411765, 0.38823529411764707, 0.0), # e76300
|
| 1377 |
+
(0.7254901960784313, 0.6745098039215687, 0.4392156862745098), # b9ac70
|
| 1378 |
+
(0.44313725490196076, 0.4588235294117647, 0.5058823529411764), # 717581
|
| 1379 |
+
(0.5725490196078431, 0.8549019607843137, 0.8666666666666667), # 92dadd
|
| 1380 |
+
)
|
| 1381 |
+
|
| 1382 |
+
|
| 1383 |
+
datad = {
|
| 1384 |
+
'Blues': _Blues_data,
|
| 1385 |
+
'BrBG': _BrBG_data,
|
| 1386 |
+
'BuGn': _BuGn_data,
|
| 1387 |
+
'BuPu': _BuPu_data,
|
| 1388 |
+
'CMRmap': _CMRmap_data,
|
| 1389 |
+
'GnBu': _GnBu_data,
|
| 1390 |
+
'Greens': _Greens_data,
|
| 1391 |
+
'Greys': _Greys_data,
|
| 1392 |
+
'OrRd': _OrRd_data,
|
| 1393 |
+
'Oranges': _Oranges_data,
|
| 1394 |
+
'PRGn': _PRGn_data,
|
| 1395 |
+
'PiYG': _PiYG_data,
|
| 1396 |
+
'PuBu': _PuBu_data,
|
| 1397 |
+
'PuBuGn': _PuBuGn_data,
|
| 1398 |
+
'PuOr': _PuOr_data,
|
| 1399 |
+
'PuRd': _PuRd_data,
|
| 1400 |
+
'Purples': _Purples_data,
|
| 1401 |
+
'RdBu': _RdBu_data,
|
| 1402 |
+
'RdGy': _RdGy_data,
|
| 1403 |
+
'RdPu': _RdPu_data,
|
| 1404 |
+
'RdYlBu': _RdYlBu_data,
|
| 1405 |
+
'RdYlGn': _RdYlGn_data,
|
| 1406 |
+
'Reds': _Reds_data,
|
| 1407 |
+
'Spectral': _Spectral_data,
|
| 1408 |
+
'Wistia': _wistia_data,
|
| 1409 |
+
'YlGn': _YlGn_data,
|
| 1410 |
+
'YlGnBu': _YlGnBu_data,
|
| 1411 |
+
'YlOrBr': _YlOrBr_data,
|
| 1412 |
+
'YlOrRd': _YlOrRd_data,
|
| 1413 |
+
'afmhot': _afmhot_data,
|
| 1414 |
+
'autumn': _autumn_data,
|
| 1415 |
+
'binary': _binary_data,
|
| 1416 |
+
'bone': _bone_data,
|
| 1417 |
+
'brg': _brg_data,
|
| 1418 |
+
'bwr': _bwr_data,
|
| 1419 |
+
'cool': _cool_data,
|
| 1420 |
+
'coolwarm': _coolwarm_data,
|
| 1421 |
+
'copper': _copper_data,
|
| 1422 |
+
'cubehelix': _cubehelix_data,
|
| 1423 |
+
'flag': _flag_data,
|
| 1424 |
+
'gist_earth': _gist_earth_data,
|
| 1425 |
+
'gist_gray': _gist_gray_data,
|
| 1426 |
+
'gist_heat': _gist_heat_data,
|
| 1427 |
+
'gist_ncar': _gist_ncar_data,
|
| 1428 |
+
'gist_rainbow': _gist_rainbow_data,
|
| 1429 |
+
'gist_stern': _gist_stern_data,
|
| 1430 |
+
'gist_yarg': _gist_yarg_data,
|
| 1431 |
+
'gnuplot': _gnuplot_data,
|
| 1432 |
+
'gnuplot2': _gnuplot2_data,
|
| 1433 |
+
'gray': _gray_data,
|
| 1434 |
+
'hot': _hot_data,
|
| 1435 |
+
'hsv': _hsv_data,
|
| 1436 |
+
'jet': _jet_data,
|
| 1437 |
+
'nipy_spectral': _nipy_spectral_data,
|
| 1438 |
+
'ocean': _ocean_data,
|
| 1439 |
+
'pink': _pink_data,
|
| 1440 |
+
'prism': _prism_data,
|
| 1441 |
+
'rainbow': _rainbow_data,
|
| 1442 |
+
'seismic': _seismic_data,
|
| 1443 |
+
'spring': _spring_data,
|
| 1444 |
+
'summer': _summer_data,
|
| 1445 |
+
'terrain': _terrain_data,
|
| 1446 |
+
'winter': _winter_data,
|
| 1447 |
+
# Qualitative
|
| 1448 |
+
'Accent': {'listed': _Accent_data},
|
| 1449 |
+
'Dark2': {'listed': _Dark2_data},
|
| 1450 |
+
'Paired': {'listed': _Paired_data},
|
| 1451 |
+
'Pastel1': {'listed': _Pastel1_data},
|
| 1452 |
+
'Pastel2': {'listed': _Pastel2_data},
|
| 1453 |
+
'Set1': {'listed': _Set1_data},
|
| 1454 |
+
'Set2': {'listed': _Set2_data},
|
| 1455 |
+
'Set3': {'listed': _Set3_data},
|
| 1456 |
+
'tab10': {'listed': _tab10_data},
|
| 1457 |
+
'tab20': {'listed': _tab20_data},
|
| 1458 |
+
'tab20b': {'listed': _tab20b_data},
|
| 1459 |
+
'tab20c': {'listed': _tab20c_data},
|
| 1460 |
+
}
|
llava_video/lib/python3.10/site-packages/matplotlib/_cm_bivar.py
ADDED
|
@@ -0,0 +1,1312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# auto-generated by https://github.com/trygvrad/multivariate_colormaps
|
| 2 |
+
# date: 2024-05-24
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
from matplotlib.colors import SegmentedBivarColormap
|
| 6 |
+
|
| 7 |
+
BiPeak = np.array(
|
| 8 |
+
[0.000, 0.674, 0.931, 0.000, 0.680, 0.922, 0.000, 0.685, 0.914, 0.000,
|
| 9 |
+
0.691, 0.906, 0.000, 0.696, 0.898, 0.000, 0.701, 0.890, 0.000, 0.706,
|
| 10 |
+
0.882, 0.000, 0.711, 0.875, 0.000, 0.715, 0.867, 0.000, 0.720, 0.860,
|
| 11 |
+
0.000, 0.725, 0.853, 0.000, 0.729, 0.845, 0.000, 0.733, 0.838, 0.000,
|
| 12 |
+
0.737, 0.831, 0.000, 0.741, 0.824, 0.000, 0.745, 0.816, 0.000, 0.749,
|
| 13 |
+
0.809, 0.000, 0.752, 0.802, 0.000, 0.756, 0.794, 0.000, 0.759, 0.787,
|
| 14 |
+
0.000, 0.762, 0.779, 0.000, 0.765, 0.771, 0.000, 0.767, 0.764, 0.000,
|
| 15 |
+
0.770, 0.755, 0.000, 0.772, 0.747, 0.000, 0.774, 0.739, 0.000, 0.776,
|
| 16 |
+
0.730, 0.000, 0.777, 0.721, 0.000, 0.779, 0.712, 0.021, 0.780, 0.702,
|
| 17 |
+
0.055, 0.781, 0.693, 0.079, 0.782, 0.682, 0.097, 0.782, 0.672, 0.111,
|
| 18 |
+
0.782, 0.661, 0.122, 0.782, 0.650, 0.132, 0.782, 0.639, 0.140, 0.781,
|
| 19 |
+
0.627, 0.147, 0.781, 0.615, 0.154, 0.780, 0.602, 0.159, 0.778, 0.589,
|
| 20 |
+
0.164, 0.777, 0.576, 0.169, 0.775, 0.563, 0.173, 0.773, 0.549, 0.177,
|
| 21 |
+
0.771, 0.535, 0.180, 0.768, 0.520, 0.184, 0.766, 0.505, 0.187, 0.763,
|
| 22 |
+
0.490, 0.190, 0.760, 0.474, 0.193, 0.756, 0.458, 0.196, 0.753, 0.442,
|
| 23 |
+
0.200, 0.749, 0.425, 0.203, 0.745, 0.408, 0.206, 0.741, 0.391, 0.210,
|
| 24 |
+
0.736, 0.373, 0.213, 0.732, 0.355, 0.216, 0.727, 0.337, 0.220, 0.722,
|
| 25 |
+
0.318, 0.224, 0.717, 0.298, 0.227, 0.712, 0.278, 0.231, 0.707, 0.258,
|
| 26 |
+
0.235, 0.701, 0.236, 0.239, 0.696, 0.214, 0.242, 0.690, 0.190, 0.246,
|
| 27 |
+
0.684, 0.165, 0.250, 0.678, 0.136, 0.000, 0.675, 0.934, 0.000, 0.681,
|
| 28 |
+
0.925, 0.000, 0.687, 0.917, 0.000, 0.692, 0.909, 0.000, 0.697, 0.901,
|
| 29 |
+
0.000, 0.703, 0.894, 0.000, 0.708, 0.886, 0.000, 0.713, 0.879, 0.000,
|
| 30 |
+
0.718, 0.872, 0.000, 0.722, 0.864, 0.000, 0.727, 0.857, 0.000, 0.731,
|
| 31 |
+
0.850, 0.000, 0.736, 0.843, 0.000, 0.740, 0.836, 0.000, 0.744, 0.829,
|
| 32 |
+
0.000, 0.748, 0.822, 0.000, 0.752, 0.815, 0.000, 0.755, 0.808, 0.000,
|
| 33 |
+
0.759, 0.800, 0.000, 0.762, 0.793, 0.000, 0.765, 0.786, 0.000, 0.768,
|
| 34 |
+
0.778, 0.000, 0.771, 0.770, 0.000, 0.773, 0.762, 0.051, 0.776, 0.754,
|
| 35 |
+
0.087, 0.778, 0.746, 0.111, 0.780, 0.737, 0.131, 0.782, 0.728, 0.146,
|
| 36 |
+
0.783, 0.719, 0.159, 0.784, 0.710, 0.171, 0.785, 0.700, 0.180, 0.786,
|
| 37 |
+
0.690, 0.189, 0.786, 0.680, 0.196, 0.787, 0.669, 0.202, 0.787, 0.658,
|
| 38 |
+
0.208, 0.786, 0.647, 0.213, 0.786, 0.635, 0.217, 0.785, 0.623, 0.221,
|
| 39 |
+
0.784, 0.610, 0.224, 0.782, 0.597, 0.227, 0.781, 0.584, 0.230, 0.779,
|
| 40 |
+
0.570, 0.232, 0.777, 0.556, 0.234, 0.775, 0.542, 0.236, 0.772, 0.527,
|
| 41 |
+
0.238, 0.769, 0.512, 0.240, 0.766, 0.497, 0.242, 0.763, 0.481, 0.244,
|
| 42 |
+
0.760, 0.465, 0.246, 0.756, 0.448, 0.248, 0.752, 0.432, 0.250, 0.748,
|
| 43 |
+
0.415, 0.252, 0.744, 0.397, 0.254, 0.739, 0.379, 0.256, 0.735, 0.361,
|
| 44 |
+
0.259, 0.730, 0.343, 0.261, 0.725, 0.324, 0.264, 0.720, 0.304, 0.266,
|
| 45 |
+
0.715, 0.284, 0.269, 0.709, 0.263, 0.271, 0.704, 0.242, 0.274, 0.698,
|
| 46 |
+
0.220, 0.277, 0.692, 0.196, 0.280, 0.686, 0.170, 0.283, 0.680, 0.143,
|
| 47 |
+
0.000, 0.676, 0.937, 0.000, 0.682, 0.928, 0.000, 0.688, 0.920, 0.000,
|
| 48 |
+
0.694, 0.913, 0.000, 0.699, 0.905, 0.000, 0.704, 0.897, 0.000, 0.710,
|
| 49 |
+
0.890, 0.000, 0.715, 0.883, 0.000, 0.720, 0.876, 0.000, 0.724, 0.869,
|
| 50 |
+
0.000, 0.729, 0.862, 0.000, 0.734, 0.855, 0.000, 0.738, 0.848, 0.000,
|
| 51 |
+
0.743, 0.841, 0.000, 0.747, 0.834, 0.000, 0.751, 0.827, 0.000, 0.755,
|
| 52 |
+
0.820, 0.000, 0.759, 0.813, 0.000, 0.762, 0.806, 0.003, 0.766, 0.799,
|
| 53 |
+
0.066, 0.769, 0.792, 0.104, 0.772, 0.784, 0.131, 0.775, 0.777, 0.152,
|
| 54 |
+
0.777, 0.769, 0.170, 0.780, 0.761, 0.185, 0.782, 0.753, 0.198, 0.784,
|
| 55 |
+
0.744, 0.209, 0.786, 0.736, 0.219, 0.787, 0.727, 0.228, 0.788, 0.717,
|
| 56 |
+
0.236, 0.789, 0.708, 0.243, 0.790, 0.698, 0.249, 0.791, 0.688, 0.254,
|
| 57 |
+
0.791, 0.677, 0.259, 0.791, 0.666, 0.263, 0.791, 0.654, 0.266, 0.790,
|
| 58 |
+
0.643, 0.269, 0.789, 0.631, 0.272, 0.788, 0.618, 0.274, 0.787, 0.605,
|
| 59 |
+
0.276, 0.785, 0.592, 0.278, 0.783, 0.578, 0.279, 0.781, 0.564, 0.280,
|
| 60 |
+
0.779, 0.549, 0.282, 0.776, 0.535, 0.283, 0.773, 0.519, 0.284, 0.770,
|
| 61 |
+
0.504, 0.285, 0.767, 0.488, 0.286, 0.763, 0.472, 0.287, 0.759, 0.455,
|
| 62 |
+
0.288, 0.756, 0.438, 0.289, 0.751, 0.421, 0.291, 0.747, 0.403, 0.292,
|
| 63 |
+
0.742, 0.385, 0.293, 0.738, 0.367, 0.295, 0.733, 0.348, 0.296, 0.728,
|
| 64 |
+
0.329, 0.298, 0.723, 0.310, 0.300, 0.717, 0.290, 0.302, 0.712, 0.269,
|
| 65 |
+
0.304, 0.706, 0.247, 0.306, 0.700, 0.225, 0.308, 0.694, 0.201, 0.310,
|
| 66 |
+
0.688, 0.176, 0.312, 0.682, 0.149, 0.000, 0.678, 0.939, 0.000, 0.683,
|
| 67 |
+
0.931, 0.000, 0.689, 0.923, 0.000, 0.695, 0.916, 0.000, 0.701, 0.908,
|
| 68 |
+
0.000, 0.706, 0.901, 0.000, 0.711, 0.894, 0.000, 0.717, 0.887, 0.000,
|
| 69 |
+
0.722, 0.880, 0.000, 0.727, 0.873, 0.000, 0.732, 0.866, 0.000, 0.736,
|
| 70 |
+
0.859, 0.000, 0.741, 0.853, 0.000, 0.745, 0.846, 0.000, 0.750, 0.839,
|
| 71 |
+
0.000, 0.754, 0.833, 0.035, 0.758, 0.826, 0.091, 0.762, 0.819, 0.126,
|
| 72 |
+
0.765, 0.812, 0.153, 0.769, 0.805, 0.174, 0.772, 0.798, 0.193, 0.775,
|
| 73 |
+
0.791, 0.209, 0.778, 0.783, 0.223, 0.781, 0.776, 0.236, 0.784, 0.768,
|
| 74 |
+
0.247, 0.786, 0.760, 0.257, 0.788, 0.752, 0.266, 0.790, 0.743, 0.273,
|
| 75 |
+
0.791, 0.734, 0.280, 0.793, 0.725, 0.287, 0.794, 0.715, 0.292, 0.794,
|
| 76 |
+
0.706, 0.297, 0.795, 0.695, 0.301, 0.795, 0.685, 0.305, 0.795, 0.674,
|
| 77 |
+
0.308, 0.795, 0.662, 0.310, 0.794, 0.651, 0.312, 0.794, 0.638, 0.314,
|
| 78 |
+
0.792, 0.626, 0.316, 0.791, 0.613, 0.317, 0.789, 0.599, 0.318, 0.787,
|
| 79 |
+
0.586, 0.319, 0.785, 0.571, 0.320, 0.783, 0.557, 0.320, 0.780, 0.542,
|
| 80 |
+
0.321, 0.777, 0.527, 0.321, 0.774, 0.511, 0.322, 0.770, 0.495, 0.322,
|
| 81 |
+
0.767, 0.478, 0.323, 0.763, 0.462, 0.323, 0.759, 0.445, 0.324, 0.755,
|
| 82 |
+
0.427, 0.325, 0.750, 0.410, 0.325, 0.745, 0.391, 0.326, 0.741, 0.373,
|
| 83 |
+
0.327, 0.736, 0.354, 0.328, 0.730, 0.335, 0.329, 0.725, 0.315, 0.330,
|
| 84 |
+
0.720, 0.295, 0.331, 0.714, 0.274, 0.333, 0.708, 0.253, 0.334, 0.702,
|
| 85 |
+
0.230, 0.336, 0.696, 0.207, 0.337, 0.690, 0.182, 0.339, 0.684, 0.154,
|
| 86 |
+
0.000, 0.679, 0.942, 0.000, 0.685, 0.934, 0.000, 0.691, 0.927, 0.000,
|
| 87 |
+
0.696, 0.919, 0.000, 0.702, 0.912, 0.000, 0.708, 0.905, 0.000, 0.713,
|
| 88 |
+
0.898, 0.000, 0.718, 0.891, 0.000, 0.724, 0.884, 0.000, 0.729, 0.877,
|
| 89 |
+
0.000, 0.734, 0.871, 0.000, 0.739, 0.864, 0.000, 0.743, 0.857, 0.035,
|
| 90 |
+
0.748, 0.851, 0.096, 0.752, 0.844, 0.133, 0.757, 0.838, 0.161, 0.761,
|
| 91 |
+
0.831, 0.185, 0.765, 0.825, 0.205, 0.769, 0.818, 0.223, 0.772, 0.811,
|
| 92 |
+
0.238, 0.776, 0.804, 0.252, 0.779, 0.797, 0.265, 0.782, 0.790, 0.276,
|
| 93 |
+
0.785, 0.783, 0.286, 0.788, 0.775, 0.296, 0.790, 0.767, 0.304, 0.792,
|
| 94 |
+
0.759, 0.311, 0.794, 0.751, 0.318, 0.796, 0.742, 0.324, 0.797, 0.733,
|
| 95 |
+
0.329, 0.798, 0.723, 0.334, 0.799, 0.714, 0.338, 0.799, 0.703, 0.341,
|
| 96 |
+
0.800, 0.693, 0.344, 0.800, 0.682, 0.347, 0.799, 0.670, 0.349, 0.799,
|
| 97 |
+
0.659, 0.351, 0.798, 0.646, 0.352, 0.797, 0.634, 0.353, 0.795, 0.621,
|
| 98 |
+
0.354, 0.794, 0.607, 0.354, 0.792, 0.593, 0.355, 0.789, 0.579, 0.355,
|
| 99 |
+
0.787, 0.564, 0.355, 0.784, 0.549, 0.355, 0.781, 0.534, 0.355, 0.778,
|
| 100 |
+
0.518, 0.355, 0.774, 0.502, 0.355, 0.770, 0.485, 0.355, 0.766, 0.468,
|
| 101 |
+
0.355, 0.762, 0.451, 0.355, 0.758, 0.434, 0.355, 0.753, 0.416, 0.356,
|
| 102 |
+
0.748, 0.397, 0.356, 0.743, 0.379, 0.356, 0.738, 0.360, 0.357, 0.733,
|
| 103 |
+
0.340, 0.357, 0.728, 0.321, 0.358, 0.722, 0.300, 0.359, 0.716, 0.279,
|
| 104 |
+
0.360, 0.710, 0.258, 0.361, 0.704, 0.235, 0.361, 0.698, 0.212, 0.362,
|
| 105 |
+
0.692, 0.187, 0.363, 0.686, 0.160, 0.000, 0.680, 0.945, 0.000, 0.686,
|
| 106 |
+
0.937, 0.000, 0.692, 0.930, 0.000, 0.698, 0.922, 0.000, 0.703, 0.915,
|
| 107 |
+
0.000, 0.709, 0.908, 0.000, 0.715, 0.901, 0.000, 0.720, 0.894, 0.000,
|
| 108 |
+
0.726, 0.888, 0.000, 0.731, 0.881, 0.007, 0.736, 0.875, 0.084, 0.741,
|
| 109 |
+
0.869, 0.127, 0.746, 0.862, 0.159, 0.751, 0.856, 0.185, 0.755, 0.850,
|
| 110 |
+
0.208, 0.760, 0.843, 0.227, 0.764, 0.837, 0.245, 0.768, 0.830, 0.260,
|
| 111 |
+
0.772, 0.824, 0.275, 0.776, 0.817, 0.288, 0.779, 0.811, 0.300, 0.783,
|
| 112 |
+
0.804, 0.310, 0.786, 0.797, 0.320, 0.789, 0.789, 0.329, 0.792, 0.782,
|
| 113 |
+
0.337, 0.794, 0.774, 0.345, 0.796, 0.766, 0.351, 0.798, 0.758, 0.357,
|
| 114 |
+
0.800, 0.749, 0.363, 0.801, 0.740, 0.367, 0.803, 0.731, 0.371, 0.803,
|
| 115 |
+
0.721, 0.375, 0.804, 0.711, 0.378, 0.804, 0.701, 0.380, 0.804, 0.690,
|
| 116 |
+
0.382, 0.804, 0.679, 0.384, 0.803, 0.667, 0.385, 0.802, 0.654, 0.386,
|
| 117 |
+
0.801, 0.642, 0.386, 0.800, 0.629, 0.387, 0.798, 0.615, 0.387, 0.796,
|
| 118 |
+
0.601, 0.387, 0.793, 0.587, 0.387, 0.791, 0.572, 0.387, 0.788, 0.557,
|
| 119 |
+
0.386, 0.785, 0.541, 0.386, 0.781, 0.525, 0.385, 0.778, 0.509, 0.385,
|
| 120 |
+
0.774, 0.492, 0.385, 0.770, 0.475, 0.384, 0.765, 0.457, 0.384, 0.761,
|
| 121 |
+
0.440, 0.384, 0.756, 0.422, 0.384, 0.751, 0.403, 0.384, 0.746, 0.384,
|
| 122 |
+
0.384, 0.741, 0.365, 0.384, 0.735, 0.346, 0.384, 0.730, 0.326, 0.384,
|
| 123 |
+
0.724, 0.305, 0.384, 0.718, 0.284, 0.385, 0.712, 0.263, 0.385, 0.706,
|
| 124 |
+
0.240, 0.386, 0.700, 0.217, 0.386, 0.694, 0.192, 0.387, 0.687, 0.165,
|
| 125 |
+
0.000, 0.680, 0.948, 0.000, 0.687, 0.940, 0.000, 0.693, 0.933, 0.000,
|
| 126 |
+
0.699, 0.925, 0.000, 0.705, 0.918, 0.000, 0.711, 0.912, 0.000, 0.716,
|
| 127 |
+
0.905, 0.000, 0.722, 0.898, 0.050, 0.728, 0.892, 0.109, 0.733, 0.886,
|
| 128 |
+
0.147, 0.738, 0.879, 0.177, 0.743, 0.873, 0.202, 0.748, 0.867, 0.224,
|
| 129 |
+
0.753, 0.861, 0.243, 0.758, 0.855, 0.261, 0.763, 0.849, 0.277, 0.767,
|
| 130 |
+
0.842, 0.292, 0.771, 0.836, 0.305, 0.775, 0.830, 0.318, 0.779, 0.823,
|
| 131 |
+
0.329, 0.783, 0.817, 0.340, 0.787, 0.810, 0.350, 0.790, 0.803, 0.359,
|
| 132 |
+
0.793, 0.796, 0.367, 0.796, 0.789, 0.374, 0.798, 0.782, 0.381, 0.801,
|
| 133 |
+
0.774, 0.387, 0.803, 0.766, 0.393, 0.804, 0.757, 0.397, 0.806, 0.748,
|
| 134 |
+
0.402, 0.807, 0.739, 0.405, 0.808, 0.729, 0.408, 0.809, 0.719, 0.411,
|
| 135 |
+
0.809, 0.709, 0.413, 0.809, 0.698, 0.415, 0.808, 0.687, 0.416, 0.808,
|
| 136 |
+
0.675, 0.417, 0.807, 0.663, 0.417, 0.806, 0.650, 0.417, 0.804, 0.637,
|
| 137 |
+
0.418, 0.802, 0.623, 0.417, 0.800, 0.609, 0.417, 0.798, 0.594, 0.416,
|
| 138 |
+
0.795, 0.579, 0.416, 0.792, 0.564, 0.415, 0.789, 0.548, 0.414, 0.785,
|
| 139 |
+
0.532, 0.414, 0.781, 0.515, 0.413, 0.777, 0.499, 0.412, 0.773, 0.481,
|
| 140 |
+
0.412, 0.769, 0.464, 0.411, 0.764, 0.446, 0.410, 0.759, 0.428, 0.410,
|
| 141 |
+
0.754, 0.409, 0.409, 0.749, 0.390, 0.409, 0.743, 0.371, 0.409, 0.738,
|
| 142 |
+
0.351, 0.409, 0.732, 0.331, 0.408, 0.726, 0.310, 0.408, 0.720, 0.289,
|
| 143 |
+
0.408, 0.714, 0.268, 0.408, 0.708, 0.245, 0.409, 0.702, 0.222, 0.409,
|
| 144 |
+
0.695, 0.197, 0.409, 0.689, 0.170, 0.000, 0.681, 0.950, 0.000, 0.688,
|
| 145 |
+
0.943, 0.000, 0.694, 0.936, 0.000, 0.700, 0.929, 0.000, 0.706, 0.922,
|
| 146 |
+
0.000, 0.712, 0.915, 0.074, 0.718, 0.908, 0.124, 0.724, 0.902, 0.159,
|
| 147 |
+
0.730, 0.896, 0.188, 0.735, 0.890, 0.213, 0.740, 0.884, 0.235, 0.746,
|
| 148 |
+
0.878, 0.255, 0.751, 0.872, 0.273, 0.756, 0.866, 0.289, 0.761, 0.860,
|
| 149 |
+
0.305, 0.766, 0.854, 0.319, 0.770, 0.848, 0.332, 0.775, 0.842, 0.344,
|
| 150 |
+
0.779, 0.836, 0.356, 0.783, 0.830, 0.366, 0.787, 0.823, 0.376, 0.790,
|
| 151 |
+
0.817, 0.385, 0.794, 0.810, 0.394, 0.797, 0.803, 0.401, 0.800, 0.796,
|
| 152 |
+
0.408, 0.802, 0.789, 0.414, 0.805, 0.781, 0.420, 0.807, 0.773, 0.425,
|
| 153 |
+
0.809, 0.765, 0.430, 0.810, 0.756, 0.433, 0.812, 0.747, 0.437, 0.813,
|
| 154 |
+
0.738, 0.440, 0.813, 0.728, 0.442, 0.814, 0.717, 0.444, 0.813, 0.706,
|
| 155 |
+
0.445, 0.813, 0.695, 0.446, 0.812, 0.683, 0.446, 0.811, 0.671, 0.447,
|
| 156 |
+
0.810, 0.658, 0.447, 0.809, 0.645, 0.446, 0.807, 0.631, 0.446, 0.804,
|
| 157 |
+
0.617, 0.445, 0.802, 0.602, 0.444, 0.799, 0.587, 0.443, 0.796, 0.571,
|
| 158 |
+
0.442, 0.792, 0.555, 0.441, 0.789, 0.539, 0.440, 0.785, 0.522, 0.439,
|
| 159 |
+
0.781, 0.505, 0.438, 0.776, 0.488, 0.437, 0.772, 0.470, 0.436, 0.767,
|
| 160 |
+
0.452, 0.435, 0.762, 0.433, 0.435, 0.757, 0.415, 0.434, 0.751, 0.396,
|
| 161 |
+
0.433, 0.746, 0.376, 0.432, 0.740, 0.356, 0.432, 0.734, 0.336, 0.431,
|
| 162 |
+
0.728, 0.315, 0.431, 0.722, 0.294, 0.431, 0.716, 0.272, 0.430, 0.710,
|
| 163 |
+
0.250, 0.430, 0.703, 0.226, 0.430, 0.697, 0.201, 0.430, 0.690, 0.175,
|
| 164 |
+
0.000, 0.682, 0.953, 0.000, 0.689, 0.946, 0.000, 0.695, 0.938, 0.002,
|
| 165 |
+
0.701, 0.932, 0.086, 0.708, 0.925, 0.133, 0.714, 0.918, 0.167, 0.720,
|
| 166 |
+
0.912, 0.196, 0.726, 0.906, 0.221, 0.731, 0.900, 0.243, 0.737, 0.894,
|
| 167 |
+
0.263, 0.743, 0.888, 0.281, 0.748, 0.882, 0.298, 0.753, 0.876, 0.314,
|
| 168 |
+
0.759, 0.870, 0.329, 0.764, 0.865, 0.342, 0.768, 0.859, 0.355, 0.773,
|
| 169 |
+
0.853, 0.368, 0.778, 0.847, 0.379, 0.782, 0.842, 0.390, 0.786, 0.836,
|
| 170 |
+
0.400, 0.790, 0.830, 0.409, 0.794, 0.823, 0.417, 0.798, 0.817, 0.425,
|
| 171 |
+
0.801, 0.810, 0.433, 0.804, 0.803, 0.439, 0.807, 0.796, 0.445, 0.809,
|
| 172 |
+
0.789, 0.451, 0.811, 0.781, 0.456, 0.813, 0.773, 0.460, 0.815, 0.764,
|
| 173 |
+
0.463, 0.816, 0.755, 0.466, 0.817, 0.746, 0.469, 0.818, 0.736, 0.471,
|
| 174 |
+
0.818, 0.725, 0.472, 0.818, 0.715, 0.473, 0.818, 0.703, 0.474, 0.817,
|
| 175 |
+
0.691, 0.474, 0.816, 0.679, 0.474, 0.815, 0.666, 0.474, 0.813, 0.653,
|
| 176 |
+
0.473, 0.811, 0.639, 0.473, 0.809, 0.624, 0.472, 0.806, 0.610, 0.471,
|
| 177 |
+
0.803, 0.594, 0.469, 0.800, 0.579, 0.468, 0.796, 0.562, 0.467, 0.792,
|
| 178 |
+
0.546, 0.466, 0.788, 0.529, 0.464, 0.784, 0.512, 0.463, 0.780, 0.494,
|
| 179 |
+
0.462, 0.775, 0.476, 0.460, 0.770, 0.458, 0.459, 0.765, 0.439, 0.458,
|
| 180 |
+
0.759, 0.420, 0.457, 0.754, 0.401, 0.456, 0.748, 0.381, 0.455, 0.742,
|
| 181 |
+
0.361, 0.454, 0.736, 0.341, 0.453, 0.730, 0.320, 0.453, 0.724, 0.299,
|
| 182 |
+
0.452, 0.718, 0.277, 0.452, 0.711, 0.254, 0.451, 0.705, 0.231, 0.451,
|
| 183 |
+
0.698, 0.206, 0.450, 0.691, 0.179, 0.000, 0.683, 0.955, 0.013, 0.689,
|
| 184 |
+
0.948, 0.092, 0.696, 0.941, 0.137, 0.702, 0.935, 0.171, 0.709, 0.928,
|
| 185 |
+
0.200, 0.715, 0.922, 0.225, 0.721, 0.916, 0.247, 0.727, 0.909, 0.267,
|
| 186 |
+
0.733, 0.904, 0.286, 0.739, 0.898, 0.303, 0.745, 0.892, 0.320, 0.750,
|
| 187 |
+
0.886, 0.335, 0.756, 0.881, 0.350, 0.761, 0.875, 0.363, 0.766, 0.870,
|
| 188 |
+
0.376, 0.771, 0.864, 0.388, 0.776, 0.859, 0.400, 0.781, 0.853, 0.411,
|
| 189 |
+
0.785, 0.847, 0.421, 0.790, 0.842, 0.430, 0.794, 0.836, 0.439, 0.798,
|
| 190 |
+
0.830, 0.448, 0.802, 0.824, 0.455, 0.805, 0.817, 0.462, 0.808, 0.810,
|
| 191 |
+
0.469, 0.811, 0.804, 0.475, 0.814, 0.796, 0.480, 0.816, 0.789, 0.484,
|
| 192 |
+
0.818, 0.781, 0.488, 0.820, 0.772, 0.492, 0.821, 0.763, 0.495, 0.822,
|
| 193 |
+
0.754, 0.497, 0.823, 0.744, 0.499, 0.823, 0.734, 0.500, 0.823, 0.723,
|
| 194 |
+
0.501, 0.823, 0.712, 0.501, 0.822, 0.700, 0.501, 0.821, 0.687, 0.501,
|
| 195 |
+
0.819, 0.674, 0.500, 0.818, 0.661, 0.499, 0.815, 0.647, 0.498, 0.813,
|
| 196 |
+
0.632, 0.497, 0.810, 0.617, 0.496, 0.807, 0.602, 0.494, 0.804, 0.586,
|
| 197 |
+
0.493, 0.800, 0.569, 0.491, 0.796, 0.553, 0.490, 0.792, 0.536, 0.488,
|
| 198 |
+
0.787, 0.518, 0.486, 0.783, 0.500, 0.485, 0.778, 0.482, 0.483, 0.773,
|
| 199 |
+
0.463, 0.482, 0.767, 0.445, 0.480, 0.762, 0.425, 0.479, 0.756, 0.406,
|
| 200 |
+
0.478, 0.750, 0.386, 0.477, 0.744, 0.366, 0.476, 0.738, 0.345, 0.475,
|
| 201 |
+
0.732, 0.325, 0.474, 0.726, 0.303, 0.473, 0.719, 0.281, 0.472, 0.713,
|
| 202 |
+
0.258, 0.471, 0.706, 0.235, 0.470, 0.699, 0.210, 0.469, 0.692, 0.184,
|
| 203 |
+
0.095, 0.683, 0.958, 0.139, 0.690, 0.951, 0.173, 0.697, 0.944, 0.201,
|
| 204 |
+
0.703, 0.938, 0.226, 0.710, 0.931, 0.249, 0.716, 0.925, 0.269, 0.723,
|
| 205 |
+
0.919, 0.288, 0.729, 0.913, 0.306, 0.735, 0.907, 0.323, 0.741, 0.902,
|
| 206 |
+
0.339, 0.747, 0.896, 0.354, 0.752, 0.891, 0.368, 0.758, 0.885, 0.382,
|
| 207 |
+
0.764, 0.880, 0.394, 0.769, 0.875, 0.407, 0.774, 0.869, 0.418, 0.779,
|
| 208 |
+
0.864, 0.429, 0.784, 0.859, 0.440, 0.789, 0.853, 0.450, 0.793, 0.848,
|
| 209 |
+
0.459, 0.798, 0.842, 0.468, 0.802, 0.836, 0.476, 0.806, 0.830, 0.483,
|
| 210 |
+
0.809, 0.824, 0.490, 0.812, 0.818, 0.496, 0.815, 0.811, 0.502, 0.818,
|
| 211 |
+
0.804, 0.507, 0.821, 0.796, 0.512, 0.823, 0.789, 0.515, 0.825, 0.780,
|
| 212 |
+
0.519, 0.826, 0.772, 0.521, 0.827, 0.762, 0.524, 0.828, 0.753, 0.525,
|
| 213 |
+
0.828, 0.742, 0.526, 0.828, 0.732, 0.527, 0.828, 0.720, 0.527, 0.827,
|
| 214 |
+
0.708, 0.527, 0.826, 0.696, 0.526, 0.824, 0.683, 0.525, 0.822, 0.669,
|
| 215 |
+
0.524, 0.820, 0.655, 0.523, 0.817, 0.640, 0.522, 0.814, 0.625, 0.520,
|
| 216 |
+
0.811, 0.609, 0.518, 0.808, 0.593, 0.516, 0.804, 0.576, 0.515, 0.800,
|
| 217 |
+
0.559, 0.513, 0.795, 0.542, 0.511, 0.791, 0.524, 0.509, 0.786, 0.506,
|
| 218 |
+
0.507, 0.781, 0.488, 0.505, 0.775, 0.469, 0.504, 0.770, 0.450, 0.502,
|
| 219 |
+
0.764, 0.431, 0.500, 0.759, 0.411, 0.499, 0.753, 0.391, 0.497, 0.746,
|
| 220 |
+
0.371, 0.496, 0.740, 0.350, 0.495, 0.734, 0.329, 0.494, 0.727, 0.307,
|
| 221 |
+
0.492, 0.721, 0.285, 0.491, 0.714, 0.262, 0.490, 0.707, 0.239, 0.489,
|
| 222 |
+
0.700, 0.214, 0.488, 0.693, 0.188, 0.172, 0.684, 0.961, 0.201, 0.691,
|
| 223 |
+
0.954, 0.226, 0.698, 0.947, 0.248, 0.704, 0.941, 0.269, 0.711, 0.934,
|
| 224 |
+
0.289, 0.717, 0.928, 0.307, 0.724, 0.922, 0.324, 0.730, 0.917, 0.340,
|
| 225 |
+
0.736, 0.911, 0.356, 0.743, 0.906, 0.370, 0.749, 0.900, 0.384, 0.755,
|
| 226 |
+
0.895, 0.398, 0.760, 0.890, 0.411, 0.766, 0.885, 0.423, 0.772, 0.880,
|
| 227 |
+
0.435, 0.777, 0.874, 0.446, 0.782, 0.869, 0.457, 0.787, 0.864, 0.467,
|
| 228 |
+
0.792, 0.859, 0.477, 0.797, 0.854, 0.486, 0.801, 0.848, 0.494, 0.806,
|
| 229 |
+
0.843, 0.502, 0.810, 0.837, 0.510, 0.813, 0.831, 0.517, 0.817, 0.825,
|
| 230 |
+
0.523, 0.820, 0.818, 0.528, 0.823, 0.811, 0.533, 0.825, 0.804, 0.538,
|
| 231 |
+
0.828, 0.797, 0.542, 0.829, 0.788, 0.545, 0.831, 0.780, 0.547, 0.832,
|
| 232 |
+
0.771, 0.549, 0.833, 0.761, 0.551, 0.833, 0.751, 0.552, 0.833, 0.740,
|
| 233 |
+
0.552, 0.833, 0.729, 0.552, 0.832, 0.717, 0.551, 0.830, 0.704, 0.551,
|
| 234 |
+
0.829, 0.691, 0.550, 0.827, 0.677, 0.548, 0.824, 0.663, 0.547, 0.822,
|
| 235 |
+
0.648, 0.545, 0.819, 0.632, 0.543, 0.815, 0.617, 0.541, 0.812, 0.600,
|
| 236 |
+
0.539, 0.808, 0.583, 0.537, 0.803, 0.566, 0.535, 0.799, 0.549, 0.533,
|
| 237 |
+
0.794, 0.531, 0.531, 0.789, 0.512, 0.529, 0.784, 0.494, 0.527, 0.778,
|
| 238 |
+
0.475, 0.525, 0.773, 0.455, 0.523, 0.767, 0.436, 0.521, 0.761, 0.416,
|
| 239 |
+
0.519, 0.755, 0.396, 0.517, 0.748, 0.375, 0.516, 0.742, 0.354, 0.514,
|
| 240 |
+
0.735, 0.333, 0.513, 0.729, 0.311, 0.511, 0.722, 0.289, 0.510, 0.715,
|
| 241 |
+
0.266, 0.509, 0.708, 0.242, 0.507, 0.701, 0.218, 0.506, 0.694, 0.191,
|
| 242 |
+
0.224, 0.684, 0.963, 0.247, 0.691, 0.956, 0.268, 0.698, 0.950, 0.287,
|
| 243 |
+
0.705, 0.943, 0.305, 0.712, 0.937, 0.323, 0.719, 0.931, 0.339, 0.725,
|
| 244 |
+
0.926, 0.355, 0.732, 0.920, 0.370, 0.738, 0.915, 0.385, 0.744, 0.909,
|
| 245 |
+
0.399, 0.751, 0.904, 0.412, 0.757, 0.899, 0.425, 0.763, 0.894, 0.438,
|
| 246 |
+
0.768, 0.889, 0.450, 0.774, 0.884, 0.461, 0.780, 0.879, 0.472, 0.785,
|
| 247 |
+
0.875, 0.483, 0.790, 0.870, 0.493, 0.795, 0.865, 0.502, 0.800, 0.860,
|
| 248 |
+
0.511, 0.805, 0.855, 0.520, 0.809, 0.849, 0.528, 0.814, 0.844, 0.535,
|
| 249 |
+
0.818, 0.838, 0.542, 0.821, 0.832, 0.548, 0.824, 0.826, 0.554, 0.827,
|
| 250 |
+
0.819, 0.559, 0.830, 0.812, 0.563, 0.832, 0.805, 0.567, 0.834, 0.797,
|
| 251 |
+
0.570, 0.836, 0.788, 0.572, 0.837, 0.779, 0.574, 0.838, 0.770, 0.575,
|
| 252 |
+
0.838, 0.760, 0.576, 0.838, 0.749, 0.576, 0.838, 0.737, 0.576, 0.837,
|
| 253 |
+
0.725, 0.575, 0.835, 0.713, 0.574, 0.834, 0.699, 0.573, 0.831, 0.685,
|
| 254 |
+
0.571, 0.829, 0.671, 0.570, 0.826, 0.656, 0.568, 0.823, 0.640, 0.566,
|
| 255 |
+
0.819, 0.624, 0.563, 0.815, 0.607, 0.561, 0.811, 0.590, 0.559, 0.807,
|
| 256 |
+
0.573, 0.556, 0.802, 0.555, 0.554, 0.797, 0.537, 0.552, 0.792, 0.518,
|
| 257 |
+
0.549, 0.786, 0.499, 0.547, 0.781, 0.480, 0.545, 0.775, 0.460, 0.543,
|
| 258 |
+
0.769, 0.441, 0.541, 0.763, 0.420, 0.539, 0.756, 0.400, 0.537, 0.750,
|
| 259 |
+
0.379, 0.535, 0.743, 0.358, 0.533, 0.737, 0.337, 0.531, 0.730, 0.315,
|
| 260 |
+
0.530, 0.723, 0.293, 0.528, 0.716, 0.270, 0.527, 0.709, 0.246, 0.525,
|
| 261 |
+
0.702, 0.221, 0.524, 0.694, 0.195, 0.265, 0.685, 0.965, 0.284, 0.692,
|
| 262 |
+
0.959, 0.303, 0.699, 0.952, 0.320, 0.706, 0.946, 0.337, 0.713, 0.940,
|
| 263 |
+
0.353, 0.720, 0.935, 0.369, 0.726, 0.929, 0.384, 0.733, 0.924, 0.398,
|
| 264 |
+
0.739, 0.918, 0.412, 0.746, 0.913, 0.425, 0.752, 0.908, 0.438, 0.759,
|
| 265 |
+
0.903, 0.451, 0.765, 0.899, 0.463, 0.771, 0.894, 0.475, 0.777, 0.889,
|
| 266 |
+
0.486, 0.782, 0.884, 0.497, 0.788, 0.880, 0.507, 0.793, 0.875, 0.517,
|
| 267 |
+
0.799, 0.870, 0.527, 0.804, 0.866, 0.536, 0.809, 0.861, 0.544, 0.813,
|
| 268 |
+
0.856, 0.552, 0.818, 0.850, 0.560, 0.822, 0.845, 0.566, 0.826, 0.839,
|
| 269 |
+
0.573, 0.829, 0.833, 0.578, 0.832, 0.827, 0.583, 0.835, 0.820, 0.587,
|
| 270 |
+
0.837, 0.813, 0.591, 0.839, 0.805, 0.594, 0.841, 0.797, 0.596, 0.842,
|
| 271 |
+
0.788, 0.598, 0.843, 0.778, 0.599, 0.843, 0.768, 0.600, 0.843, 0.758,
|
| 272 |
+
0.600, 0.843, 0.746, 0.599, 0.842, 0.734, 0.599, 0.840, 0.721, 0.597,
|
| 273 |
+
0.838, 0.708, 0.596, 0.836, 0.694, 0.594, 0.834, 0.679, 0.592, 0.831,
|
| 274 |
+
0.663, 0.590, 0.827, 0.648, 0.587, 0.823, 0.631, 0.585, 0.819, 0.614,
|
| 275 |
+
0.582, 0.815, 0.597, 0.580, 0.810, 0.579, 0.577, 0.805, 0.561, 0.575,
|
| 276 |
+
0.800, 0.542, 0.572, 0.795, 0.524, 0.569, 0.789, 0.504, 0.567, 0.783,
|
| 277 |
+
0.485, 0.565, 0.777, 0.465, 0.562, 0.771, 0.445, 0.560, 0.765, 0.425,
|
| 278 |
+
0.558, 0.758, 0.404, 0.556, 0.752, 0.383, 0.554, 0.745, 0.362, 0.552,
|
| 279 |
+
0.738, 0.341, 0.550, 0.731, 0.319, 0.548, 0.724, 0.296, 0.546, 0.717,
|
| 280 |
+
0.273, 0.544, 0.709, 0.249, 0.542, 0.702, 0.224, 0.541, 0.695, 0.198,
|
| 281 |
+
0.299, 0.685, 0.968, 0.317, 0.692, 0.961, 0.334, 0.699, 0.955, 0.350,
|
| 282 |
+
0.706, 0.949, 0.366, 0.713, 0.943, 0.381, 0.720, 0.938, 0.395, 0.727,
|
| 283 |
+
0.932, 0.410, 0.734, 0.927, 0.423, 0.741, 0.922, 0.437, 0.747, 0.917,
|
| 284 |
+
0.450, 0.754, 0.912, 0.463, 0.760, 0.907, 0.475, 0.767, 0.903, 0.487,
|
| 285 |
+
0.773, 0.898, 0.498, 0.779, 0.894, 0.509, 0.785, 0.889, 0.520, 0.791,
|
| 286 |
+
0.885, 0.531, 0.796, 0.880, 0.540, 0.802, 0.876, 0.550, 0.807, 0.871,
|
| 287 |
+
0.559, 0.812, 0.867, 0.568, 0.817, 0.862, 0.576, 0.822, 0.857, 0.583,
|
| 288 |
+
0.826, 0.852, 0.590, 0.830, 0.847, 0.596, 0.834, 0.841, 0.602, 0.837,
|
| 289 |
+
0.835, 0.607, 0.840, 0.828, 0.611, 0.843, 0.821, 0.615, 0.845, 0.814,
|
| 290 |
+
0.618, 0.846, 0.805, 0.620, 0.848, 0.797, 0.622, 0.848, 0.787, 0.623,
|
| 291 |
+
0.849, 0.777, 0.623, 0.849, 0.766, 0.623, 0.848, 0.755, 0.622, 0.847,
|
| 292 |
+
0.743, 0.621, 0.845, 0.730, 0.620, 0.843, 0.716, 0.618, 0.841, 0.702,
|
| 293 |
+
0.616, 0.838, 0.687, 0.613, 0.835, 0.671, 0.611, 0.831, 0.655, 0.608,
|
| 294 |
+
0.827, 0.638, 0.606, 0.823, 0.621, 0.603, 0.818, 0.604, 0.600, 0.814,
|
| 295 |
+
0.585, 0.597, 0.808, 0.567, 0.594, 0.803, 0.548, 0.592, 0.797, 0.529,
|
| 296 |
+
0.589, 0.792, 0.510, 0.586, 0.785, 0.490, 0.584, 0.779, 0.470, 0.581,
|
| 297 |
+
0.773, 0.450, 0.579, 0.766, 0.429, 0.576, 0.760, 0.408, 0.574, 0.753,
|
| 298 |
+
0.387, 0.572, 0.746, 0.366, 0.569, 0.739, 0.344, 0.567, 0.732, 0.322,
|
| 299 |
+
0.565, 0.725, 0.299, 0.563, 0.717, 0.276, 0.561, 0.710, 0.252, 0.559,
|
| 300 |
+
0.703, 0.227, 0.557, 0.695, 0.201, 0.329, 0.685, 0.970, 0.346, 0.692,
|
| 301 |
+
0.964, 0.362, 0.699, 0.958, 0.377, 0.707, 0.952, 0.392, 0.714, 0.946,
|
| 302 |
+
0.406, 0.721, 0.941, 0.420, 0.728, 0.935, 0.434, 0.735, 0.930, 0.447,
|
| 303 |
+
0.742, 0.925, 0.460, 0.749, 0.920, 0.473, 0.756, 0.916, 0.485, 0.762,
|
| 304 |
+
0.911, 0.497, 0.769, 0.907, 0.509, 0.775, 0.903, 0.521, 0.781, 0.898,
|
| 305 |
+
0.532, 0.788, 0.894, 0.542, 0.794, 0.890, 0.553, 0.799, 0.886, 0.563,
|
| 306 |
+
0.805, 0.882, 0.572, 0.811, 0.877, 0.581, 0.816, 0.873, 0.590, 0.821,
|
| 307 |
+
0.868, 0.598, 0.826, 0.864, 0.606, 0.830, 0.859, 0.613, 0.834, 0.854,
|
| 308 |
+
0.619, 0.838, 0.848, 0.625, 0.842, 0.842, 0.630, 0.845, 0.836, 0.634,
|
| 309 |
+
0.848, 0.829, 0.638, 0.850, 0.822, 0.641, 0.852, 0.814, 0.643, 0.853,
|
| 310 |
+
0.805, 0.645, 0.854, 0.796, 0.645, 0.854, 0.786, 0.646, 0.854, 0.775,
|
| 311 |
+
0.645, 0.853, 0.764, 0.645, 0.852, 0.751, 0.643, 0.851, 0.738, 0.642,
|
| 312 |
+
0.848, 0.725, 0.639, 0.846, 0.710, 0.637, 0.843, 0.695, 0.635, 0.839,
|
| 313 |
+
0.679, 0.632, 0.836, 0.662, 0.629, 0.831, 0.645, 0.626, 0.827, 0.628,
|
| 314 |
+
0.623, 0.822, 0.610, 0.620, 0.817, 0.592, 0.617, 0.811, 0.573, 0.614,
|
| 315 |
+
0.806, 0.554, 0.611, 0.800, 0.534, 0.608, 0.794, 0.515, 0.605, 0.788,
|
| 316 |
+
0.495, 0.602, 0.781, 0.474, 0.599, 0.775, 0.454, 0.597, 0.768, 0.433,
|
| 317 |
+
0.594, 0.761, 0.412, 0.592, 0.754, 0.391, 0.589, 0.747, 0.369, 0.587,
|
| 318 |
+
0.740, 0.347, 0.584, 0.733, 0.325, 0.582, 0.725, 0.302, 0.580, 0.718,
|
| 319 |
+
0.279, 0.577, 0.710, 0.255, 0.575, 0.703, 0.230, 0.573, 0.695, 0.204,
|
| 320 |
+
0.357, 0.685, 0.972, 0.372, 0.692, 0.966, 0.387, 0.700, 0.960, 0.401,
|
| 321 |
+
0.707, 0.954, 0.416, 0.714, 0.949, 0.429, 0.722, 0.943, 0.443, 0.729,
|
| 322 |
+
0.938, 0.456, 0.736, 0.933, 0.469, 0.743, 0.929, 0.482, 0.750, 0.924,
|
| 323 |
+
0.494, 0.757, 0.919, 0.507, 0.764, 0.915, 0.519, 0.771, 0.911, 0.530,
|
| 324 |
+
0.777, 0.907, 0.542, 0.784, 0.903, 0.553, 0.790, 0.899, 0.563, 0.796,
|
| 325 |
+
0.895, 0.574, 0.802, 0.891, 0.584, 0.808, 0.887, 0.593, 0.814, 0.883,
|
| 326 |
+
0.603, 0.820, 0.879, 0.611, 0.825, 0.875, 0.620, 0.830, 0.870, 0.627,
|
| 327 |
+
0.835, 0.866, 0.635, 0.839, 0.861, 0.641, 0.843, 0.856, 0.647, 0.847,
|
| 328 |
+
0.850, 0.652, 0.850, 0.844, 0.657, 0.853, 0.838, 0.660, 0.855, 0.831,
|
| 329 |
+
0.663, 0.857, 0.823, 0.666, 0.859, 0.814, 0.667, 0.859, 0.805, 0.668,
|
| 330 |
+
0.860, 0.795, 0.668, 0.860, 0.784, 0.667, 0.859, 0.773, 0.666, 0.858,
|
| 331 |
+
0.760, 0.665, 0.856, 0.747, 0.663, 0.853, 0.733, 0.661, 0.851, 0.718,
|
| 332 |
+
0.658, 0.847, 0.703, 0.655, 0.844, 0.687, 0.652, 0.840, 0.670, 0.649,
|
| 333 |
+
0.835, 0.652, 0.646, 0.830, 0.635, 0.642, 0.825, 0.616, 0.639, 0.820,
|
| 334 |
+
0.598, 0.636, 0.814, 0.579, 0.633, 0.808, 0.559, 0.629, 0.802, 0.539,
|
| 335 |
+
0.626, 0.796, 0.519, 0.623, 0.790, 0.499, 0.620, 0.783, 0.479, 0.617,
|
| 336 |
+
0.776, 0.458, 0.614, 0.769, 0.437, 0.611, 0.762, 0.416, 0.609, 0.755,
|
| 337 |
+
0.394, 0.606, 0.748, 0.372, 0.603, 0.740, 0.350, 0.601, 0.733, 0.328,
|
| 338 |
+
0.598, 0.726, 0.305, 0.596, 0.718, 0.282, 0.593, 0.710, 0.257, 0.591,
|
| 339 |
+
0.703, 0.232, 0.589, 0.695, 0.206, 0.381, 0.684, 0.974, 0.396, 0.692,
|
| 340 |
+
0.968, 0.410, 0.700, 0.962, 0.424, 0.707, 0.957, 0.438, 0.715, 0.951,
|
| 341 |
+
0.451, 0.722, 0.946, 0.464, 0.729, 0.941, 0.477, 0.737, 0.936, 0.490,
|
| 342 |
+
0.744, 0.932, 0.503, 0.751, 0.927, 0.515, 0.758, 0.923, 0.527, 0.765,
|
| 343 |
+
0.919, 0.539, 0.772, 0.915, 0.550, 0.779, 0.911, 0.562, 0.786, 0.907,
|
| 344 |
+
0.573, 0.792, 0.903, 0.584, 0.799, 0.900, 0.594, 0.805, 0.896, 0.604,
|
| 345 |
+
0.811, 0.892, 0.614, 0.817, 0.889, 0.623, 0.823, 0.885, 0.632, 0.829,
|
| 346 |
+
0.881, 0.641, 0.834, 0.877, 0.649, 0.839, 0.873, 0.656, 0.844, 0.868,
|
| 347 |
+
0.663, 0.848, 0.863, 0.669, 0.852, 0.858, 0.674, 0.855, 0.852, 0.679,
|
| 348 |
+
0.858, 0.846, 0.682, 0.861, 0.839, 0.685, 0.863, 0.832, 0.688, 0.864,
|
| 349 |
+
0.823, 0.689, 0.865, 0.814, 0.690, 0.865, 0.804, 0.690, 0.865, 0.794,
|
| 350 |
+
0.689, 0.864, 0.782, 0.688, 0.863, 0.769, 0.686, 0.861, 0.756, 0.684,
|
| 351 |
+
0.858, 0.742, 0.681, 0.855, 0.726, 0.678, 0.852, 0.711, 0.675, 0.848,
|
| 352 |
+
0.694, 0.672, 0.844, 0.677, 0.668, 0.839, 0.659, 0.665, 0.834, 0.641,
|
| 353 |
+
0.662, 0.829, 0.622, 0.658, 0.823, 0.603, 0.655, 0.817, 0.584, 0.651,
|
| 354 |
+
0.811, 0.564, 0.648, 0.805, 0.544, 0.644, 0.798, 0.524, 0.641, 0.791,
|
| 355 |
+
0.503, 0.638, 0.785, 0.483, 0.635, 0.778, 0.462, 0.631, 0.770, 0.440,
|
| 356 |
+
0.628, 0.763, 0.419, 0.625, 0.756, 0.397, 0.623, 0.748, 0.375, 0.620,
|
| 357 |
+
0.741, 0.353, 0.617, 0.733, 0.330, 0.614, 0.726, 0.307, 0.612, 0.718,
|
| 358 |
+
0.284, 0.609, 0.710, 0.260, 0.606, 0.702, 0.235, 0.604, 0.694, 0.208,
|
| 359 |
+
0.404, 0.684, 0.977, 0.418, 0.692, 0.971, 0.432, 0.699, 0.965, 0.445,
|
| 360 |
+
0.707, 0.959, 0.458, 0.715, 0.954, 0.472, 0.722, 0.949, 0.484, 0.730,
|
| 361 |
+
0.944, 0.497, 0.737, 0.939, 0.510, 0.745, 0.935, 0.522, 0.752, 0.931,
|
| 362 |
+
0.534, 0.759, 0.926, 0.546, 0.767, 0.922, 0.558, 0.774, 0.919, 0.569,
|
| 363 |
+
0.781, 0.915, 0.581, 0.788, 0.911, 0.592, 0.794, 0.908, 0.603, 0.801,
|
| 364 |
+
0.904, 0.613, 0.808, 0.901, 0.624, 0.814, 0.897, 0.633, 0.820, 0.894,
|
| 365 |
+
0.643, 0.826, 0.891, 0.652, 0.832, 0.887, 0.661, 0.838, 0.883, 0.669,
|
| 366 |
+
0.843, 0.879, 0.677, 0.848, 0.875, 0.684, 0.853, 0.871, 0.690, 0.857,
|
| 367 |
+
0.866, 0.695, 0.860, 0.860, 0.700, 0.864, 0.855, 0.704, 0.866, 0.848,
|
| 368 |
+
0.707, 0.869, 0.841, 0.709, 0.870, 0.833, 0.711, 0.871, 0.824, 0.711,
|
| 369 |
+
0.871, 0.814, 0.711, 0.871, 0.803, 0.710, 0.870, 0.791, 0.709, 0.868,
|
| 370 |
+
0.778, 0.707, 0.866, 0.765, 0.704, 0.864, 0.750, 0.701, 0.860, 0.735,
|
| 371 |
+
0.698, 0.857, 0.718, 0.695, 0.852, 0.702, 0.691, 0.848, 0.684, 0.688,
|
| 372 |
+
0.843, 0.666, 0.684, 0.837, 0.647, 0.680, 0.832, 0.628, 0.676, 0.826,
|
| 373 |
+
0.609, 0.673, 0.820, 0.589, 0.669, 0.813, 0.569, 0.665, 0.807, 0.549,
|
| 374 |
+
0.662, 0.800, 0.528, 0.658, 0.793, 0.507, 0.655, 0.786, 0.486, 0.651,
|
| 375 |
+
0.779, 0.465, 0.648, 0.771, 0.444, 0.645, 0.764, 0.422, 0.642, 0.756,
|
| 376 |
+
0.400, 0.639, 0.749, 0.378, 0.636, 0.741, 0.356, 0.633, 0.733, 0.333,
|
| 377 |
+
0.630, 0.726, 0.310, 0.627, 0.718, 0.286, 0.624, 0.710, 0.262, 0.621,
|
| 378 |
+
0.702, 0.237, 0.619, 0.694, 0.210, 0.425, 0.683, 0.979, 0.439, 0.691,
|
| 379 |
+
0.973, 0.452, 0.699, 0.967, 0.465, 0.707, 0.962, 0.478, 0.715, 0.956,
|
| 380 |
+
0.491, 0.722, 0.951, 0.503, 0.730, 0.947, 0.516, 0.738, 0.942, 0.528,
|
| 381 |
+
0.745, 0.938, 0.540, 0.753, 0.934, 0.552, 0.760, 0.930, 0.564, 0.768,
|
| 382 |
+
0.926, 0.576, 0.775, 0.922, 0.588, 0.782, 0.919, 0.599, 0.789, 0.915,
|
| 383 |
+
0.610, 0.797, 0.912, 0.621, 0.803, 0.909, 0.632, 0.810, 0.906, 0.642,
|
| 384 |
+
0.817, 0.902, 0.652, 0.823, 0.899, 0.662, 0.830, 0.896, 0.671, 0.836,
|
| 385 |
+
0.893, 0.680, 0.842, 0.890, 0.689, 0.847, 0.886, 0.697, 0.853, 0.882,
|
| 386 |
+
0.704, 0.857, 0.878, 0.710, 0.862, 0.874, 0.716, 0.866, 0.869, 0.721,
|
| 387 |
+
0.869, 0.863, 0.725, 0.872, 0.857, 0.729, 0.874, 0.850, 0.731, 0.876,
|
| 388 |
+
0.842, 0.732, 0.877, 0.833, 0.733, 0.877, 0.823, 0.732, 0.877, 0.812,
|
| 389 |
+
0.731, 0.876, 0.800, 0.729, 0.874, 0.787, 0.727, 0.872, 0.773, 0.724,
|
| 390 |
+
0.869, 0.759, 0.721, 0.865, 0.743, 0.718, 0.861, 0.726, 0.714, 0.857,
|
| 391 |
+
0.709, 0.710, 0.852, 0.691, 0.706, 0.846, 0.672, 0.702, 0.841, 0.653,
|
| 392 |
+
0.698, 0.835, 0.634, 0.694, 0.828, 0.614, 0.690, 0.822, 0.594, 0.686,
|
| 393 |
+
0.815, 0.574, 0.683, 0.808, 0.553, 0.679, 0.801, 0.532, 0.675, 0.794,
|
| 394 |
+
0.511, 0.672, 0.787, 0.490, 0.668, 0.779, 0.468, 0.665, 0.772, 0.446,
|
| 395 |
+
0.661, 0.764, 0.425, 0.658, 0.757, 0.403, 0.654, 0.749, 0.380, 0.651,
|
| 396 |
+
0.741, 0.358, 0.648, 0.733, 0.335, 0.645, 0.725, 0.312, 0.642, 0.717,
|
| 397 |
+
0.288, 0.639, 0.709, 0.264, 0.636, 0.701, 0.238, 0.633, 0.693, 0.212,
|
| 398 |
+
0.445, 0.682, 0.981, 0.458, 0.691, 0.975, 0.471, 0.699, 0.969, 0.484,
|
| 399 |
+
0.707, 0.964, 0.496, 0.715, 0.959, 0.509, 0.722, 0.954, 0.521, 0.730,
|
| 400 |
+
0.949, 0.534, 0.738, 0.945, 0.546, 0.746, 0.941, 0.558, 0.753, 0.937,
|
| 401 |
+
0.570, 0.761, 0.933, 0.582, 0.769, 0.929, 0.593, 0.776, 0.926, 0.605,
|
| 402 |
+
0.784, 0.922, 0.616, 0.791, 0.919, 0.628, 0.798, 0.916, 0.639, 0.806,
|
| 403 |
+
0.913, 0.649, 0.813, 0.910, 0.660, 0.820, 0.907, 0.670, 0.826, 0.904,
|
| 404 |
+
0.680, 0.833, 0.902, 0.690, 0.839, 0.899, 0.699, 0.846, 0.896, 0.708,
|
| 405 |
+
0.851, 0.893, 0.716, 0.857, 0.889, 0.724, 0.862, 0.885, 0.731, 0.867,
|
| 406 |
+
0.881, 0.737, 0.871, 0.877, 0.742, 0.875, 0.872, 0.746, 0.878, 0.866,
|
| 407 |
+
0.750, 0.880, 0.859, 0.752, 0.882, 0.851, 0.753, 0.883, 0.843, 0.754,
|
| 408 |
+
0.883, 0.833, 0.753, 0.883, 0.822, 0.752, 0.882, 0.810, 0.750, 0.880,
|
| 409 |
+
0.797, 0.747, 0.877, 0.782, 0.744, 0.874, 0.767, 0.740, 0.870, 0.751,
|
| 410 |
+
0.737, 0.866, 0.734, 0.733, 0.861, 0.716, 0.729, 0.855, 0.697, 0.724,
|
| 411 |
+
0.850, 0.678, 0.720, 0.844, 0.659, 0.716, 0.837, 0.639, 0.712, 0.831,
|
| 412 |
+
0.619, 0.708, 0.824, 0.598, 0.704, 0.817, 0.578, 0.699, 0.810, 0.557,
|
| 413 |
+
0.696, 0.803, 0.535, 0.692, 0.795, 0.514, 0.688, 0.788, 0.493, 0.684,
|
| 414 |
+
0.780, 0.471, 0.680, 0.772, 0.449, 0.677, 0.765, 0.427, 0.673, 0.757,
|
| 415 |
+
0.405, 0.670, 0.749, 0.382, 0.666, 0.741, 0.360, 0.663, 0.733, 0.337,
|
| 416 |
+
0.660, 0.725, 0.313, 0.657, 0.716, 0.289, 0.653, 0.708, 0.265, 0.650,
|
| 417 |
+
0.700, 0.240, 0.647, 0.692, 0.213, 0.464, 0.681, 0.982, 0.476, 0.690,
|
| 418 |
+
0.977, 0.489, 0.698, 0.971, 0.501, 0.706, 0.966, 0.514, 0.714, 0.961,
|
| 419 |
+
0.526, 0.722, 0.956, 0.538, 0.730, 0.952, 0.550, 0.738, 0.947, 0.562,
|
| 420 |
+
0.746, 0.943, 0.574, 0.754, 0.939, 0.586, 0.762, 0.936, 0.598, 0.769,
|
| 421 |
+
0.932, 0.610, 0.777, 0.929, 0.621, 0.785, 0.926, 0.633, 0.792, 0.923,
|
| 422 |
+
0.644, 0.800, 0.920, 0.655, 0.807, 0.917, 0.666, 0.815, 0.915, 0.677,
|
| 423 |
+
0.822, 0.912, 0.688, 0.829, 0.909, 0.698, 0.836, 0.907, 0.708, 0.843,
|
| 424 |
+
0.904, 0.717, 0.849, 0.902, 0.727, 0.855, 0.899, 0.735, 0.861, 0.896,
|
| 425 |
+
0.743, 0.867, 0.893, 0.750, 0.872, 0.889, 0.757, 0.877, 0.885, 0.762,
|
| 426 |
+
0.881, 0.880, 0.767, 0.884, 0.875, 0.770, 0.887, 0.868, 0.773, 0.888,
|
| 427 |
+
0.861, 0.774, 0.889, 0.852, 0.774, 0.890, 0.842, 0.774, 0.889, 0.831,
|
| 428 |
+
0.772, 0.888, 0.819, 0.770, 0.885, 0.806, 0.767, 0.883, 0.791, 0.763,
|
| 429 |
+
0.879, 0.775, 0.759, 0.875, 0.759, 0.755, 0.870, 0.741, 0.751, 0.865,
|
| 430 |
+
0.723, 0.747, 0.859, 0.704, 0.742, 0.853, 0.684, 0.738, 0.847, 0.664,
|
| 431 |
+
0.733, 0.840, 0.644, 0.729, 0.833, 0.623, 0.724, 0.826, 0.603, 0.720,
|
| 432 |
+
0.819, 0.581, 0.716, 0.811, 0.560, 0.712, 0.804, 0.539, 0.708, 0.796,
|
| 433 |
+
0.517, 0.704, 0.788, 0.495, 0.700, 0.780, 0.473, 0.696, 0.772, 0.451,
|
| 434 |
+
0.692, 0.764, 0.429, 0.688, 0.756, 0.407, 0.685, 0.748, 0.384, 0.681,
|
| 435 |
+
0.740, 0.361, 0.678, 0.732, 0.338, 0.674, 0.724, 0.315, 0.671, 0.715,
|
| 436 |
+
0.291, 0.667, 0.707, 0.266, 0.664, 0.699, 0.241, 0.661, 0.691, 0.214,
|
| 437 |
+
0.481, 0.680, 0.984, 0.494, 0.689, 0.978, 0.506, 0.697, 0.973, 0.518,
|
| 438 |
+
0.705, 0.968, 0.530, 0.713, 0.963, 0.542, 0.722, 0.958, 0.554, 0.730,
|
| 439 |
+
0.954, 0.566, 0.738, 0.950, 0.578, 0.746, 0.946, 0.590, 0.754, 0.942,
|
| 440 |
+
0.602, 0.762, 0.939, 0.614, 0.770, 0.935, 0.626, 0.778, 0.932, 0.637,
|
| 441 |
+
0.786, 0.929, 0.649, 0.794, 0.926, 0.660, 0.801, 0.924, 0.671, 0.809,
|
| 442 |
+
0.921, 0.683, 0.817, 0.919, 0.694, 0.824, 0.916, 0.704, 0.832, 0.914,
|
| 443 |
+
0.715, 0.839, 0.912, 0.725, 0.846, 0.910, 0.735, 0.853, 0.908, 0.744,
|
| 444 |
+
0.859, 0.905, 0.753, 0.866, 0.903, 0.762, 0.872, 0.900, 0.770, 0.877,
|
| 445 |
+
0.897, 0.776, 0.882, 0.893, 0.782, 0.886, 0.889, 0.787, 0.890, 0.884,
|
| 446 |
+
0.791, 0.893, 0.878, 0.794, 0.895, 0.871, 0.795, 0.896, 0.862, 0.795,
|
| 447 |
+
0.896, 0.852, 0.794, 0.895, 0.841, 0.792, 0.894, 0.829, 0.789, 0.891,
|
| 448 |
+
0.815, 0.786, 0.888, 0.800, 0.782, 0.884, 0.783, 0.778, 0.879, 0.766,
|
| 449 |
+
0.774, 0.874, 0.748, 0.769, 0.868, 0.729, 0.764, 0.862, 0.710, 0.760,
|
| 450 |
+
0.856, 0.690, 0.755, 0.849, 0.669, 0.750, 0.842, 0.649, 0.745, 0.835,
|
| 451 |
+
0.628, 0.741, 0.827, 0.606, 0.736, 0.820, 0.585, 0.732, 0.812, 0.563,
|
| 452 |
+
0.728, 0.804, 0.542, 0.723, 0.796, 0.520, 0.719, 0.788, 0.498, 0.715,
|
| 453 |
+
0.780, 0.475, 0.711, 0.772, 0.453, 0.707, 0.764, 0.431, 0.703, 0.756,
|
| 454 |
+
0.408, 0.699, 0.748, 0.386, 0.696, 0.739, 0.363, 0.692, 0.731, 0.339,
|
| 455 |
+
0.688, 0.723, 0.316, 0.685, 0.714, 0.292, 0.681, 0.706, 0.267, 0.678,
|
| 456 |
+
0.697, 0.242, 0.674, 0.689, 0.215, 0.498, 0.679, 0.986, 0.510, 0.687,
|
| 457 |
+
0.980, 0.522, 0.696, 0.975, 0.534, 0.704, 0.970, 0.546, 0.712, 0.965,
|
| 458 |
+
0.558, 0.721, 0.961, 0.570, 0.729, 0.956, 0.581, 0.737, 0.952, 0.593,
|
| 459 |
+
0.746, 0.948, 0.605, 0.754, 0.945, 0.617, 0.762, 0.941, 0.629, 0.770,
|
| 460 |
+
0.938, 0.640, 0.778, 0.935, 0.652, 0.786, 0.932, 0.664, 0.794, 0.930,
|
| 461 |
+
0.675, 0.802, 0.927, 0.687, 0.810, 0.925, 0.698, 0.818, 0.923, 0.709,
|
| 462 |
+
0.826, 0.921, 0.720, 0.834, 0.919, 0.731, 0.841, 0.917, 0.742, 0.849,
|
| 463 |
+
0.915, 0.752, 0.856, 0.913, 0.762, 0.863, 0.911, 0.771, 0.870, 0.909,
|
| 464 |
+
0.780, 0.876, 0.907, 0.788, 0.882, 0.904, 0.796, 0.887, 0.901, 0.802,
|
| 465 |
+
0.892, 0.897, 0.807, 0.896, 0.893, 0.811, 0.899, 0.887, 0.814, 0.902,
|
| 466 |
+
0.880, 0.815, 0.903, 0.872, 0.815, 0.903, 0.862, 0.814, 0.902, 0.851,
|
| 467 |
+
0.812, 0.900, 0.838, 0.809, 0.897, 0.824, 0.805, 0.893, 0.808, 0.801,
|
| 468 |
+
0.889, 0.791, 0.796, 0.884, 0.774, 0.791, 0.878, 0.755, 0.786, 0.872,
|
| 469 |
+
0.735, 0.781, 0.865, 0.715, 0.776, 0.858, 0.695, 0.771, 0.851, 0.674,
|
| 470 |
+
0.767, 0.844, 0.653, 0.762, 0.836, 0.631, 0.757, 0.829, 0.610, 0.752,
|
| 471 |
+
0.821, 0.588, 0.748, 0.813, 0.566, 0.743, 0.805, 0.544, 0.739, 0.796,
|
| 472 |
+
0.522, 0.734, 0.788, 0.500, 0.730, 0.780, 0.477, 0.726, 0.772, 0.455,
|
| 473 |
+
0.722, 0.763, 0.432, 0.718, 0.755, 0.410, 0.714, 0.746, 0.387, 0.710,
|
| 474 |
+
0.738, 0.364, 0.706, 0.730, 0.340, 0.702, 0.721, 0.317, 0.698, 0.713,
|
| 475 |
+
0.293, 0.694, 0.704, 0.268, 0.691, 0.696, 0.243, 0.687, 0.687, 0.216,
|
| 476 |
+
0.513, 0.677, 0.987, 0.525, 0.686, 0.982, 0.537, 0.694, 0.977, 0.549,
|
| 477 |
+
0.703, 0.972, 0.561, 0.711, 0.967, 0.572, 0.720, 0.962, 0.584, 0.728,
|
| 478 |
+
0.958, 0.596, 0.737, 0.954, 0.608, 0.745, 0.951, 0.619, 0.753, 0.947,
|
| 479 |
+
0.631, 0.762, 0.944, 0.643, 0.770, 0.941, 0.655, 0.778, 0.938, 0.666,
|
| 480 |
+
0.787, 0.935, 0.678, 0.795, 0.933, 0.689, 0.803, 0.930, 0.701, 0.811,
|
| 481 |
+
0.928, 0.713, 0.820, 0.926, 0.724, 0.828, 0.925, 0.735, 0.836, 0.923,
|
| 482 |
+
0.746, 0.844, 0.921, 0.757, 0.852, 0.920, 0.768, 0.859, 0.918, 0.778,
|
| 483 |
+
0.867, 0.917, 0.788, 0.874, 0.915, 0.797, 0.881, 0.913, 0.806, 0.887,
|
| 484 |
+
0.911, 0.814, 0.893, 0.909, 0.821, 0.898, 0.906, 0.827, 0.902, 0.902,
|
| 485 |
+
0.831, 0.906, 0.897, 0.834, 0.908, 0.890, 0.836, 0.910, 0.882, 0.836,
|
| 486 |
+
0.910, 0.873, 0.834, 0.909, 0.861, 0.832, 0.906, 0.848, 0.828, 0.903,
|
| 487 |
+
0.833, 0.824, 0.899, 0.817, 0.819, 0.894, 0.799, 0.814, 0.888, 0.781,
|
| 488 |
+
0.809, 0.882, 0.761, 0.804, 0.875, 0.741, 0.798, 0.868, 0.720, 0.793,
|
| 489 |
+
0.861, 0.699, 0.788, 0.853, 0.678, 0.783, 0.845, 0.656, 0.777, 0.837,
|
| 490 |
+
0.635, 0.772, 0.829, 0.613, 0.768, 0.821, 0.590, 0.763, 0.813, 0.568,
|
| 491 |
+
0.758, 0.804, 0.546, 0.753, 0.796, 0.524, 0.749, 0.788, 0.501, 0.744,
|
| 492 |
+
0.779, 0.479, 0.740, 0.771, 0.456, 0.736, 0.762, 0.433, 0.731, 0.754,
|
| 493 |
+
0.411, 0.727, 0.745, 0.388, 0.723, 0.736, 0.365, 0.719, 0.728, 0.341,
|
| 494 |
+
0.715, 0.719, 0.317, 0.711, 0.711, 0.293, 0.707, 0.702, 0.268, 0.704,
|
| 495 |
+
0.694, 0.243, 0.700, 0.685, 0.216, 0.528, 0.675, 0.989, 0.540, 0.684,
|
| 496 |
+
0.983, 0.551, 0.693, 0.978, 0.563, 0.701, 0.973, 0.575, 0.710, 0.969,
|
| 497 |
+
0.586, 0.718, 0.964, 0.598, 0.727, 0.960, 0.610, 0.736, 0.956, 0.621,
|
| 498 |
+
0.744, 0.953, 0.633, 0.753, 0.949, 0.645, 0.761, 0.946, 0.656, 0.770,
|
| 499 |
+
0.943, 0.668, 0.778, 0.940, 0.680, 0.787, 0.938, 0.691, 0.795, 0.936,
|
| 500 |
+
0.703, 0.804, 0.933, 0.715, 0.812, 0.932, 0.726, 0.821, 0.930, 0.738,
|
| 501 |
+
0.829, 0.928, 0.749, 0.837, 0.927, 0.761, 0.846, 0.926, 0.772, 0.854,
|
| 502 |
+
0.924, 0.783, 0.862, 0.923, 0.794, 0.870, 0.922, 0.804, 0.877, 0.921,
|
| 503 |
+
0.814, 0.885, 0.920, 0.824, 0.892, 0.918, 0.832, 0.898, 0.917, 0.840,
|
| 504 |
+
0.904, 0.914, 0.846, 0.909, 0.911, 0.851, 0.913, 0.906, 0.855, 0.915,
|
| 505 |
+
0.901, 0.856, 0.917, 0.893, 0.856, 0.917, 0.883, 0.854, 0.915, 0.871,
|
| 506 |
+
0.851, 0.913, 0.858, 0.847, 0.909, 0.842, 0.842, 0.904, 0.825, 0.837,
|
| 507 |
+
0.898, 0.806, 0.831, 0.892, 0.787, 0.826, 0.885, 0.767, 0.820, 0.878,
|
| 508 |
+
0.746, 0.814, 0.870, 0.725, 0.809, 0.862, 0.703, 0.803, 0.854, 0.681,
|
| 509 |
+
0.798, 0.846, 0.659, 0.793, 0.838, 0.637, 0.788, 0.829, 0.615, 0.782,
|
| 510 |
+
0.821, 0.592, 0.777, 0.812, 0.570, 0.773, 0.804, 0.548, 0.768, 0.795,
|
| 511 |
+
0.525, 0.763, 0.787, 0.502, 0.758, 0.778, 0.480, 0.754, 0.769, 0.457,
|
| 512 |
+
0.749, 0.761, 0.434, 0.745, 0.752, 0.411, 0.741, 0.743, 0.388, 0.737,
|
| 513 |
+
0.735, 0.365, 0.732, 0.726, 0.342, 0.728, 0.717, 0.318, 0.724, 0.709,
|
| 514 |
+
0.293, 0.720, 0.700, 0.269, 0.716, 0.691, 0.243, 0.712, 0.683, 0.216,
|
| 515 |
+
0.542, 0.673, 0.990, 0.554, 0.682, 0.985, 0.565, 0.691, 0.980, 0.577,
|
| 516 |
+
0.700, 0.975, 0.588, 0.708, 0.970, 0.600, 0.717, 0.966, 0.611, 0.726,
|
| 517 |
+
0.962, 0.623, 0.734, 0.958, 0.634, 0.743, 0.955, 0.646, 0.752, 0.951,
|
| 518 |
+
0.657, 0.760, 0.948, 0.669, 0.769, 0.945, 0.681, 0.778, 0.943, 0.692,
|
| 519 |
+
0.786, 0.940, 0.704, 0.795, 0.938, 0.716, 0.804, 0.936, 0.728, 0.812,
|
| 520 |
+
0.934, 0.739, 0.821, 0.933, 0.751, 0.830, 0.932, 0.763, 0.838, 0.930,
|
| 521 |
+
0.774, 0.847, 0.929, 0.786, 0.856, 0.929, 0.797, 0.864, 0.928, 0.809,
|
| 522 |
+
0.873, 0.927, 0.819, 0.881, 0.927, 0.830, 0.889, 0.926, 0.840, 0.896,
|
| 523 |
+
0.925, 0.850, 0.903, 0.924, 0.858, 0.910, 0.922, 0.865, 0.915, 0.920,
|
| 524 |
+
0.871, 0.920, 0.916, 0.875, 0.923, 0.911, 0.876, 0.924, 0.903, 0.876,
|
| 525 |
+
0.924, 0.894, 0.873, 0.922, 0.882, 0.870, 0.919, 0.867, 0.865, 0.914,
|
| 526 |
+
0.851, 0.860, 0.909, 0.832, 0.854, 0.902, 0.813, 0.848, 0.895, 0.793,
|
| 527 |
+
0.842, 0.888, 0.772, 0.836, 0.880, 0.750, 0.830, 0.872, 0.729, 0.824,
|
| 528 |
+
0.864, 0.707, 0.819, 0.855, 0.684, 0.813, 0.847, 0.662, 0.808, 0.838,
|
| 529 |
+
0.639, 0.802, 0.829, 0.617, 0.797, 0.820, 0.594, 0.792, 0.812, 0.571,
|
| 530 |
+
0.787, 0.803, 0.549, 0.782, 0.794, 0.526, 0.777, 0.785, 0.503, 0.772,
|
| 531 |
+
0.776, 0.480, 0.767, 0.768, 0.458, 0.763, 0.759, 0.435, 0.758, 0.750,
|
| 532 |
+
0.412, 0.754, 0.741, 0.388, 0.749, 0.732, 0.365, 0.745, 0.724, 0.342,
|
| 533 |
+
0.741, 0.715, 0.318, 0.737, 0.706, 0.293, 0.732, 0.697, 0.269, 0.728,
|
| 534 |
+
0.689, 0.243, 0.724, 0.680, 0.216, 0.556, 0.671, 0.992, 0.567, 0.680,
|
| 535 |
+
0.986, 0.578, 0.689, 0.981, 0.590, 0.697, 0.976, 0.601, 0.706, 0.972,
|
| 536 |
+
0.612, 0.715, 0.968, 0.624, 0.724, 0.964, 0.635, 0.733, 0.960, 0.646,
|
| 537 |
+
0.741, 0.956, 0.658, 0.750, 0.953, 0.670, 0.759, 0.950, 0.681, 0.768,
|
| 538 |
+
0.947, 0.693, 0.777, 0.945, 0.704, 0.786, 0.943, 0.716, 0.794, 0.941,
|
| 539 |
+
0.728, 0.803, 0.939, 0.740, 0.812, 0.937, 0.752, 0.821, 0.936, 0.763,
|
| 540 |
+
0.830, 0.935, 0.775, 0.839, 0.934, 0.787, 0.848, 0.933, 0.799, 0.857,
|
| 541 |
+
0.932, 0.811, 0.866, 0.932, 0.822, 0.875, 0.932, 0.834, 0.883, 0.932,
|
| 542 |
+
0.845, 0.892, 0.931, 0.856, 0.900, 0.931, 0.866, 0.908, 0.931, 0.876,
|
| 543 |
+
0.915, 0.930, 0.884, 0.922, 0.929, 0.890, 0.927, 0.926, 0.895, 0.930,
|
| 544 |
+
0.921, 0.896, 0.932, 0.914, 0.896, 0.932, 0.905, 0.893, 0.929, 0.892,
|
| 545 |
+
0.888, 0.925, 0.876, 0.883, 0.920, 0.859, 0.877, 0.913, 0.840, 0.871,
|
| 546 |
+
0.906, 0.819, 0.864, 0.898, 0.798, 0.858, 0.890, 0.776, 0.852, 0.882,
|
| 547 |
+
0.754, 0.845, 0.873, 0.732, 0.839, 0.864, 0.709, 0.833, 0.855, 0.686,
|
| 548 |
+
0.828, 0.846, 0.664, 0.822, 0.837, 0.641, 0.816, 0.828, 0.618, 0.811,
|
| 549 |
+
0.819, 0.595, 0.806, 0.810, 0.572, 0.800, 0.801, 0.549, 0.795, 0.792,
|
| 550 |
+
0.526, 0.790, 0.783, 0.504, 0.785, 0.774, 0.481, 0.781, 0.765, 0.458,
|
| 551 |
+
0.776, 0.756, 0.435, 0.771, 0.748, 0.412, 0.766, 0.739, 0.388, 0.762,
|
| 552 |
+
0.730, 0.365, 0.757, 0.721, 0.341, 0.753, 0.712, 0.318, 0.749, 0.703,
|
| 553 |
+
0.293, 0.744, 0.695, 0.268, 0.740, 0.686, 0.243, 0.736, 0.677, 0.216,
|
| 554 |
+
0.569, 0.668, 0.993, 0.580, 0.677, 0.987, 0.591, 0.686, 0.982, 0.602,
|
| 555 |
+
0.695, 0.978, 0.613, 0.704, 0.973, 0.624, 0.713, 0.969, 0.635, 0.722,
|
| 556 |
+
0.965, 0.647, 0.731, 0.961, 0.658, 0.740, 0.958, 0.670, 0.748, 0.955,
|
| 557 |
+
0.681, 0.757, 0.952, 0.693, 0.766, 0.949, 0.704, 0.775, 0.947, 0.716,
|
| 558 |
+
0.784, 0.945, 0.728, 0.793, 0.943, 0.739, 0.802, 0.941, 0.751, 0.812,
|
| 559 |
+
0.939, 0.763, 0.821, 0.938, 0.775, 0.830, 0.937, 0.787, 0.839, 0.936,
|
| 560 |
+
0.799, 0.848, 0.936, 0.811, 0.858, 0.936, 0.823, 0.867, 0.935, 0.835,
|
| 561 |
+
0.876, 0.936, 0.847, 0.886, 0.936, 0.859, 0.895, 0.936, 0.870, 0.904,
|
| 562 |
+
0.937, 0.882, 0.912, 0.937, 0.892, 0.920, 0.937, 0.901, 0.928, 0.937,
|
| 563 |
+
0.909, 0.934, 0.936, 0.914, 0.938, 0.932, 0.917, 0.940, 0.926, 0.915,
|
| 564 |
+
0.940, 0.916, 0.912, 0.936, 0.902, 0.906, 0.931, 0.885, 0.900, 0.925,
|
| 565 |
+
0.866, 0.893, 0.917, 0.846, 0.887, 0.909, 0.824, 0.880, 0.900, 0.802,
|
| 566 |
+
0.873, 0.891, 0.780, 0.867, 0.882, 0.757, 0.860, 0.873, 0.734, 0.854,
|
| 567 |
+
0.864, 0.711, 0.848, 0.855, 0.688, 0.842, 0.845, 0.665, 0.836, 0.836,
|
| 568 |
+
0.642, 0.830, 0.827, 0.619, 0.824, 0.818, 0.596, 0.819, 0.808, 0.573,
|
| 569 |
+
0.814, 0.799, 0.549, 0.808, 0.790, 0.527, 0.803, 0.781, 0.504, 0.798,
|
| 570 |
+
0.772, 0.481, 0.793, 0.763, 0.458, 0.788, 0.754, 0.434, 0.783, 0.745,
|
| 571 |
+
0.411, 0.779, 0.736, 0.388, 0.774, 0.727, 0.365, 0.769, 0.718, 0.341,
|
| 572 |
+
0.765, 0.709, 0.317, 0.760, 0.700, 0.293, 0.756, 0.691, 0.268, 0.751,
|
| 573 |
+
0.683, 0.242, 0.747, 0.674, 0.215, 0.581, 0.665, 0.994, 0.592, 0.674,
|
| 574 |
+
0.989, 0.603, 0.683, 0.984, 0.614, 0.692, 0.979, 0.625, 0.701, 0.974,
|
| 575 |
+
0.636, 0.710, 0.970, 0.647, 0.719, 0.966, 0.658, 0.728, 0.963, 0.669,
|
| 576 |
+
0.737, 0.959, 0.681, 0.746, 0.956, 0.692, 0.755, 0.953, 0.703, 0.765,
|
| 577 |
+
0.951, 0.715, 0.774, 0.948, 0.727, 0.783, 0.946, 0.738, 0.792, 0.944,
|
| 578 |
+
0.750, 0.801, 0.943, 0.762, 0.810, 0.941, 0.774, 0.820, 0.940, 0.786,
|
| 579 |
+
0.829, 0.939, 0.798, 0.839, 0.939, 0.810, 0.848, 0.938, 0.822, 0.858,
|
| 580 |
+
0.938, 0.834, 0.867, 0.939, 0.847, 0.877, 0.939, 0.859, 0.887, 0.940,
|
| 581 |
+
0.871, 0.897, 0.940, 0.883, 0.906, 0.942, 0.896, 0.916, 0.943, 0.907,
|
| 582 |
+
0.925, 0.944, 0.918, 0.933, 0.945, 0.927, 0.941, 0.945, 0.934, 0.946,
|
| 583 |
+
0.943, 0.937, 0.949, 0.937, 0.935, 0.948, 0.927, 0.930, 0.943, 0.912,
|
| 584 |
+
0.924, 0.937, 0.893, 0.916, 0.929, 0.872, 0.909, 0.920, 0.850, 0.902,
|
| 585 |
+
0.911, 0.828, 0.895, 0.901, 0.805, 0.888, 0.892, 0.782, 0.881, 0.882,
|
| 586 |
+
0.759, 0.874, 0.872, 0.735, 0.868, 0.863, 0.712, 0.861, 0.853, 0.689,
|
| 587 |
+
0.855, 0.844, 0.665, 0.849, 0.834, 0.642, 0.843, 0.825, 0.619, 0.838,
|
| 588 |
+
0.815, 0.596, 0.832, 0.806, 0.572, 0.826, 0.797, 0.549, 0.821, 0.787,
|
| 589 |
+
0.526, 0.816, 0.778, 0.503, 0.811, 0.769, 0.480, 0.805, 0.760, 0.457,
|
| 590 |
+
0.800, 0.751, 0.434, 0.795, 0.742, 0.411, 0.791, 0.733, 0.387, 0.786,
|
| 591 |
+
0.724, 0.364, 0.781, 0.715, 0.340, 0.776, 0.706, 0.316, 0.772, 0.697,
|
| 592 |
+
0.292, 0.767, 0.688, 0.267, 0.762, 0.679, 0.241, 0.758, 0.670, 0.215,
|
| 593 |
+
0.593, 0.662, 0.995, 0.603, 0.671, 0.990, 0.614, 0.680, 0.985, 0.625,
|
| 594 |
+
0.689, 0.980, 0.636, 0.699, 0.975, 0.647, 0.708, 0.971, 0.658, 0.717,
|
| 595 |
+
0.967, 0.669, 0.726, 0.964, 0.680, 0.735, 0.960, 0.691, 0.744, 0.957,
|
| 596 |
+
0.702, 0.753, 0.955, 0.714, 0.762, 0.952, 0.725, 0.771, 0.950, 0.737,
|
| 597 |
+
0.781, 0.948, 0.748, 0.790, 0.946, 0.760, 0.799, 0.944, 0.772, 0.809,
|
| 598 |
+
0.943, 0.784, 0.818, 0.942, 0.796, 0.828, 0.941, 0.808, 0.837, 0.941,
|
| 599 |
+
0.820, 0.847, 0.940, 0.832, 0.857, 0.941, 0.844, 0.867, 0.941, 0.857,
|
| 600 |
+
0.877, 0.942, 0.869, 0.887, 0.943, 0.882, 0.897, 0.944, 0.895, 0.908,
|
| 601 |
+
0.945, 0.908, 0.918, 0.947, 0.920, 0.928, 0.949, 0.933, 0.938, 0.951,
|
| 602 |
+
0.944, 0.947, 0.953, 0.953, 0.955, 0.954, 0.957, 0.958, 0.950, 0.954,
|
| 603 |
+
0.956, 0.938, 0.948, 0.949, 0.920, 0.940, 0.941, 0.899, 0.932, 0.931,
|
| 604 |
+
0.877, 0.924, 0.921, 0.854, 0.916, 0.911, 0.830, 0.909, 0.901, 0.807,
|
| 605 |
+
0.901, 0.891, 0.783, 0.894, 0.881, 0.759, 0.887, 0.871, 0.736, 0.881,
|
| 606 |
+
0.861, 0.712, 0.874, 0.851, 0.688, 0.868, 0.841, 0.665, 0.862, 0.832,
|
| 607 |
+
0.642, 0.856, 0.822, 0.618, 0.850, 0.812, 0.595, 0.844, 0.803, 0.572,
|
| 608 |
+
0.839, 0.793, 0.549, 0.833, 0.784, 0.525, 0.828, 0.775, 0.502, 0.822,
|
| 609 |
+
0.766, 0.479, 0.817, 0.756, 0.456, 0.812, 0.747, 0.433, 0.807, 0.738,
|
| 610 |
+
0.410, 0.802, 0.729, 0.387, 0.797, 0.720, 0.363, 0.792, 0.711, 0.339,
|
| 611 |
+
0.787, 0.702, 0.315, 0.782, 0.693, 0.291, 0.778, 0.684, 0.266, 0.773,
|
| 612 |
+
0.675, 0.240, 0.768, 0.666, 0.214, 0.604, 0.659, 0.996, 0.614, 0.668,
|
| 613 |
+
0.990, 0.625, 0.677, 0.985, 0.636, 0.686, 0.981, 0.646, 0.695, 0.976,
|
| 614 |
+
0.657, 0.704, 0.972, 0.668, 0.714, 0.968, 0.679, 0.723, 0.965, 0.690,
|
| 615 |
+
0.732, 0.961, 0.701, 0.741, 0.958, 0.712, 0.750, 0.956, 0.723, 0.759,
|
| 616 |
+
0.953, 0.735, 0.769, 0.951, 0.746, 0.778, 0.949, 0.758, 0.787, 0.947,
|
| 617 |
+
0.769, 0.797, 0.945, 0.781, 0.806, 0.944, 0.793, 0.816, 0.943, 0.805,
|
| 618 |
+
0.826, 0.943, 0.817, 0.836, 0.942, 0.829, 0.845, 0.942, 0.841, 0.855,
|
| 619 |
+
0.942, 0.853, 0.866, 0.943, 0.866, 0.876, 0.943, 0.879, 0.886, 0.945,
|
| 620 |
+
0.892, 0.897, 0.946, 0.905, 0.907, 0.948, 0.918, 0.918, 0.950, 0.931,
|
| 621 |
+
0.930, 0.953, 0.945, 0.941, 0.956, 0.958, 0.952, 0.960, 0.971, 0.963,
|
| 622 |
+
0.963, 0.978, 0.968, 0.963, 0.972, 0.963, 0.948, 0.963, 0.954, 0.926,
|
| 623 |
+
0.954, 0.943, 0.903, 0.945, 0.931, 0.879, 0.937, 0.921, 0.855, 0.929,
|
| 624 |
+
0.910, 0.831, 0.921, 0.899, 0.807, 0.914, 0.889, 0.783, 0.907, 0.878,
|
| 625 |
+
0.759, 0.900, 0.868, 0.735, 0.893, 0.858, 0.711, 0.887, 0.848, 0.688,
|
| 626 |
+
0.880, 0.838, 0.664, 0.874, 0.828, 0.641, 0.868, 0.818, 0.617, 0.862,
|
| 627 |
+
0.809, 0.594, 0.856, 0.799, 0.571, 0.850, 0.790, 0.547, 0.845, 0.780,
|
| 628 |
+
0.524, 0.839, 0.771, 0.501, 0.834, 0.762, 0.478, 0.828, 0.752, 0.455,
|
| 629 |
+
0.823, 0.743, 0.432, 0.818, 0.734, 0.409, 0.813, 0.725, 0.385, 0.808,
|
| 630 |
+
0.716, 0.362, 0.803, 0.707, 0.338, 0.798, 0.698, 0.314, 0.793, 0.689,
|
| 631 |
+
0.290, 0.788, 0.680, 0.265, 0.783, 0.671, 0.239, 0.778, 0.662, 0.213,
|
| 632 |
+
0.615, 0.655, 0.996, 0.625, 0.664, 0.991, 0.635, 0.673, 0.986, 0.646,
|
| 633 |
+
0.683, 0.982, 0.656, 0.692, 0.977, 0.667, 0.701, 0.973, 0.678, 0.710,
|
| 634 |
+
0.969, 0.688, 0.719, 0.966, 0.699, 0.729, 0.962, 0.710, 0.738, 0.959,
|
| 635 |
+
0.721, 0.747, 0.956, 0.732, 0.756, 0.954, 0.744, 0.766, 0.952, 0.755,
|
| 636 |
+
0.775, 0.950, 0.766, 0.784, 0.948, 0.778, 0.794, 0.946, 0.789, 0.804,
|
| 637 |
+
0.945, 0.801, 0.813, 0.944, 0.813, 0.823, 0.943, 0.825, 0.833, 0.943,
|
| 638 |
+
0.837, 0.843, 0.943, 0.849, 0.853, 0.943, 0.861, 0.863, 0.944, 0.874,
|
| 639 |
+
0.873, 0.944, 0.886, 0.884, 0.946, 0.899, 0.895, 0.947, 0.912, 0.906,
|
| 640 |
+
0.949, 0.926, 0.917, 0.952, 0.939, 0.928, 0.955, 0.953, 0.940, 0.958,
|
| 641 |
+
0.967, 0.953, 0.963, 0.982, 0.966, 0.969, 0.994, 0.976, 0.972, 0.986,
|
| 642 |
+
0.966, 0.952, 0.976, 0.953, 0.928, 0.966, 0.941, 0.903, 0.957, 0.929,
|
| 643 |
+
0.878, 0.949, 0.918, 0.854, 0.941, 0.906, 0.830, 0.933, 0.896, 0.806,
|
| 644 |
+
0.926, 0.885, 0.782, 0.918, 0.874, 0.758, 0.911, 0.864, 0.734, 0.905,
|
| 645 |
+
0.854, 0.710, 0.898, 0.844, 0.686, 0.892, 0.834, 0.663, 0.885, 0.824,
|
| 646 |
+
0.639, 0.879, 0.814, 0.616, 0.873, 0.804, 0.592, 0.867, 0.795, 0.569,
|
| 647 |
+
0.861, 0.785, 0.546, 0.856, 0.776, 0.523, 0.850, 0.766, 0.500, 0.845,
|
| 648 |
+
0.757, 0.477, 0.839, 0.748, 0.454, 0.834, 0.739, 0.430, 0.829, 0.729,
|
| 649 |
+
0.407, 0.823, 0.720, 0.384, 0.818, 0.711, 0.361, 0.813, 0.702, 0.337,
|
| 650 |
+
0.808, 0.693, 0.313, 0.803, 0.684, 0.289, 0.798, 0.675, 0.264, 0.793,
|
| 651 |
+
0.666, 0.238, 0.788, 0.657, 0.211, 0.625, 0.651, 0.997, 0.635, 0.660,
|
| 652 |
+
0.992, 0.645, 0.669, 0.987, 0.656, 0.679, 0.982, 0.666, 0.688, 0.978,
|
| 653 |
+
0.676, 0.697, 0.974, 0.687, 0.706, 0.970, 0.698, 0.716, 0.966, 0.708,
|
| 654 |
+
0.725, 0.963, 0.719, 0.734, 0.960, 0.730, 0.743, 0.957, 0.741, 0.753,
|
| 655 |
+
0.954, 0.752, 0.762, 0.952, 0.763, 0.771, 0.950, 0.774, 0.781, 0.948,
|
| 656 |
+
0.786, 0.790, 0.947, 0.797, 0.800, 0.945, 0.809, 0.810, 0.945, 0.820,
|
| 657 |
+
0.819, 0.944, 0.832, 0.829, 0.943, 0.844, 0.839, 0.943, 0.856, 0.849,
|
| 658 |
+
0.943, 0.868, 0.860, 0.944, 0.880, 0.870, 0.945, 0.893, 0.880, 0.946,
|
| 659 |
+
0.905, 0.891, 0.947, 0.918, 0.902, 0.949, 0.931, 0.913, 0.951, 0.944,
|
| 660 |
+
0.924, 0.954, 0.957, 0.936, 0.957, 0.971, 0.947, 0.961, 0.983, 0.958,
|
| 661 |
+
0.964, 0.991, 0.963, 0.962, 0.990, 0.957, 0.946, 0.983, 0.946, 0.924,
|
| 662 |
+
0.975, 0.935, 0.900, 0.967, 0.923, 0.876, 0.959, 0.912, 0.851, 0.951,
|
| 663 |
+
0.901, 0.827, 0.943, 0.890, 0.803, 0.936, 0.880, 0.779, 0.929, 0.869,
|
| 664 |
+
0.755, 0.922, 0.859, 0.732, 0.915, 0.849, 0.708, 0.909, 0.839, 0.684,
|
| 665 |
+
0.902, 0.829, 0.661, 0.896, 0.819, 0.637, 0.890, 0.809, 0.614, 0.884,
|
| 666 |
+
0.800, 0.591, 0.878, 0.790, 0.567, 0.872, 0.780, 0.544, 0.866, 0.771,
|
| 667 |
+
0.521, 0.861, 0.762, 0.498, 0.855, 0.752, 0.475, 0.850, 0.743, 0.452,
|
| 668 |
+
0.844, 0.734, 0.429, 0.839, 0.725, 0.406, 0.834, 0.715, 0.382, 0.828,
|
| 669 |
+
0.706, 0.359, 0.823, 0.697, 0.335, 0.818, 0.688, 0.311, 0.813, 0.679,
|
| 670 |
+
0.287, 0.808, 0.670, 0.262, 0.803, 0.662, 0.236, 0.798, 0.653, 0.210,
|
| 671 |
+
0.635, 0.646, 0.998, 0.645, 0.656, 0.992, 0.655, 0.665, 0.987, 0.665,
|
| 672 |
+
0.674, 0.983, 0.675, 0.684, 0.978, 0.685, 0.693, 0.974, 0.696, 0.702,
|
| 673 |
+
0.970, 0.706, 0.711, 0.966, 0.717, 0.721, 0.963, 0.727, 0.730, 0.960,
|
| 674 |
+
0.738, 0.739, 0.957, 0.749, 0.748, 0.955, 0.760, 0.758, 0.952, 0.771,
|
| 675 |
+
0.767, 0.950, 0.782, 0.777, 0.948, 0.793, 0.786, 0.947, 0.804, 0.796,
|
| 676 |
+
0.946, 0.816, 0.805, 0.945, 0.827, 0.815, 0.944, 0.839, 0.825, 0.943,
|
| 677 |
+
0.850, 0.835, 0.943, 0.862, 0.845, 0.943, 0.874, 0.855, 0.943, 0.886,
|
| 678 |
+
0.865, 0.944, 0.898, 0.875, 0.945, 0.910, 0.886, 0.946, 0.923, 0.896,
|
| 679 |
+
0.948, 0.935, 0.907, 0.949, 0.947, 0.917, 0.951, 0.959, 0.927, 0.953,
|
| 680 |
+
0.970, 0.937, 0.955, 0.980, 0.944, 0.955, 0.987, 0.946, 0.949, 0.989,
|
| 681 |
+
0.942, 0.936, 0.985, 0.935, 0.916, 0.980, 0.925, 0.894, 0.973, 0.915,
|
| 682 |
+
0.871, 0.966, 0.904, 0.847, 0.959, 0.894, 0.824, 0.952, 0.883, 0.800,
|
| 683 |
+
0.945, 0.873, 0.776, 0.938, 0.863, 0.752, 0.932, 0.853, 0.729, 0.925,
|
| 684 |
+
0.843, 0.705, 0.919, 0.833, 0.682, 0.912, 0.823, 0.658, 0.906, 0.813,
|
| 685 |
+
0.635, 0.900, 0.803, 0.611, 0.894, 0.794, 0.588, 0.888, 0.784, 0.565,
|
| 686 |
+
0.882, 0.775, 0.542, 0.876, 0.765, 0.519, 0.871, 0.756, 0.496, 0.865,
|
| 687 |
+
0.747, 0.473, 0.859, 0.738, 0.450, 0.854, 0.728, 0.427, 0.848, 0.719,
|
| 688 |
+
0.404, 0.843, 0.710, 0.380, 0.838, 0.701, 0.357, 0.833, 0.692, 0.333,
|
| 689 |
+
0.827, 0.683, 0.310, 0.822, 0.674, 0.285, 0.817, 0.665, 0.260, 0.812,
|
| 690 |
+
0.656, 0.235, 0.807, 0.648, 0.208, 0.644, 0.642, 0.998, 0.654, 0.651,
|
| 691 |
+
0.993, 0.664, 0.660, 0.988, 0.674, 0.670, 0.983, 0.684, 0.679, 0.978,
|
| 692 |
+
0.694, 0.688, 0.974, 0.704, 0.697, 0.970, 0.715, 0.707, 0.967, 0.725,
|
| 693 |
+
0.716, 0.963, 0.735, 0.725, 0.960, 0.746, 0.735, 0.957, 0.757, 0.744,
|
| 694 |
+
0.955, 0.767, 0.753, 0.952, 0.778, 0.763, 0.950, 0.789, 0.772, 0.948,
|
| 695 |
+
0.800, 0.781, 0.947, 0.811, 0.791, 0.945, 0.822, 0.801, 0.944, 0.833,
|
| 696 |
+
0.810, 0.943, 0.845, 0.820, 0.943, 0.856, 0.830, 0.942, 0.868, 0.839,
|
| 697 |
+
0.942, 0.879, 0.849, 0.942, 0.891, 0.859, 0.943, 0.902, 0.869, 0.943,
|
| 698 |
+
0.914, 0.879, 0.944, 0.926, 0.889, 0.945, 0.937, 0.899, 0.946, 0.949,
|
| 699 |
+
0.908, 0.947, 0.959, 0.917, 0.948, 0.969, 0.924, 0.947, 0.978, 0.929,
|
| 700 |
+
0.944, 0.984, 0.930, 0.937, 0.986, 0.927, 0.924, 0.986, 0.921, 0.907,
|
| 701 |
+
0.982, 0.913, 0.887, 0.978, 0.904, 0.865, 0.972, 0.895, 0.842, 0.966,
|
| 702 |
+
0.885, 0.819, 0.959, 0.875, 0.795, 0.953, 0.865, 0.772, 0.946, 0.855,
|
| 703 |
+
0.749, 0.940, 0.846, 0.725, 0.934, 0.836, 0.702, 0.927, 0.826, 0.678,
|
| 704 |
+
0.921, 0.816, 0.655, 0.915, 0.807, 0.632, 0.909, 0.797, 0.609, 0.903,
|
| 705 |
+
0.788, 0.586, 0.897, 0.778, 0.562, 0.891, 0.769, 0.539, 0.886, 0.759,
|
| 706 |
+
0.516, 0.880, 0.750, 0.493, 0.874, 0.741, 0.471, 0.869, 0.732, 0.448,
|
| 707 |
+
0.863, 0.723, 0.425, 0.858, 0.713, 0.402, 0.852, 0.704, 0.378, 0.847,
|
| 708 |
+
0.695, 0.355, 0.842, 0.686, 0.331, 0.836, 0.677, 0.308, 0.831, 0.669,
|
| 709 |
+
0.283, 0.826, 0.660, 0.258, 0.821, 0.651, 0.233, 0.815, 0.642, 0.206,
|
| 710 |
+
0.653, 0.636, 0.998, 0.663, 0.646, 0.993, 0.673, 0.655, 0.988, 0.682,
|
| 711 |
+
0.665, 0.983, 0.692, 0.674, 0.979, 0.702, 0.683, 0.974, 0.712, 0.692,
|
| 712 |
+
0.970, 0.722, 0.702, 0.967, 0.733, 0.711, 0.963, 0.743, 0.720, 0.960,
|
| 713 |
+
0.753, 0.730, 0.957, 0.764, 0.739, 0.954, 0.774, 0.748, 0.952, 0.785,
|
| 714 |
+
0.757, 0.950, 0.796, 0.767, 0.948, 0.806, 0.776, 0.946, 0.817, 0.786,
|
| 715 |
+
0.945, 0.828, 0.795, 0.943, 0.839, 0.804, 0.942, 0.850, 0.814, 0.941,
|
| 716 |
+
0.861, 0.824, 0.941, 0.872, 0.833, 0.940, 0.884, 0.843, 0.940, 0.895,
|
| 717 |
+
0.852, 0.940, 0.906, 0.862, 0.940, 0.917, 0.871, 0.941, 0.928, 0.880,
|
| 718 |
+
0.941, 0.939, 0.889, 0.941, 0.949, 0.897, 0.941, 0.959, 0.904, 0.940,
|
| 719 |
+
0.968, 0.910, 0.938, 0.975, 0.914, 0.933, 0.981, 0.914, 0.925, 0.984,
|
| 720 |
+
0.912, 0.913, 0.985, 0.907, 0.897, 0.983, 0.900, 0.878, 0.980, 0.893,
|
| 721 |
+
0.857, 0.976, 0.884, 0.836, 0.971, 0.875, 0.813, 0.965, 0.866, 0.790,
|
| 722 |
+
0.959, 0.856, 0.767, 0.954, 0.847, 0.744, 0.947, 0.837, 0.721, 0.941,
|
| 723 |
+
0.828, 0.698, 0.935, 0.818, 0.675, 0.929, 0.809, 0.652, 0.923, 0.800,
|
| 724 |
+
0.629, 0.917, 0.790, 0.605, 0.912, 0.781, 0.582, 0.906, 0.771, 0.560,
|
| 725 |
+
0.900, 0.762, 0.537, 0.894, 0.753, 0.514, 0.889, 0.744, 0.491, 0.883,
|
| 726 |
+
0.735, 0.468, 0.877, 0.725, 0.445, 0.872, 0.716, 0.422, 0.866, 0.707,
|
| 727 |
+
0.399, 0.861, 0.698, 0.376, 0.856, 0.689, 0.353, 0.850, 0.680, 0.329,
|
| 728 |
+
0.845, 0.672, 0.305, 0.840, 0.663, 0.281, 0.834, 0.654, 0.256, 0.829,
|
| 729 |
+
0.645, 0.231, 0.824, 0.636, 0.204, 0.662, 0.631, 0.998, 0.672, 0.641,
|
| 730 |
+
0.993, 0.681, 0.650, 0.988, 0.691, 0.659, 0.983, 0.700, 0.669, 0.979,
|
| 731 |
+
0.710, 0.678, 0.974, 0.720, 0.687, 0.970, 0.730, 0.696, 0.966, 0.740,
|
| 732 |
+
0.706, 0.963, 0.750, 0.715, 0.960, 0.760, 0.724, 0.957, 0.771, 0.733,
|
| 733 |
+
0.954, 0.781, 0.742, 0.951, 0.791, 0.752, 0.949, 0.802, 0.761, 0.947,
|
| 734 |
+
0.812, 0.770, 0.945, 0.823, 0.779, 0.943, 0.834, 0.789, 0.942, 0.844,
|
| 735 |
+
0.798, 0.941, 0.855, 0.807, 0.940, 0.866, 0.817, 0.939, 0.877, 0.826,
|
| 736 |
+
0.938, 0.887, 0.835, 0.938, 0.898, 0.844, 0.937, 0.909, 0.853, 0.937,
|
| 737 |
+
0.919, 0.862, 0.937, 0.930, 0.870, 0.936, 0.940, 0.878, 0.936, 0.950,
|
| 738 |
+
0.885, 0.934, 0.958, 0.891, 0.932, 0.967, 0.896, 0.928, 0.974, 0.898,
|
| 739 |
+
0.922, 0.979, 0.899, 0.914, 0.982, 0.897, 0.902, 0.984, 0.893, 0.886,
|
| 740 |
+
0.984, 0.887, 0.869, 0.982, 0.880, 0.849, 0.979, 0.872, 0.828, 0.975,
|
| 741 |
+
0.864, 0.807, 0.970, 0.856, 0.785, 0.965, 0.847, 0.762, 0.959, 0.838,
|
| 742 |
+
0.739, 0.954, 0.829, 0.717, 0.948, 0.819, 0.694, 0.943, 0.810, 0.671,
|
| 743 |
+
0.937, 0.801, 0.648, 0.931, 0.792, 0.625, 0.925, 0.782, 0.602, 0.919,
|
| 744 |
+
0.773, 0.579, 0.914, 0.764, 0.556, 0.908, 0.755, 0.533, 0.902, 0.746,
|
| 745 |
+
0.511, 0.897, 0.737, 0.488, 0.891, 0.728, 0.465, 0.886, 0.719, 0.442,
|
| 746 |
+
0.880, 0.710, 0.420, 0.875, 0.701, 0.397, 0.869, 0.692, 0.374, 0.864,
|
| 747 |
+
0.683, 0.350, 0.858, 0.674, 0.327, 0.853, 0.665, 0.303, 0.848, 0.657,
|
| 748 |
+
0.279, 0.842, 0.648, 0.254, 0.837, 0.639, 0.229, 0.832, 0.630, 0.202,
|
| 749 |
+
0.671, 0.625, 0.998, 0.680, 0.635, 0.993, 0.689, 0.644, 0.988, 0.698,
|
| 750 |
+
0.654, 0.983, 0.708, 0.663, 0.978, 0.718, 0.672, 0.974, 0.727, 0.681,
|
| 751 |
+
0.970, 0.737, 0.691, 0.966, 0.747, 0.700, 0.962, 0.757, 0.709, 0.959,
|
| 752 |
+
0.767, 0.718, 0.956, 0.777, 0.727, 0.953, 0.787, 0.736, 0.950, 0.797,
|
| 753 |
+
0.745, 0.948, 0.807, 0.755, 0.946, 0.818, 0.764, 0.944, 0.828, 0.773,
|
| 754 |
+
0.942, 0.839, 0.782, 0.940, 0.849, 0.791, 0.939, 0.859, 0.800, 0.938,
|
| 755 |
+
0.870, 0.809, 0.937, 0.880, 0.818, 0.936, 0.891, 0.827, 0.935, 0.901,
|
| 756 |
+
0.835, 0.934, 0.911, 0.844, 0.933, 0.921, 0.852, 0.932, 0.931, 0.859,
|
| 757 |
+
0.931, 0.941, 0.866, 0.929, 0.950, 0.873, 0.927, 0.958, 0.878, 0.923,
|
| 758 |
+
0.966, 0.881, 0.919, 0.972, 0.883, 0.912, 0.977, 0.883, 0.903, 0.981,
|
| 759 |
+
0.882, 0.891, 0.983, 0.878, 0.876, 0.984, 0.873, 0.859, 0.983, 0.867,
|
| 760 |
+
0.841, 0.980, 0.860, 0.821, 0.977, 0.853, 0.800, 0.974, 0.845, 0.778,
|
| 761 |
+
0.969, 0.836, 0.756, 0.964, 0.828, 0.734, 0.959, 0.819, 0.712, 0.954,
|
| 762 |
+
0.810, 0.689, 0.949, 0.801, 0.666, 0.943, 0.792, 0.644, 0.938, 0.783,
|
| 763 |
+
0.621, 0.932, 0.774, 0.598, 0.927, 0.765, 0.575, 0.921, 0.756, 0.553,
|
| 764 |
+
0.916, 0.747, 0.530, 0.910, 0.738, 0.507, 0.904, 0.729, 0.485, 0.899,
|
| 765 |
+
0.721, 0.462, 0.893, 0.712, 0.439, 0.888, 0.703, 0.417, 0.882, 0.694,
|
| 766 |
+
0.394, 0.877, 0.685, 0.371, 0.871, 0.676, 0.348, 0.866, 0.668, 0.324,
|
| 767 |
+
0.861, 0.659, 0.301, 0.855, 0.650, 0.277, 0.850, 0.641, 0.252, 0.845,
|
| 768 |
+
0.633, 0.226, 0.839, 0.624, 0.200, 0.679, 0.619, 0.998, 0.688, 0.629,
|
| 769 |
+
0.993, 0.697, 0.638, 0.988, 0.706, 0.648, 0.983, 0.715, 0.657, 0.978,
|
| 770 |
+
0.725, 0.666, 0.974, 0.734, 0.675, 0.969, 0.744, 0.684, 0.965, 0.754,
|
| 771 |
+
0.693, 0.962, 0.763, 0.703, 0.958, 0.773, 0.712, 0.955, 0.783, 0.721,
|
| 772 |
+
0.952, 0.793, 0.730, 0.949, 0.803, 0.739, 0.947, 0.813, 0.748, 0.944,
|
| 773 |
+
0.823, 0.757, 0.942, 0.833, 0.766, 0.940, 0.843, 0.774, 0.938, 0.853,
|
| 774 |
+
0.783, 0.937, 0.863, 0.792, 0.935, 0.874, 0.801, 0.934, 0.884, 0.809,
|
| 775 |
+
0.932, 0.894, 0.818, 0.931, 0.904, 0.826, 0.930, 0.913, 0.833, 0.928,
|
| 776 |
+
0.923, 0.841, 0.927, 0.932, 0.848, 0.925, 0.941, 0.854, 0.922, 0.950,
|
| 777 |
+
0.859, 0.919, 0.957, 0.864, 0.915, 0.965, 0.867, 0.909, 0.971, 0.868,
|
| 778 |
+
0.901, 0.976, 0.868, 0.892, 0.980, 0.867, 0.880, 0.982, 0.863, 0.866,
|
| 779 |
+
0.983, 0.859, 0.849, 0.983, 0.854, 0.832, 0.982, 0.847, 0.812, 0.979,
|
| 780 |
+
0.840, 0.792, 0.976, 0.833, 0.771, 0.973, 0.825, 0.750, 0.969, 0.817,
|
| 781 |
+
0.728, 0.964, 0.809, 0.706, 0.959, 0.800, 0.684, 0.954, 0.792, 0.661,
|
| 782 |
+
0.949, 0.783, 0.639, 0.944, 0.774, 0.617, 0.939, 0.766, 0.594, 0.933,
|
| 783 |
+
0.757, 0.572, 0.928, 0.748, 0.549, 0.922, 0.739, 0.527, 0.917, 0.731,
|
| 784 |
+
0.504, 0.911, 0.722, 0.481, 0.906, 0.713, 0.459, 0.901, 0.704, 0.436,
|
| 785 |
+
0.895, 0.695, 0.414, 0.890, 0.687, 0.391, 0.884, 0.678, 0.368, 0.879,
|
| 786 |
+
0.669, 0.345, 0.873, 0.661, 0.322, 0.868, 0.652, 0.298, 0.863, 0.643,
|
| 787 |
+
0.274, 0.857, 0.635, 0.249, 0.852, 0.626, 0.224, 0.846, 0.617, 0.197,
|
| 788 |
+
0.686, 0.613, 0.998, 0.695, 0.622, 0.993, 0.704, 0.632, 0.987, 0.713,
|
| 789 |
+
0.641, 0.982, 0.722, 0.650, 0.977, 0.732, 0.660, 0.973, 0.741, 0.669,
|
| 790 |
+
0.969, 0.750, 0.678, 0.965, 0.760, 0.687, 0.961, 0.769, 0.696, 0.957,
|
| 791 |
+
0.779, 0.705, 0.954, 0.789, 0.714, 0.951, 0.798, 0.723, 0.948, 0.808,
|
| 792 |
+
0.731, 0.945, 0.818, 0.740, 0.943, 0.828, 0.749, 0.940, 0.838, 0.758,
|
| 793 |
+
0.938, 0.847, 0.766, 0.936, 0.857, 0.775, 0.934, 0.867, 0.783, 0.932,
|
| 794 |
+
0.877, 0.792, 0.930, 0.887, 0.800, 0.929, 0.896, 0.808, 0.927, 0.906,
|
| 795 |
+
0.815, 0.925, 0.915, 0.823, 0.923, 0.924, 0.829, 0.921, 0.933, 0.836,
|
| 796 |
+
0.918, 0.942, 0.841, 0.915, 0.950, 0.846, 0.911, 0.957, 0.850, 0.906,
|
| 797 |
+
0.964, 0.852, 0.899, 0.970, 0.853, 0.891, 0.975, 0.853, 0.881, 0.979,
|
| 798 |
+
0.852, 0.869, 0.981, 0.849, 0.855, 0.983, 0.845, 0.840, 0.983, 0.840,
|
| 799 |
+
0.822, 0.982, 0.834, 0.804, 0.981, 0.828, 0.784, 0.978, 0.821, 0.764,
|
| 800 |
+
0.975, 0.814, 0.743, 0.972, 0.806, 0.722, 0.968, 0.798, 0.700, 0.964,
|
| 801 |
+
0.790, 0.678, 0.959, 0.782, 0.656, 0.954, 0.773, 0.634, 0.949, 0.765,
|
| 802 |
+
0.612, 0.944, 0.757, 0.590, 0.939, 0.748, 0.567, 0.934, 0.739, 0.545,
|
| 803 |
+
0.929, 0.731, 0.523, 0.923, 0.722, 0.500, 0.918, 0.714, 0.478, 0.913,
|
| 804 |
+
0.705, 0.456, 0.907, 0.696, 0.433, 0.902, 0.688, 0.411, 0.896, 0.679,
|
| 805 |
+
0.388, 0.891, 0.670, 0.365, 0.886, 0.662, 0.342, 0.880, 0.653, 0.319,
|
| 806 |
+
0.875, 0.645, 0.295, 0.869, 0.636, 0.271, 0.864, 0.628, 0.247, 0.859,
|
| 807 |
+
0.619, 0.221, 0.853, 0.611, 0.195, 0.694, 0.606, 0.998, 0.703, 0.616,
|
| 808 |
+
0.992, 0.711, 0.625, 0.987, 0.720, 0.634, 0.982, 0.729, 0.644, 0.977,
|
| 809 |
+
0.738, 0.653, 0.972, 0.747, 0.662, 0.968, 0.757, 0.671, 0.964, 0.766,
|
| 810 |
+
0.680, 0.960, 0.775, 0.689, 0.956, 0.785, 0.698, 0.953, 0.794, 0.706,
|
| 811 |
+
0.949, 0.804, 0.715, 0.946, 0.813, 0.724, 0.943, 0.823, 0.732, 0.941,
|
| 812 |
+
0.832, 0.741, 0.938, 0.842, 0.749, 0.936, 0.851, 0.758, 0.933, 0.861,
|
| 813 |
+
0.766, 0.931, 0.870, 0.774, 0.929, 0.880, 0.782, 0.927, 0.889, 0.790,
|
| 814 |
+
0.924, 0.899, 0.797, 0.922, 0.908, 0.805, 0.920, 0.917, 0.811, 0.917,
|
| 815 |
+
0.925, 0.818, 0.914, 0.934, 0.823, 0.911, 0.942, 0.828, 0.907, 0.950,
|
| 816 |
+
0.832, 0.902, 0.957, 0.836, 0.896, 0.963, 0.838, 0.889, 0.969, 0.839,
|
| 817 |
+
0.881, 0.974, 0.838, 0.871, 0.978, 0.837, 0.859, 0.980, 0.834, 0.845,
|
| 818 |
+
0.982, 0.831, 0.830, 0.983, 0.826, 0.813, 0.983, 0.821, 0.795, 0.982,
|
| 819 |
+
0.815, 0.776, 0.980, 0.809, 0.757, 0.978, 0.802, 0.736, 0.975, 0.794,
|
| 820 |
+
0.715, 0.971, 0.787, 0.694, 0.967, 0.779, 0.673, 0.963, 0.771, 0.651,
|
| 821 |
+
0.959, 0.763, 0.629, 0.954, 0.755, 0.607, 0.949, 0.747, 0.585, 0.944,
|
| 822 |
+
0.739, 0.563, 0.939, 0.730, 0.541, 0.934, 0.722, 0.519, 0.929, 0.714,
|
| 823 |
+
0.496, 0.924, 0.705, 0.474, 0.919, 0.697, 0.452, 0.913, 0.688, 0.430,
|
| 824 |
+
0.908, 0.680, 0.407, 0.903, 0.671, 0.385, 0.897, 0.663, 0.362, 0.892,
|
| 825 |
+
0.654, 0.339, 0.887, 0.646, 0.316, 0.881, 0.637, 0.293, 0.876, 0.629,
|
| 826 |
+
0.269, 0.870, 0.620, 0.244, 0.865, 0.612, 0.219, 0.860, 0.604, 0.192,
|
| 827 |
+
0.701, 0.599, 0.997, 0.710, 0.609, 0.992, 0.718, 0.618, 0.986, 0.727,
|
| 828 |
+
0.627, 0.981, 0.736, 0.636, 0.976, 0.745, 0.645, 0.971, 0.754, 0.655,
|
| 829 |
+
0.967, 0.763, 0.663, 0.963, 0.772, 0.672, 0.959, 0.781, 0.681, 0.955,
|
| 830 |
+
0.790, 0.690, 0.951, 0.799, 0.699, 0.948, 0.808, 0.707, 0.944, 0.818,
|
| 831 |
+
0.716, 0.941, 0.827, 0.724, 0.938, 0.836, 0.732, 0.935, 0.846, 0.741,
|
| 832 |
+
0.933, 0.855, 0.749, 0.930, 0.864, 0.757, 0.928, 0.874, 0.765, 0.925,
|
| 833 |
+
0.883, 0.772, 0.923, 0.892, 0.780, 0.920, 0.901, 0.787, 0.917, 0.910,
|
| 834 |
+
0.793, 0.914, 0.918, 0.800, 0.911, 0.927, 0.805, 0.908, 0.935, 0.811,
|
| 835 |
+
0.904, 0.942, 0.815, 0.899, 0.950, 0.819, 0.894, 0.956, 0.821, 0.887,
|
| 836 |
+
0.963, 0.823, 0.880, 0.968, 0.824, 0.871, 0.973, 0.824, 0.860, 0.977,
|
| 837 |
+
0.822, 0.849, 0.980, 0.820, 0.835, 0.982, 0.817, 0.820, 0.983, 0.812,
|
| 838 |
+
0.804, 0.983, 0.808, 0.786, 0.983, 0.802, 0.768, 0.981, 0.796, 0.749,
|
| 839 |
+
0.979, 0.789, 0.729, 0.977, 0.783, 0.709, 0.974, 0.776, 0.688, 0.970,
|
| 840 |
+
0.768, 0.667, 0.967, 0.761, 0.645, 0.963, 0.753, 0.624, 0.958, 0.745,
|
| 841 |
+
0.602, 0.954, 0.737, 0.580, 0.949, 0.729, 0.558, 0.944, 0.721, 0.536,
|
| 842 |
+
0.939, 0.713, 0.514, 0.934, 0.704, 0.492, 0.929, 0.696, 0.470, 0.924,
|
| 843 |
+
0.688, 0.448, 0.919, 0.680, 0.426, 0.914, 0.671, 0.404, 0.908, 0.663,
|
| 844 |
+
0.381, 0.903, 0.655, 0.359, 0.898, 0.646, 0.336, 0.893, 0.638, 0.313,
|
| 845 |
+
0.887, 0.629, 0.290, 0.882, 0.621, 0.266, 0.876, 0.613, 0.241, 0.871,
|
| 846 |
+
0.604, 0.216, 0.866, 0.596, 0.189, 0.708, 0.592, 0.997, 0.716, 0.601,
|
| 847 |
+
0.991, 0.725, 0.611, 0.985, 0.733, 0.620, 0.980, 0.742, 0.629, 0.975,
|
| 848 |
+
0.751, 0.638, 0.970, 0.759, 0.647, 0.966, 0.768, 0.656, 0.961, 0.777,
|
| 849 |
+
0.665, 0.957, 0.786, 0.673, 0.953, 0.795, 0.682, 0.949, 0.804, 0.690,
|
| 850 |
+
0.946, 0.813, 0.699, 0.942, 0.822, 0.707, 0.939, 0.831, 0.715, 0.936,
|
| 851 |
+
0.840, 0.723, 0.933, 0.849, 0.731, 0.930, 0.859, 0.739, 0.927, 0.868,
|
| 852 |
+
0.747, 0.924, 0.876, 0.754, 0.921, 0.885, 0.762, 0.918, 0.894, 0.769,
|
| 853 |
+
0.915, 0.903, 0.775, 0.912, 0.911, 0.782, 0.909, 0.920, 0.787, 0.905,
|
| 854 |
+
0.928, 0.793, 0.901, 0.935, 0.798, 0.896, 0.943, 0.802, 0.891, 0.950,
|
| 855 |
+
0.805, 0.885, 0.956, 0.807, 0.878, 0.962, 0.809, 0.870, 0.967, 0.809,
|
| 856 |
+
0.861, 0.972, 0.809, 0.850, 0.976, 0.808, 0.838, 0.979, 0.805, 0.825,
|
| 857 |
+
0.981, 0.802, 0.810, 0.983, 0.799, 0.795, 0.983, 0.794, 0.778, 0.983,
|
| 858 |
+
0.789, 0.760, 0.982, 0.783, 0.741, 0.981, 0.777, 0.721, 0.979, 0.771,
|
| 859 |
+
0.701, 0.976, 0.764, 0.681, 0.973, 0.757, 0.660, 0.970, 0.750, 0.639,
|
| 860 |
+
0.966, 0.742, 0.618, 0.962, 0.735, 0.597, 0.958, 0.727, 0.575, 0.953,
|
| 861 |
+
0.719, 0.553, 0.949, 0.711, 0.532, 0.944, 0.703, 0.510, 0.939, 0.695,
|
| 862 |
+
0.488, 0.934, 0.687, 0.466, 0.929, 0.679, 0.444, 0.924, 0.671, 0.422,
|
| 863 |
+
0.919, 0.663, 0.400, 0.914, 0.654, 0.378, 0.909, 0.646, 0.355, 0.903,
|
| 864 |
+
0.638, 0.333, 0.898, 0.630, 0.310, 0.893, 0.621, 0.287, 0.887, 0.613,
|
| 865 |
+
0.263, 0.882, 0.605, 0.238, 0.877, 0.597, 0.213, 0.871, 0.589, 0.186,
|
| 866 |
+
0.715, 0.584, 0.996, 0.723, 0.593, 0.990, 0.731, 0.603, 0.984, 0.739,
|
| 867 |
+
0.612, 0.979, 0.748, 0.621, 0.974, 0.756, 0.630, 0.969, 0.765, 0.639,
|
| 868 |
+
0.964, 0.774, 0.648, 0.960, 0.782, 0.656, 0.955, 0.791, 0.665, 0.951,
|
| 869 |
+
0.800, 0.673, 0.947, 0.809, 0.682, 0.943, 0.818, 0.690, 0.940, 0.826,
|
| 870 |
+
0.698, 0.936, 0.835, 0.706, 0.933, 0.844, 0.714, 0.930, 0.853, 0.722,
|
| 871 |
+
0.926, 0.862, 0.729, 0.923, 0.871, 0.737, 0.920, 0.879, 0.744, 0.917,
|
| 872 |
+
0.888, 0.751, 0.913, 0.896, 0.758, 0.910, 0.905, 0.764, 0.906, 0.913,
|
| 873 |
+
0.770, 0.903, 0.921, 0.775, 0.898, 0.929, 0.780, 0.894, 0.936, 0.784,
|
| 874 |
+
0.889, 0.943, 0.788, 0.883, 0.950, 0.791, 0.877, 0.956, 0.793, 0.869,
|
| 875 |
+
0.962, 0.794, 0.861, 0.967, 0.795, 0.851, 0.971, 0.794, 0.841, 0.975,
|
| 876 |
+
0.793, 0.829, 0.978, 0.791, 0.815, 0.981, 0.788, 0.801, 0.982, 0.785,
|
| 877 |
+
0.785, 0.983, 0.780, 0.769, 0.983, 0.776, 0.751, 0.983, 0.770, 0.733,
|
| 878 |
+
0.982, 0.764, 0.714, 0.980, 0.758, 0.694, 0.978, 0.752, 0.674, 0.975,
|
| 879 |
+
0.745, 0.654, 0.972, 0.738, 0.633, 0.969, 0.731, 0.612, 0.965, 0.724,
|
| 880 |
+
0.591, 0.961, 0.716, 0.570, 0.957, 0.709, 0.548, 0.953, 0.701, 0.527,
|
| 881 |
+
0.948, 0.693, 0.505, 0.943, 0.685, 0.484, 0.939, 0.678, 0.462, 0.934,
|
| 882 |
+
0.670, 0.440, 0.929, 0.662, 0.418, 0.924, 0.654, 0.396, 0.919, 0.646,
|
| 883 |
+
0.374, 0.914, 0.637, 0.352, 0.908, 0.629, 0.329, 0.903, 0.621, 0.307,
|
| 884 |
+
0.898, 0.613, 0.283, 0.893, 0.605, 0.260, 0.887, 0.597, 0.235, 0.882,
|
| 885 |
+
0.589, 0.210, 0.876, 0.581, 0.183, 0.721, 0.576, 0.995, 0.729, 0.585,
|
| 886 |
+
0.989, 0.737, 0.595, 0.983, 0.745, 0.604, 0.978, 0.754, 0.613, 0.973,
|
| 887 |
+
0.762, 0.622, 0.968, 0.770, 0.631, 0.963, 0.779, 0.639, 0.958, 0.787,
|
| 888 |
+
0.648, 0.954, 0.796, 0.656, 0.949, 0.805, 0.665, 0.945, 0.813, 0.673,
|
| 889 |
+
0.941, 0.822, 0.681, 0.937, 0.830, 0.689, 0.933, 0.839, 0.697, 0.930,
|
| 890 |
+
0.848, 0.704, 0.926, 0.856, 0.712, 0.923, 0.865, 0.719, 0.919, 0.873,
|
| 891 |
+
0.726, 0.916, 0.882, 0.733, 0.912, 0.890, 0.740, 0.908, 0.898, 0.746,
|
| 892 |
+
0.905, 0.906, 0.752, 0.901, 0.914, 0.757, 0.896, 0.922, 0.762, 0.892,
|
| 893 |
+
0.929, 0.767, 0.887, 0.937, 0.771, 0.881, 0.943, 0.774, 0.875, 0.950,
|
| 894 |
+
0.777, 0.868, 0.956, 0.779, 0.860, 0.961, 0.780, 0.851, 0.966, 0.780,
|
| 895 |
+
0.842, 0.971, 0.780, 0.831, 0.975, 0.779, 0.819, 0.978, 0.777, 0.806,
|
| 896 |
+
0.980, 0.774, 0.791, 0.982, 0.771, 0.776, 0.983, 0.767, 0.760, 0.984,
|
| 897 |
+
0.762, 0.742, 0.983, 0.757, 0.725, 0.983, 0.752, 0.706, 0.981, 0.746,
|
| 898 |
+
0.687, 0.979, 0.740, 0.667, 0.977, 0.733, 0.647, 0.974, 0.727, 0.627,
|
| 899 |
+
0.971, 0.720, 0.606, 0.968, 0.713, 0.585, 0.964, 0.706, 0.564, 0.960,
|
| 900 |
+
0.698, 0.543, 0.956, 0.691, 0.522, 0.952, 0.683, 0.501, 0.947, 0.676,
|
| 901 |
+
0.479, 0.943, 0.668, 0.458, 0.938, 0.660, 0.436, 0.933, 0.652, 0.414,
|
| 902 |
+
0.928, 0.644, 0.392, 0.923, 0.636, 0.370, 0.918, 0.629, 0.348, 0.913,
|
| 903 |
+
0.621, 0.326, 0.908, 0.613, 0.303, 0.903, 0.605, 0.280, 0.897, 0.597,
|
| 904 |
+
0.257, 0.892, 0.589, 0.232, 0.887, 0.581, 0.207, 0.881, 0.573, 0.180,
|
| 905 |
+
0.727, 0.568, 0.994, 0.735, 0.577, 0.988, 0.743, 0.586, 0.982, 0.751,
|
| 906 |
+
0.595, 0.977, 0.759, 0.604, 0.971, 0.767, 0.613, 0.966, 0.776, 0.622,
|
| 907 |
+
0.961, 0.784, 0.630, 0.956, 0.792, 0.639, 0.951, 0.801, 0.647, 0.947,
|
| 908 |
+
0.809, 0.655, 0.943, 0.817, 0.663, 0.938, 0.826, 0.671, 0.934, 0.834,
|
| 909 |
+
0.679, 0.930, 0.843, 0.687, 0.927, 0.851, 0.694, 0.923, 0.859, 0.702,
|
| 910 |
+
0.919, 0.868, 0.709, 0.915, 0.876, 0.715, 0.911, 0.884, 0.722, 0.907,
|
| 911 |
+
0.892, 0.728, 0.903, 0.900, 0.734, 0.899, 0.908, 0.740, 0.895, 0.916,
|
| 912 |
+
0.745, 0.890, 0.923, 0.750, 0.885, 0.930, 0.754, 0.879, 0.937, 0.758,
|
| 913 |
+
0.873, 0.944, 0.761, 0.867, 0.950, 0.763, 0.859, 0.956, 0.765, 0.851,
|
| 914 |
+
0.961, 0.766, 0.842, 0.966, 0.766, 0.832, 0.970, 0.766, 0.821, 0.974,
|
| 915 |
+
0.764, 0.809, 0.977, 0.762, 0.796, 0.980, 0.760, 0.782, 0.982, 0.757,
|
| 916 |
+
0.767, 0.983, 0.753, 0.751, 0.984, 0.749, 0.734, 0.984, 0.744, 0.716,
|
| 917 |
+
0.983, 0.739, 0.698, 0.982, 0.733, 0.679, 0.980, 0.727, 0.660, 0.978,
|
| 918 |
+
0.721, 0.640, 0.976, 0.715, 0.620, 0.973, 0.708, 0.600, 0.970, 0.701,
|
| 919 |
+
0.579, 0.967, 0.694, 0.559, 0.963, 0.687, 0.538, 0.959, 0.680, 0.517,
|
| 920 |
+
0.955, 0.673, 0.496, 0.951, 0.665, 0.474, 0.946, 0.658, 0.453, 0.942,
|
| 921 |
+
0.650, 0.432, 0.937, 0.643, 0.410, 0.932, 0.635, 0.388, 0.927, 0.627,
|
| 922 |
+
0.367, 0.922, 0.619, 0.345, 0.917, 0.612, 0.322, 0.912, 0.604, 0.300,
|
| 923 |
+
0.907, 0.596, 0.277, 0.902, 0.588, 0.253, 0.897, 0.580, 0.229, 0.891,
|
| 924 |
+
0.572, 0.204, 0.886, 0.564, 0.177, 0.733, 0.559, 0.993, 0.741, 0.568,
|
| 925 |
+
0.987, 0.749, 0.577, 0.981, 0.757, 0.587, 0.975, 0.765, 0.595, 0.970,
|
| 926 |
+
0.773, 0.604, 0.964, 0.781, 0.613, 0.959, 0.789, 0.621, 0.954, 0.797,
|
| 927 |
+
0.630, 0.949, 0.805, 0.638, 0.945, 0.813, 0.646, 0.940, 0.821, 0.654,
|
| 928 |
+
0.936, 0.830, 0.662, 0.931, 0.838, 0.669, 0.927, 0.846, 0.677, 0.923,
|
| 929 |
+
0.854, 0.684, 0.919, 0.862, 0.691, 0.915, 0.870, 0.698, 0.911, 0.879,
|
| 930 |
+
0.704, 0.907, 0.886, 0.711, 0.902, 0.894, 0.717, 0.898, 0.902, 0.722,
|
| 931 |
+
0.893, 0.910, 0.727, 0.889, 0.917, 0.732, 0.883, 0.924, 0.737, 0.878,
|
| 932 |
+
0.931, 0.741, 0.872, 0.938, 0.744, 0.866, 0.944, 0.747, 0.859, 0.950,
|
| 933 |
+
0.749, 0.851, 0.956, 0.751, 0.842, 0.961, 0.751, 0.833, 0.966, 0.752,
|
| 934 |
+
0.823, 0.970, 0.751, 0.812, 0.974, 0.750, 0.800, 0.977, 0.748, 0.787,
|
| 935 |
+
0.979, 0.746, 0.773, 0.981, 0.743, 0.758, 0.983, 0.739, 0.742, 0.984,
|
| 936 |
+
0.735, 0.725, 0.984, 0.731, 0.708, 0.983, 0.726, 0.690, 0.983, 0.721,
|
| 937 |
+
0.672, 0.981, 0.715, 0.653, 0.980, 0.709, 0.633, 0.977, 0.703, 0.614,
|
| 938 |
+
0.975, 0.697, 0.594, 0.972, 0.690, 0.573, 0.969, 0.683, 0.553, 0.965,
|
| 939 |
+
0.676, 0.532, 0.962, 0.669, 0.512, 0.958, 0.662, 0.491, 0.954, 0.655,
|
| 940 |
+
0.470, 0.949, 0.648, 0.448, 0.945, 0.640, 0.427, 0.941, 0.633, 0.406,
|
| 941 |
+
0.936, 0.625, 0.384, 0.931, 0.618, 0.363, 0.926, 0.610, 0.341, 0.921,
|
| 942 |
+
0.602, 0.319, 0.916, 0.595, 0.296, 0.911, 0.587, 0.273, 0.906, 0.579,
|
| 943 |
+
0.250, 0.901, 0.571, 0.226, 0.896, 0.563, 0.201, 0.890, 0.556, 0.174,
|
| 944 |
+
0.739, 0.550, 0.992, 0.747, 0.559, 0.986, 0.754, 0.568, 0.980, 0.762,
|
| 945 |
+
0.577, 0.974, 0.770, 0.586, 0.968, 0.778, 0.595, 0.962, 0.785, 0.603,
|
| 946 |
+
0.957, 0.793, 0.612, 0.952, 0.801, 0.620, 0.947, 0.809, 0.628, 0.942,
|
| 947 |
+
0.817, 0.636, 0.937, 0.825, 0.644, 0.933, 0.833, 0.651, 0.928, 0.841,
|
| 948 |
+
0.659, 0.924, 0.849, 0.666, 0.919, 0.857, 0.673, 0.915, 0.865, 0.680,
|
| 949 |
+
0.911, 0.873, 0.686, 0.906, 0.881, 0.693, 0.902, 0.889, 0.699, 0.897,
|
| 950 |
+
0.896, 0.705, 0.892, 0.904, 0.710, 0.887, 0.911, 0.715, 0.882, 0.918,
|
| 951 |
+
0.720, 0.877, 0.925, 0.724, 0.871, 0.932, 0.727, 0.865, 0.938, 0.730,
|
| 952 |
+
0.858, 0.944, 0.733, 0.850, 0.950, 0.735, 0.842, 0.956, 0.736, 0.834,
|
| 953 |
+
0.961, 0.737, 0.824, 0.965, 0.737, 0.814, 0.970, 0.737, 0.802, 0.973,
|
| 954 |
+
0.736, 0.790, 0.976, 0.734, 0.777, 0.979, 0.732, 0.763, 0.981, 0.729,
|
| 955 |
+
0.749, 0.982, 0.726, 0.733, 0.983, 0.722, 0.717, 0.984, 0.717, 0.700,
|
| 956 |
+
0.984, 0.713, 0.682, 0.983, 0.708, 0.664, 0.982, 0.702, 0.645, 0.980,
|
| 957 |
+
0.697, 0.626, 0.979, 0.691, 0.607, 0.976, 0.685, 0.587, 0.974, 0.678,
|
| 958 |
+
0.567, 0.971, 0.672, 0.547, 0.967, 0.665, 0.527, 0.964, 0.658, 0.506,
|
| 959 |
+
0.960, 0.651, 0.485, 0.956, 0.644, 0.465, 0.952, 0.637, 0.444, 0.948,
|
| 960 |
+
0.630, 0.423, 0.944, 0.623, 0.401, 0.939, 0.615, 0.380, 0.934, 0.608,
|
| 961 |
+
0.358, 0.930, 0.600, 0.337, 0.925, 0.593, 0.315, 0.920, 0.585, 0.292,
|
| 962 |
+
0.915, 0.578, 0.270, 0.910, 0.570, 0.246, 0.905, 0.562, 0.222, 0.899,
|
| 963 |
+
0.555, 0.197, 0.894, 0.547, 0.171, 0.745, 0.540, 0.991, 0.752, 0.550,
|
| 964 |
+
0.984, 0.760, 0.559, 0.978, 0.767, 0.568, 0.972, 0.775, 0.577, 0.966,
|
| 965 |
+
0.782, 0.585, 0.960, 0.790, 0.594, 0.955, 0.798, 0.602, 0.950, 0.806,
|
| 966 |
+
0.610, 0.944, 0.813, 0.618, 0.939, 0.821, 0.626, 0.934, 0.829, 0.634,
|
| 967 |
+
0.930, 0.837, 0.641, 0.925, 0.845, 0.648, 0.920, 0.852, 0.655, 0.915,
|
| 968 |
+
0.860, 0.662, 0.911, 0.868, 0.669, 0.906, 0.876, 0.675, 0.901, 0.883,
|
| 969 |
+
0.681, 0.897, 0.891, 0.687, 0.892, 0.898, 0.692, 0.887, 0.905, 0.697,
|
| 970 |
+
0.881, 0.912, 0.702, 0.876, 0.919, 0.707, 0.870, 0.926, 0.710, 0.864,
|
| 971 |
+
0.932, 0.714, 0.857, 0.939, 0.717, 0.850, 0.945, 0.719, 0.842, 0.950,
|
| 972 |
+
0.721, 0.834, 0.956, 0.722, 0.825, 0.961, 0.723, 0.815, 0.965, 0.723,
|
| 973 |
+
0.804, 0.969, 0.723, 0.793, 0.973, 0.722, 0.781, 0.976, 0.720, 0.768,
|
| 974 |
+
0.978, 0.718, 0.754, 0.981, 0.715, 0.739, 0.982, 0.712, 0.724, 0.983,
|
| 975 |
+
0.708, 0.708, 0.984, 0.704, 0.691, 0.984, 0.700, 0.674, 0.983, 0.695,
|
| 976 |
+
0.656, 0.982, 0.690, 0.638, 0.981, 0.684, 0.619, 0.979, 0.679, 0.600,
|
| 977 |
+
0.977, 0.673, 0.581, 0.975, 0.666, 0.561, 0.972, 0.660, 0.541, 0.969,
|
| 978 |
+
0.654, 0.521, 0.966, 0.647, 0.501, 0.962, 0.640, 0.480, 0.959, 0.634,
|
| 979 |
+
0.459, 0.955, 0.627, 0.439, 0.951, 0.620, 0.418, 0.946, 0.612, 0.397,
|
| 980 |
+
0.942, 0.605, 0.376, 0.937, 0.598, 0.354, 0.933, 0.591, 0.333, 0.928,
|
| 981 |
+
0.583, 0.311, 0.923, 0.576, 0.289, 0.918, 0.568, 0.266, 0.913, 0.561,
|
| 982 |
+
0.243, 0.908, 0.553, 0.219, 0.903, 0.546, 0.194, 0.898, 0.538, 0.167,
|
| 983 |
+
0.750, 0.531, 0.989, 0.757, 0.540, 0.983, 0.765, 0.549, 0.976, 0.772,
|
| 984 |
+
0.558, 0.970, 0.779, 0.567, 0.964, 0.787, 0.575, 0.958, 0.794, 0.584,
|
| 985 |
+
0.953, 0.802, 0.592, 0.947, 0.810, 0.600, 0.942, 0.817, 0.608, 0.936,
|
| 986 |
+
0.825, 0.615, 0.931, 0.833, 0.623, 0.926, 0.840, 0.630, 0.921, 0.848,
|
| 987 |
+
0.637, 0.916, 0.855, 0.644, 0.911, 0.863, 0.651, 0.907, 0.870, 0.657,
|
| 988 |
+
0.902, 0.878, 0.663, 0.897, 0.885, 0.669, 0.891, 0.893, 0.675, 0.886,
|
| 989 |
+
0.900, 0.680, 0.881, 0.907, 0.685, 0.875, 0.914, 0.689, 0.869, 0.920,
|
| 990 |
+
0.693, 0.863, 0.927, 0.697, 0.857, 0.933, 0.700, 0.850, 0.939, 0.703,
|
| 991 |
+
0.842, 0.945, 0.705, 0.834, 0.950, 0.707, 0.825, 0.956, 0.708, 0.816,
|
| 992 |
+
0.960, 0.709, 0.806, 0.965, 0.709, 0.795, 0.969, 0.708, 0.784, 0.972,
|
| 993 |
+
0.707, 0.772, 0.975, 0.706, 0.759, 0.978, 0.704, 0.745, 0.980, 0.701,
|
| 994 |
+
0.731, 0.982, 0.698, 0.715, 0.983, 0.694, 0.699, 0.984, 0.691, 0.683,
|
| 995 |
+
0.984, 0.686, 0.666, 0.983, 0.682, 0.648, 0.983, 0.677, 0.630, 0.982,
|
| 996 |
+
0.672, 0.612, 0.980, 0.666, 0.593, 0.978, 0.660, 0.574, 0.976, 0.655,
|
| 997 |
+
0.554, 0.973, 0.648, 0.535, 0.971, 0.642, 0.515, 0.967, 0.636, 0.495,
|
| 998 |
+
0.964, 0.629, 0.475, 0.961, 0.623, 0.454, 0.957, 0.616, 0.434, 0.953,
|
| 999 |
+
0.609, 0.413, 0.949, 0.602, 0.392, 0.944, 0.595, 0.371, 0.940, 0.588,
|
| 1000 |
+
0.350, 0.936, 0.580, 0.328, 0.931, 0.573, 0.307, 0.926, 0.566, 0.285,
|
| 1001 |
+
0.921, 0.559, 0.262, 0.916, 0.551, 0.239, 0.911, 0.544, 0.215, 0.906,
|
| 1002 |
+
0.536, 0.190, 0.901, 0.529, 0.164, 0.755, 0.521, 0.988, 0.762, 0.530,
|
| 1003 |
+
0.981, 0.770, 0.539, 0.975, 0.777, 0.548, 0.968, 0.784, 0.557, 0.962,
|
| 1004 |
+
0.791, 0.565, 0.956, 0.799, 0.573, 0.950, 0.806, 0.582, 0.944, 0.814,
|
| 1005 |
+
0.589, 0.939, 0.821, 0.597, 0.933, 0.828, 0.605, 0.928, 0.836, 0.612,
|
| 1006 |
+
0.923, 0.843, 0.619, 0.918, 0.851, 0.626, 0.912, 0.858, 0.633, 0.907,
|
| 1007 |
+
0.866, 0.639, 0.902, 0.873, 0.645, 0.897, 0.880, 0.651, 0.892, 0.887,
|
| 1008 |
+
0.657, 0.886, 0.894, 0.662, 0.881, 0.901, 0.667, 0.875, 0.908, 0.672,
|
| 1009 |
+
0.869, 0.915, 0.676, 0.863, 0.921, 0.680, 0.856, 0.928, 0.684, 0.849,
|
| 1010 |
+
0.934, 0.687, 0.842, 0.940, 0.689, 0.834, 0.945, 0.691, 0.826, 0.951,
|
| 1011 |
+
0.693, 0.817, 0.956, 0.694, 0.807, 0.960, 0.695, 0.797, 0.964, 0.695,
|
| 1012 |
+
0.787, 0.968, 0.694, 0.775, 0.972, 0.693, 0.763, 0.975, 0.692, 0.750,
|
| 1013 |
+
0.977, 0.690, 0.736, 0.980, 0.687, 0.722, 0.981, 0.684, 0.707, 0.982,
|
| 1014 |
+
0.681, 0.691, 0.983, 0.677, 0.675, 0.984, 0.673, 0.658, 0.983, 0.669,
|
| 1015 |
+
0.641, 0.983, 0.664, 0.623, 0.982, 0.659, 0.605, 0.980, 0.654, 0.586,
|
| 1016 |
+
0.979, 0.648, 0.567, 0.977, 0.642, 0.548, 0.974, 0.637, 0.529, 0.972,
|
| 1017 |
+
0.630, 0.509, 0.969, 0.624, 0.489, 0.966, 0.618, 0.469, 0.962, 0.611,
|
| 1018 |
+
0.449, 0.959, 0.605, 0.429, 0.955, 0.598, 0.408, 0.951, 0.591, 0.387,
|
| 1019 |
+
0.947, 0.584, 0.367, 0.942, 0.577, 0.346, 0.938, 0.570, 0.324, 0.933,
|
| 1020 |
+
0.563, 0.303, 0.929, 0.556, 0.281, 0.924, 0.549, 0.258, 0.919, 0.541,
|
| 1021 |
+
0.235, 0.914, 0.534, 0.212, 0.909, 0.527, 0.187, 0.904, 0.519, 0.160,
|
| 1022 |
+
0.760, 0.510, 0.986, 0.767, 0.520, 0.979, 0.774, 0.529, 0.973, 0.781,
|
| 1023 |
+
0.538, 0.966, 0.788, 0.546, 0.960, 0.796, 0.555, 0.954, 0.803, 0.563,
|
| 1024 |
+
0.948, 0.810, 0.571, 0.942, 0.817, 0.579, 0.936, 0.825, 0.586, 0.930,
|
| 1025 |
+
0.832, 0.594, 0.925, 0.839, 0.601, 0.919, 0.846, 0.608, 0.914, 0.854,
|
| 1026 |
+
0.615, 0.908, 0.861, 0.621, 0.903, 0.868, 0.627, 0.897, 0.875, 0.633,
|
| 1027 |
+
0.892, 0.882, 0.639, 0.886, 0.889, 0.645, 0.881, 0.896, 0.650, 0.875,
|
| 1028 |
+
0.903, 0.655, 0.869, 0.909, 0.659, 0.863, 0.916, 0.663, 0.856, 0.922,
|
| 1029 |
+
0.667, 0.849, 0.928, 0.670, 0.842, 0.934, 0.673, 0.834, 0.940, 0.675,
|
| 1030 |
+
0.826, 0.945, 0.677, 0.818, 0.951, 0.679, 0.809, 0.955, 0.680, 0.799,
|
| 1031 |
+
0.960, 0.680, 0.789, 0.964, 0.680, 0.778, 0.968, 0.680, 0.766, 0.971,
|
| 1032 |
+
0.679, 0.754, 0.974, 0.677, 0.741, 0.977, 0.676, 0.727, 0.979, 0.673,
|
| 1033 |
+
0.713, 0.981, 0.670, 0.698, 0.982, 0.667, 0.682, 0.983, 0.664, 0.666,
|
| 1034 |
+
0.983, 0.660, 0.650, 0.983, 0.655, 0.633, 0.983, 0.651, 0.615, 0.982,
|
| 1035 |
+
0.646, 0.597, 0.981, 0.641, 0.579, 0.979, 0.636, 0.560, 0.977, 0.630,
|
| 1036 |
+
0.541, 0.975, 0.625, 0.522, 0.973, 0.619, 0.503, 0.970, 0.613, 0.483,
|
| 1037 |
+
0.967, 0.606, 0.463, 0.964, 0.600, 0.443, 0.960, 0.594, 0.423, 0.956,
|
| 1038 |
+
0.587, 0.403, 0.953, 0.580, 0.383, 0.949, 0.574, 0.362, 0.944, 0.567,
|
| 1039 |
+
0.341, 0.940, 0.560, 0.320, 0.936, 0.553, 0.298, 0.931, 0.546, 0.277,
|
| 1040 |
+
0.926, 0.539, 0.254, 0.922, 0.532, 0.232, 0.917, 0.524, 0.208, 0.912,
|
| 1041 |
+
0.517, 0.183, 0.906, 0.510, 0.156, 0.765, 0.499, 0.985, 0.772, 0.509,
|
| 1042 |
+
0.978, 0.779, 0.518, 0.971, 0.786, 0.527, 0.964, 0.793, 0.535, 0.957,
|
| 1043 |
+
0.800, 0.544, 0.951, 0.807, 0.552, 0.945, 0.814, 0.560, 0.939, 0.821,
|
| 1044 |
+
0.568, 0.933, 0.828, 0.575, 0.927, 0.835, 0.582, 0.921, 0.842, 0.589,
|
| 1045 |
+
0.915, 0.849, 0.596, 0.910, 0.856, 0.603, 0.904, 0.863, 0.609, 0.898,
|
| 1046 |
+
0.870, 0.615, 0.893, 0.877, 0.621, 0.887, 0.884, 0.627, 0.881, 0.891,
|
| 1047 |
+
0.632, 0.875, 0.898, 0.637, 0.869, 0.904, 0.642, 0.863, 0.911, 0.646,
|
| 1048 |
+
0.856, 0.917, 0.650, 0.849, 0.923, 0.653, 0.842, 0.929, 0.657, 0.835,
|
| 1049 |
+
0.935, 0.659, 0.827, 0.940, 0.662, 0.818, 0.946, 0.663, 0.810, 0.951,
|
| 1050 |
+
0.665, 0.800, 0.955, 0.666, 0.790, 0.960, 0.666, 0.780, 0.964, 0.666,
|
| 1051 |
+
0.769, 0.967, 0.666, 0.757, 0.971, 0.665, 0.745, 0.974, 0.663, 0.732,
|
| 1052 |
+
0.976, 0.662, 0.718, 0.978, 0.659, 0.704, 0.980, 0.657, 0.689, 0.981,
|
| 1053 |
+
0.654, 0.674, 0.982, 0.650, 0.658, 0.983, 0.646, 0.642, 0.983, 0.642,
|
| 1054 |
+
0.625, 0.983, 0.638, 0.608, 0.982, 0.633, 0.590, 0.981, 0.628, 0.572,
|
| 1055 |
+
0.979, 0.623, 0.553, 0.978, 0.618, 0.535, 0.976, 0.612, 0.516, 0.973,
|
| 1056 |
+
0.607, 0.497, 0.971, 0.601, 0.477, 0.968, 0.595, 0.458, 0.965, 0.589,
|
| 1057 |
+
0.438, 0.961, 0.582, 0.418, 0.958, 0.576, 0.398, 0.954, 0.569, 0.378,
|
| 1058 |
+
0.950, 0.563, 0.357, 0.946, 0.556, 0.336, 0.942, 0.549, 0.315, 0.938,
|
| 1059 |
+
0.542, 0.294, 0.933, 0.536, 0.273, 0.928, 0.529, 0.250, 0.924, 0.522,
|
| 1060 |
+
0.228, 0.919, 0.514, 0.204, 0.914, 0.507, 0.179, 0.909, 0.500, 0.153,
|
| 1061 |
+
0.770, 0.488, 0.983, 0.777, 0.498, 0.976, 0.783, 0.507, 0.969, 0.790,
|
| 1062 |
+
0.516, 0.962, 0.797, 0.524, 0.955, 0.804, 0.533, 0.948, 0.811, 0.541,
|
| 1063 |
+
0.942, 0.817, 0.549, 0.936, 0.824, 0.556, 0.930, 0.831, 0.564, 0.924,
|
| 1064 |
+
0.838, 0.571, 0.918, 0.845, 0.578, 0.912, 0.852, 0.584, 0.906, 0.859,
|
| 1065 |
+
0.591, 0.900, 0.866, 0.597, 0.894, 0.873, 0.603, 0.888, 0.879, 0.609,
|
| 1066 |
+
0.882, 0.886, 0.614, 0.876, 0.893, 0.619, 0.869, 0.899, 0.624, 0.863,
|
| 1067 |
+
0.906, 0.629, 0.856, 0.912, 0.633, 0.850, 0.918, 0.637, 0.843, 0.924,
|
| 1068 |
+
0.640, 0.835, 0.930, 0.643, 0.827, 0.935, 0.646, 0.819, 0.941, 0.648,
|
| 1069 |
+
0.811, 0.946, 0.649, 0.802, 0.951, 0.651, 0.792, 0.955, 0.652, 0.782,
|
| 1070 |
+
0.959, 0.652, 0.771, 0.963, 0.652, 0.760, 0.967, 0.652, 0.749, 0.970,
|
| 1071 |
+
0.651, 0.736, 0.973, 0.649, 0.723, 0.976, 0.647, 0.710, 0.978, 0.645,
|
| 1072 |
+
0.696, 0.980, 0.643, 0.681, 0.981, 0.640, 0.666, 0.982, 0.637, 0.650,
|
| 1073 |
+
0.982, 0.633, 0.634, 0.983, 0.629, 0.617, 0.982, 0.625, 0.600, 0.982,
|
| 1074 |
+
0.620, 0.582, 0.981, 0.616, 0.565, 0.979, 0.611, 0.546, 0.978, 0.605,
|
| 1075 |
+
0.528, 0.976, 0.600, 0.509, 0.974, 0.595, 0.490, 0.971, 0.589, 0.471,
|
| 1076 |
+
0.969, 0.583, 0.452, 0.966, 0.577, 0.432, 0.962, 0.571, 0.413, 0.959,
|
| 1077 |
+
0.565, 0.393, 0.955, 0.558, 0.373, 0.952, 0.552, 0.352, 0.948, 0.545,
|
| 1078 |
+
0.332, 0.943, 0.539, 0.311, 0.939, 0.532, 0.290, 0.935, 0.525, 0.268,
|
| 1079 |
+
0.930, 0.518, 0.246, 0.926, 0.511, 0.224, 0.921, 0.504, 0.200, 0.916,
|
| 1080 |
+
0.497, 0.175, 0.911, 0.490, 0.149, 0.775, 0.477, 0.981, 0.781, 0.486,
|
| 1081 |
+
0.974, 0.788, 0.495, 0.966, 0.794, 0.504, 0.959, 0.801, 0.513, 0.952,
|
| 1082 |
+
0.808, 0.521, 0.946, 0.814, 0.529, 0.939, 0.821, 0.537, 0.933, 0.828,
|
| 1083 |
+
0.545, 0.926, 0.835, 0.552, 0.920, 0.841, 0.559, 0.914, 0.848, 0.566,
|
| 1084 |
+
0.908, 0.855, 0.572, 0.901, 0.862, 0.579, 0.895, 0.868, 0.585, 0.889,
|
| 1085 |
+
0.875, 0.591, 0.883, 0.881, 0.596, 0.877, 0.888, 0.601, 0.870, 0.894,
|
| 1086 |
+
0.606, 0.864, 0.901, 0.611, 0.857, 0.907, 0.615, 0.850, 0.913, 0.619,
|
| 1087 |
+
0.843, 0.919, 0.623, 0.836, 0.925, 0.626, 0.828, 0.930, 0.629, 0.820,
|
| 1088 |
+
0.936, 0.632, 0.812, 0.941, 0.634, 0.803, 0.946, 0.635, 0.794, 0.951,
|
| 1089 |
+
0.637, 0.784, 0.955, 0.637, 0.774, 0.959, 0.638, 0.763, 0.963, 0.638,
|
| 1090 |
+
0.752, 0.967, 0.637, 0.740, 0.970, 0.636, 0.728, 0.973, 0.635, 0.715,
|
| 1091 |
+
0.975, 0.633, 0.701, 0.977, 0.631, 0.687, 0.979, 0.629, 0.672, 0.980,
|
| 1092 |
+
0.626, 0.657, 0.981, 0.623, 0.642, 0.982, 0.619, 0.626, 0.982, 0.616,
|
| 1093 |
+
0.609, 0.982, 0.612, 0.592, 0.981, 0.607, 0.575, 0.981, 0.603, 0.557,
|
| 1094 |
+
0.979, 0.598, 0.540, 0.978, 0.593, 0.521, 0.976, 0.588, 0.503, 0.974,
|
| 1095 |
+
0.582, 0.484, 0.972, 0.577, 0.465, 0.969, 0.571, 0.446, 0.966, 0.565,
|
| 1096 |
+
0.427, 0.963, 0.559, 0.407, 0.960, 0.553, 0.387, 0.956, 0.547, 0.368,
|
| 1097 |
+
0.953, 0.541, 0.347, 0.949, 0.534, 0.327, 0.945, 0.528, 0.306, 0.941,
|
| 1098 |
+
0.521, 0.285, 0.936, 0.514, 0.264, 0.932, 0.508, 0.242, 0.927, 0.501,
|
| 1099 |
+
0.220, 0.922, 0.494, 0.196, 0.918, 0.487, 0.172, 0.913, 0.480, 0.145,
|
| 1100 |
+
0.779, 0.465, 0.979, 0.785, 0.474, 0.971, 0.792, 0.484, 0.964, 0.798,
|
| 1101 |
+
0.492, 0.957, 0.805, 0.501, 0.950, 0.811, 0.509, 0.943, 0.818, 0.517,
|
| 1102 |
+
0.936, 0.824, 0.525, 0.929, 0.831, 0.533, 0.923, 0.838, 0.540, 0.916,
|
| 1103 |
+
0.844, 0.547, 0.910, 0.851, 0.554, 0.904, 0.857, 0.560, 0.897, 0.864,
|
| 1104 |
+
0.566, 0.891, 0.870, 0.572, 0.884, 0.877, 0.578, 0.878, 0.883, 0.583,
|
| 1105 |
+
0.871, 0.890, 0.589, 0.865, 0.896, 0.593, 0.858, 0.902, 0.598, 0.851,
|
| 1106 |
+
0.908, 0.602, 0.844, 0.914, 0.606, 0.837, 0.920, 0.609, 0.829, 0.925,
|
| 1107 |
+
0.613, 0.821, 0.931, 0.615, 0.813, 0.936, 0.618, 0.804, 0.941, 0.620,
|
| 1108 |
+
0.795, 0.946, 0.621, 0.786, 0.950, 0.622, 0.776, 0.955, 0.623, 0.765,
|
| 1109 |
+
0.959, 0.624, 0.755, 0.963, 0.624, 0.743, 0.966, 0.623, 0.731, 0.969,
|
| 1110 |
+
0.622, 0.719, 0.972, 0.621, 0.706, 0.974, 0.619, 0.693, 0.976, 0.617,
|
| 1111 |
+
0.679, 0.978, 0.615, 0.664, 0.979, 0.612, 0.649, 0.980, 0.609, 0.634,
|
| 1112 |
+
0.981, 0.606, 0.618, 0.981, 0.602, 0.601, 0.981, 0.598, 0.585, 0.981,
|
| 1113 |
+
0.594, 0.568, 0.980, 0.590, 0.550, 0.979, 0.585, 0.533, 0.978, 0.580,
|
| 1114 |
+
0.515, 0.976, 0.575, 0.496, 0.974, 0.570, 0.478, 0.972, 0.565, 0.459,
|
| 1115 |
+
0.969, 0.559, 0.440, 0.967, 0.553, 0.421, 0.964, 0.547, 0.402, 0.960,
|
| 1116 |
+
0.542, 0.382, 0.957, 0.535, 0.362, 0.953, 0.529, 0.342, 0.950, 0.523,
|
| 1117 |
+
0.322, 0.946, 0.517, 0.302, 0.942, 0.510, 0.281, 0.937, 0.504, 0.260,
|
| 1118 |
+
0.933, 0.497, 0.238, 0.929, 0.490, 0.216, 0.924, 0.484, 0.192, 0.919,
|
| 1119 |
+
0.477, 0.168, 0.914, 0.470, 0.141, 0.783, 0.453, 0.977, 0.789, 0.462,
|
| 1120 |
+
0.969, 0.796, 0.471, 0.962, 0.802, 0.480, 0.954, 0.808, 0.489, 0.947,
|
| 1121 |
+
0.815, 0.497, 0.940, 0.821, 0.505, 0.933, 0.828, 0.513, 0.926, 0.834,
|
| 1122 |
+
0.520, 0.919, 0.840, 0.527, 0.913, 0.847, 0.534, 0.906, 0.853, 0.541,
|
| 1123 |
+
0.899, 0.860, 0.548, 0.893, 0.866, 0.554, 0.886, 0.873, 0.560, 0.880,
|
| 1124 |
+
0.879, 0.565, 0.873, 0.885, 0.570, 0.866, 0.891, 0.575, 0.859, 0.897,
|
| 1125 |
+
0.580, 0.852, 0.903, 0.585, 0.845, 0.909, 0.589, 0.838, 0.915, 0.592,
|
| 1126 |
+
0.830, 0.921, 0.596, 0.822, 0.926, 0.599, 0.814, 0.931, 0.601, 0.805,
|
| 1127 |
+
0.936, 0.604, 0.797, 0.941, 0.606, 0.787, 0.946, 0.607, 0.778, 0.950,
|
| 1128 |
+
0.608, 0.768, 0.955, 0.609, 0.757, 0.958, 0.609, 0.746, 0.962, 0.609,
|
| 1129 |
+
0.735, 0.965, 0.609, 0.723, 0.968, 0.608, 0.710, 0.971, 0.607, 0.698,
|
| 1130 |
+
0.974, 0.605, 0.684, 0.976, 0.603, 0.670, 0.977, 0.601, 0.656, 0.979,
|
| 1131 |
+
0.598, 0.641, 0.980, 0.596, 0.626, 0.980, 0.592, 0.610, 0.981, 0.589,
|
| 1132 |
+
0.594, 0.981, 0.585, 0.577, 0.980, 0.581, 0.560, 0.980, 0.577, 0.543,
|
| 1133 |
+
0.979, 0.572, 0.526, 0.977, 0.568, 0.508, 0.976, 0.563, 0.490, 0.974,
|
| 1134 |
+
0.558, 0.471, 0.972, 0.552, 0.453, 0.969, 0.547, 0.434, 0.967, 0.541,
|
| 1135 |
+
0.415, 0.964, 0.536, 0.396, 0.961, 0.530, 0.377, 0.958, 0.524, 0.357,
|
| 1136 |
+
0.954, 0.518, 0.337, 0.950, 0.512, 0.317, 0.947, 0.505, 0.297, 0.943,
|
| 1137 |
+
0.499, 0.276, 0.938, 0.493, 0.255, 0.934, 0.486, 0.234, 0.930, 0.480,
|
| 1138 |
+
0.211, 0.925, 0.473, 0.188, 0.920, 0.466, 0.164, 0.916, 0.459, 0.137,
|
| 1139 |
+
0.787, 0.440, 0.975, 0.793, 0.450, 0.967, 0.799, 0.459, 0.959, 0.806,
|
| 1140 |
+
0.468, 0.952, 0.812, 0.476, 0.944, 0.818, 0.485, 0.937, 0.824, 0.493,
|
| 1141 |
+
0.930, 0.831, 0.500, 0.923, 0.837, 0.508, 0.916, 0.843, 0.515, 0.909,
|
| 1142 |
+
0.850, 0.522, 0.902, 0.856, 0.528, 0.895, 0.862, 0.535, 0.888, 0.868,
|
| 1143 |
+
0.541, 0.881, 0.874, 0.547, 0.875, 0.881, 0.552, 0.868, 0.887, 0.557,
|
| 1144 |
+
0.861, 0.893, 0.562, 0.853, 0.899, 0.567, 0.846, 0.904, 0.571, 0.839,
|
| 1145 |
+
0.910, 0.575, 0.831, 0.916, 0.579, 0.823, 0.921, 0.582, 0.815, 0.926,
|
| 1146 |
+
0.585, 0.807, 0.932, 0.587, 0.798, 0.937, 0.590, 0.789, 0.941, 0.591,
|
| 1147 |
+
0.780, 0.946, 0.593, 0.770, 0.950, 0.594, 0.760, 0.954, 0.595, 0.749,
|
| 1148 |
+
0.958, 0.595, 0.738, 0.962, 0.595, 0.727, 0.965, 0.595, 0.715, 0.968,
|
| 1149 |
+
0.594, 0.702, 0.970, 0.593, 0.689, 0.973, 0.591, 0.676, 0.975, 0.589,
|
| 1150 |
+
0.662, 0.976, 0.587, 0.648, 0.978, 0.585, 0.633, 0.979, 0.582, 0.618,
|
| 1151 |
+
0.980, 0.579, 0.602, 0.980, 0.575, 0.586, 0.980, 0.572, 0.570, 0.980,
|
| 1152 |
+
0.568, 0.553, 0.979, 0.564, 0.536, 0.978, 0.559, 0.518, 0.977, 0.555,
|
| 1153 |
+
0.501, 0.975, 0.550, 0.483, 0.974, 0.545, 0.465, 0.972, 0.540, 0.447,
|
| 1154 |
+
0.969, 0.535, 0.428, 0.967, 0.529, 0.409, 0.964, 0.524, 0.390, 0.961,
|
| 1155 |
+
0.518, 0.371, 0.958, 0.512, 0.352, 0.954, 0.506, 0.332, 0.951, 0.500,
|
| 1156 |
+
0.312, 0.947, 0.494, 0.292, 0.943, 0.488, 0.272, 0.939, 0.481, 0.251,
|
| 1157 |
+
0.935, 0.475, 0.229, 0.931, 0.469, 0.207, 0.926, 0.462, 0.184, 0.921,
|
| 1158 |
+
0.455, 0.159, 0.917, 0.449, 0.133, 0.791, 0.427, 0.973, 0.797, 0.437,
|
| 1159 |
+
0.964, 0.803, 0.446, 0.957, 0.809, 0.455, 0.949, 0.815, 0.464, 0.941,
|
| 1160 |
+
0.821, 0.472, 0.934, 0.827, 0.480, 0.926, 0.834, 0.488, 0.919, 0.840,
|
| 1161 |
+
0.495, 0.912, 0.846, 0.502, 0.905, 0.852, 0.509, 0.898, 0.858, 0.515,
|
| 1162 |
+
0.891, 0.864, 0.522, 0.884, 0.870, 0.528, 0.877, 0.876, 0.533, 0.870,
|
| 1163 |
+
0.882, 0.539, 0.862, 0.888, 0.544, 0.855, 0.894, 0.549, 0.848, 0.900,
|
| 1164 |
+
0.553, 0.840, 0.906, 0.557, 0.833, 0.911, 0.561, 0.825, 0.916, 0.565,
|
| 1165 |
+
0.817, 0.922, 0.568, 0.808, 0.927, 0.571, 0.800, 0.932, 0.573, 0.791,
|
| 1166 |
+
0.937, 0.575, 0.782, 0.941, 0.577, 0.772, 0.946, 0.579, 0.762, 0.950,
|
| 1167 |
+
0.580, 0.752, 0.954, 0.580, 0.741, 0.958, 0.581, 0.730, 0.961, 0.581,
|
| 1168 |
+
0.718, 0.964, 0.580, 0.706, 0.967, 0.580, 0.694, 0.970, 0.578, 0.681,
|
| 1169 |
+
0.972, 0.577, 0.667, 0.974, 0.575, 0.654, 0.976, 0.573, 0.639, 0.977,
|
| 1170 |
+
0.571, 0.625, 0.978, 0.568, 0.610, 0.979, 0.565, 0.594, 0.979, 0.562,
|
| 1171 |
+
0.578, 0.979, 0.558, 0.562, 0.979, 0.554, 0.545, 0.978, 0.550, 0.529,
|
| 1172 |
+
0.977, 0.546, 0.511, 0.976, 0.542, 0.494, 0.975, 0.537, 0.476, 0.973,
|
| 1173 |
+
0.532, 0.458, 0.971, 0.527, 0.440, 0.969, 0.522, 0.422, 0.967, 0.517,
|
| 1174 |
+
0.403, 0.964, 0.511, 0.385, 0.961, 0.506, 0.366, 0.958, 0.500, 0.347,
|
| 1175 |
+
0.955, 0.494, 0.327, 0.951, 0.488, 0.307, 0.947, 0.482, 0.287, 0.944,
|
| 1176 |
+
0.476, 0.267, 0.940, 0.470, 0.246, 0.935, 0.464, 0.225, 0.931, 0.458,
|
| 1177 |
+
0.203, 0.927, 0.451, 0.180, 0.922, 0.445, 0.155, 0.917, 0.438, 0.129,
|
| 1178 |
+
0.795, 0.413, 0.970, 0.801, 0.423, 0.962, 0.807, 0.433, 0.954, 0.813,
|
| 1179 |
+
0.442, 0.946, 0.818, 0.450, 0.938, 0.824, 0.459, 0.930, 0.830, 0.467,
|
| 1180 |
+
0.923, 0.836, 0.474, 0.915, 0.842, 0.482, 0.908, 0.848, 0.489, 0.901,
|
| 1181 |
+
0.854, 0.496, 0.894, 0.860, 0.502, 0.886, 0.866, 0.508, 0.879, 0.872,
|
| 1182 |
+
0.514, 0.872, 0.878, 0.520, 0.864, 0.884, 0.525, 0.857, 0.890, 0.530,
|
| 1183 |
+
0.850, 0.895, 0.535, 0.842, 0.901, 0.539, 0.834, 0.906, 0.543, 0.826,
|
| 1184 |
+
0.912, 0.547, 0.818, 0.917, 0.551, 0.810, 0.922, 0.554, 0.801, 0.927,
|
| 1185 |
+
0.557, 0.793, 0.932, 0.559, 0.783, 0.937, 0.561, 0.774, 0.941, 0.563,
|
| 1186 |
+
0.764, 0.946, 0.564, 0.754, 0.950, 0.565, 0.744, 0.953, 0.566, 0.733,
|
| 1187 |
+
0.957, 0.566, 0.722, 0.960, 0.566, 0.710, 0.963, 0.566, 0.698, 0.966,
|
| 1188 |
+
0.565, 0.685, 0.969, 0.564, 0.673, 0.971, 0.563, 0.659, 0.973, 0.561,
|
| 1189 |
+
0.645, 0.975, 0.559, 0.631, 0.976, 0.557, 0.617, 0.977, 0.554, 0.602,
|
| 1190 |
+
0.978, 0.551, 0.586, 0.978, 0.548, 0.571, 0.978, 0.545, 0.554, 0.978,
|
| 1191 |
+
0.541, 0.538, 0.977, 0.537, 0.521, 0.977, 0.533, 0.504, 0.976, 0.529,
|
| 1192 |
+
0.487, 0.974, 0.524, 0.470, 0.973, 0.519, 0.452, 0.971, 0.515, 0.434,
|
| 1193 |
+
0.969, 0.510, 0.416, 0.966, 0.504, 0.398, 0.964, 0.499, 0.379, 0.961,
|
| 1194 |
+
0.494, 0.360, 0.958, 0.488, 0.341, 0.955, 0.482, 0.322, 0.951, 0.477,
|
| 1195 |
+
0.302, 0.948, 0.471, 0.283, 0.944, 0.465, 0.262, 0.940, 0.459, 0.242,
|
| 1196 |
+
0.936, 0.452, 0.220, 0.932, 0.446, 0.198, 0.927, 0.440, 0.175, 0.923,
|
| 1197 |
+
0.434, 0.151, 0.918, 0.427, 0.124, 0.799, 0.399, 0.968, 0.804, 0.409,
|
| 1198 |
+
0.959, 0.810, 0.419, 0.951, 0.816, 0.428, 0.943, 0.822, 0.437, 0.935,
|
| 1199 |
+
0.827, 0.445, 0.927, 0.833, 0.453, 0.919, 0.839, 0.461, 0.912, 0.845,
|
| 1200 |
+
0.468, 0.904, 0.851, 0.475, 0.897, 0.857, 0.482, 0.889, 0.862, 0.489,
|
| 1201 |
+
0.882, 0.868, 0.495, 0.874, 0.874, 0.501, 0.867, 0.880, 0.506, 0.859,
|
| 1202 |
+
0.885, 0.511, 0.852, 0.891, 0.516, 0.844, 0.897, 0.521, 0.836, 0.902,
|
| 1203 |
+
0.525, 0.828, 0.907, 0.529, 0.820, 0.913, 0.533, 0.812, 0.918, 0.537,
|
| 1204 |
+
0.803, 0.923, 0.540, 0.794, 0.928, 0.542, 0.785, 0.932, 0.545, 0.776,
|
| 1205 |
+
0.937, 0.547, 0.767, 0.941, 0.549, 0.757, 0.945, 0.550, 0.747, 0.949,
|
| 1206 |
+
0.551, 0.736, 0.953, 0.552, 0.725, 0.956, 0.552, 0.714, 0.960, 0.552,
|
| 1207 |
+
0.702, 0.963, 0.552, 0.690, 0.965, 0.551, 0.677, 0.968, 0.550, 0.664,
|
| 1208 |
+
0.970, 0.549, 0.651, 0.972, 0.547, 0.637, 0.974, 0.545, 0.623, 0.975,
|
| 1209 |
+
0.543, 0.609, 0.976, 0.540, 0.594, 0.977, 0.537, 0.578, 0.977, 0.534,
|
| 1210 |
+
0.563, 0.977, 0.531, 0.547, 0.977, 0.527, 0.531, 0.976, 0.524, 0.514,
|
| 1211 |
+
0.976, 0.520, 0.497, 0.975, 0.516, 0.480, 0.973, 0.511, 0.463, 0.972,
|
| 1212 |
+
0.507, 0.446, 0.970, 0.502, 0.428, 0.968, 0.497, 0.410, 0.966, 0.492,
|
| 1213 |
+
0.392, 0.963, 0.487, 0.373, 0.960, 0.481, 0.355, 0.957, 0.476, 0.336,
|
| 1214 |
+
0.954, 0.470, 0.317, 0.951, 0.465, 0.297, 0.947, 0.459, 0.278, 0.944,
|
| 1215 |
+
0.453, 0.258, 0.940, 0.447, 0.237, 0.936, 0.441, 0.216, 0.932, 0.435,
|
| 1216 |
+
0.194, 0.927, 0.429, 0.171, 0.923, 0.422, 0.147, 0.918, 0.416, 0.120,
|
| 1217 |
+
0.802, 0.385, 0.965, 0.808, 0.395, 0.957, 0.813, 0.405, 0.948, 0.819,
|
| 1218 |
+
0.414, 0.940, 0.825, 0.423, 0.932, 0.830, 0.431, 0.924, 0.836, 0.439,
|
| 1219 |
+
0.916, 0.842, 0.447, 0.908, 0.847, 0.454, 0.900, 0.853, 0.462, 0.892,
|
| 1220 |
+
0.859, 0.468, 0.885, 0.864, 0.475, 0.877, 0.870, 0.481, 0.869, 0.876,
|
| 1221 |
+
0.487, 0.862, 0.881, 0.492, 0.854, 0.887, 0.498, 0.846, 0.892, 0.502,
|
| 1222 |
+
0.838, 0.898, 0.507, 0.830, 0.903, 0.511, 0.822, 0.908, 0.515, 0.814,
|
| 1223 |
+
0.913, 0.519, 0.805, 0.918, 0.522, 0.797, 0.923, 0.525, 0.788, 0.928,
|
| 1224 |
+
0.528, 0.778, 0.932, 0.530, 0.769, 0.937, 0.532, 0.759, 0.941, 0.534,
|
| 1225 |
+
0.749, 0.945, 0.535, 0.739, 0.949, 0.536, 0.728, 0.952, 0.537, 0.717,
|
| 1226 |
+
0.956, 0.537, 0.706, 0.959, 0.537, 0.694, 0.962, 0.537, 0.682, 0.964,
|
| 1227 |
+
0.536, 0.669, 0.967, 0.536, 0.656, 0.969, 0.534, 0.643, 0.971, 0.533,
|
| 1228 |
+
0.629, 0.972, 0.531, 0.615, 0.974, 0.529, 0.601, 0.975, 0.526, 0.586,
|
| 1229 |
+
0.975, 0.523, 0.571, 0.976, 0.521, 0.555, 0.976, 0.517, 0.540, 0.976,
|
| 1230 |
+
0.514, 0.523, 0.975, 0.510, 0.507, 0.975, 0.506, 0.490, 0.974, 0.502,
|
| 1231 |
+
0.474, 0.972, 0.498, 0.456, 0.971, 0.494, 0.439, 0.969, 0.489, 0.421,
|
| 1232 |
+
0.967, 0.484, 0.404, 0.965, 0.479, 0.386, 0.963, 0.474, 0.367, 0.960,
|
| 1233 |
+
0.469, 0.349, 0.957, 0.464, 0.330, 0.954, 0.458, 0.311, 0.951, 0.453,
|
| 1234 |
+
0.292, 0.947, 0.447, 0.273, 0.944, 0.441, 0.253, 0.940, 0.435, 0.232,
|
| 1235 |
+
0.936, 0.429, 0.211, 0.932, 0.423, 0.190, 0.927, 0.417, 0.167, 0.923,
|
| 1236 |
+
0.411, 0.142, 0.919, 0.405, 0.116, 0.806, 0.370, 0.963, 0.811, 0.380,
|
| 1237 |
+
0.954, 0.816, 0.390, 0.945, 0.822, 0.399, 0.937, 0.827, 0.408, 0.929,
|
| 1238 |
+
0.833, 0.417, 0.920, 0.838, 0.425, 0.912, 0.844, 0.433, 0.904, 0.850,
|
| 1239 |
+
0.440, 0.896, 0.855, 0.447, 0.888, 0.861, 0.454, 0.880, 0.866, 0.461,
|
| 1240 |
+
0.872, 0.872, 0.467, 0.865, 0.877, 0.473, 0.857, 0.883, 0.478, 0.849,
|
| 1241 |
+
0.888, 0.483, 0.841, 0.893, 0.488, 0.833, 0.899, 0.493, 0.824, 0.904,
|
| 1242 |
+
0.497, 0.816, 0.909, 0.501, 0.807, 0.914, 0.505, 0.799, 0.919, 0.508,
|
| 1243 |
+
0.790, 0.923, 0.511, 0.781, 0.928, 0.514, 0.771, 0.932, 0.516, 0.762,
|
| 1244 |
+
0.937, 0.518, 0.752, 0.941, 0.520, 0.742, 0.945, 0.521, 0.731, 0.948,
|
| 1245 |
+
0.522, 0.720, 0.952, 0.523, 0.709, 0.955, 0.523, 0.698, 0.958, 0.523,
|
| 1246 |
+
0.686, 0.961, 0.523, 0.674, 0.964, 0.522, 0.661, 0.966, 0.521, 0.648,
|
| 1247 |
+
0.968, 0.520, 0.635, 0.970, 0.518, 0.621, 0.971, 0.517, 0.607, 0.972,
|
| 1248 |
+
0.514, 0.593, 0.973, 0.512, 0.578, 0.974, 0.509, 0.563, 0.975, 0.507,
|
| 1249 |
+
0.548, 0.975, 0.503, 0.532, 0.975, 0.500, 0.516, 0.974, 0.497, 0.500,
|
| 1250 |
+
0.974, 0.493, 0.483, 0.973, 0.489, 0.467, 0.971, 0.485, 0.450, 0.970,
|
| 1251 |
+
0.480, 0.433, 0.968, 0.476, 0.415, 0.966, 0.471, 0.397, 0.964, 0.466,
|
| 1252 |
+
0.380, 0.962, 0.461, 0.362, 0.959, 0.456, 0.343, 0.956, 0.451, 0.325,
|
| 1253 |
+
0.953, 0.446, 0.306, 0.950, 0.440, 0.287, 0.947, 0.435, 0.268, 0.943,
|
| 1254 |
+
0.429, 0.248, 0.939, 0.423, 0.228, 0.936, 0.417, 0.207, 0.931, 0.411,
|
| 1255 |
+
0.185, 0.927, 0.405, 0.162, 0.923, 0.399, 0.138, 0.918, 0.393, 0.111,
|
| 1256 |
+
0.809, 0.354, 0.960, 0.814, 0.364, 0.951, 0.819, 0.375, 0.942, 0.825,
|
| 1257 |
+
0.384, 0.934, 0.830, 0.393, 0.925, 0.835, 0.402, 0.917, 0.841, 0.410,
|
| 1258 |
+
0.908, 0.846, 0.418, 0.900, 0.852, 0.426, 0.892, 0.857, 0.433, 0.884,
|
| 1259 |
+
0.863, 0.440, 0.876, 0.868, 0.446, 0.868, 0.873, 0.452, 0.860, 0.879,
|
| 1260 |
+
0.458, 0.852, 0.884, 0.464, 0.843, 0.889, 0.469, 0.835, 0.894, 0.474,
|
| 1261 |
+
0.827, 0.899, 0.478, 0.818, 0.904, 0.483, 0.810, 0.909, 0.486, 0.801,
|
| 1262 |
+
0.914, 0.490, 0.792, 0.919, 0.493, 0.783, 0.923, 0.496, 0.774, 0.928,
|
| 1263 |
+
0.499, 0.764, 0.932, 0.501, 0.755, 0.936, 0.503, 0.745, 0.940, 0.505,
|
| 1264 |
+
0.734, 0.944, 0.506, 0.724, 0.948, 0.507, 0.713, 0.951, 0.508, 0.701,
|
| 1265 |
+
0.954, 0.508, 0.690, 0.957, 0.508, 0.678, 0.960, 0.508, 0.666, 0.962,
|
| 1266 |
+
0.507, 0.653, 0.965, 0.507, 0.640, 0.967, 0.505, 0.627, 0.968, 0.504,
|
| 1267 |
+
0.613, 0.970, 0.502, 0.599, 0.971, 0.500, 0.585, 0.972, 0.498, 0.570,
|
| 1268 |
+
0.973, 0.495, 0.555, 0.973, 0.493, 0.540, 0.973, 0.490, 0.525, 0.973,
|
| 1269 |
+
0.486, 0.509, 0.973, 0.483, 0.493, 0.972, 0.479, 0.476, 0.971, 0.475,
|
| 1270 |
+
0.460, 0.970, 0.471, 0.443, 0.969, 0.467, 0.426, 0.967, 0.463, 0.409,
|
| 1271 |
+
0.965, 0.458, 0.391, 0.963, 0.453, 0.374, 0.961, 0.449, 0.356, 0.958,
|
| 1272 |
+
0.444, 0.338, 0.956, 0.438, 0.319, 0.953, 0.433, 0.301, 0.949, 0.428,
|
| 1273 |
+
0.282, 0.946, 0.422, 0.263, 0.943, 0.417, 0.243, 0.939, 0.411, 0.223,
|
| 1274 |
+
0.935, 0.405, 0.202, 0.931, 0.399, 0.181, 0.927, 0.393, 0.158, 0.923,
|
| 1275 |
+
0.387, 0.134, 0.918, 0.381, 0.107,
|
| 1276 |
+
]).reshape((65, 65, 3))
|
| 1277 |
+
|
| 1278 |
+
BiOrangeBlue = np.array(
|
| 1279 |
+
[0.000, 0.000, 0.000, 0.000, 0.062, 0.125, 0.000, 0.125, 0.250, 0.000,
|
| 1280 |
+
0.188, 0.375, 0.000, 0.250, 0.500, 0.000, 0.312, 0.625, 0.000, 0.375,
|
| 1281 |
+
0.750, 0.000, 0.438, 0.875, 0.000, 0.500, 1.000, 0.125, 0.062, 0.000,
|
| 1282 |
+
0.125, 0.125, 0.125, 0.125, 0.188, 0.250, 0.125, 0.250, 0.375, 0.125,
|
| 1283 |
+
0.312, 0.500, 0.125, 0.375, 0.625, 0.125, 0.438, 0.750, 0.125, 0.500,
|
| 1284 |
+
0.875, 0.125, 0.562, 1.000, 0.250, 0.125, 0.000, 0.250, 0.188, 0.125,
|
| 1285 |
+
0.250, 0.250, 0.250, 0.250, 0.312, 0.375, 0.250, 0.375, 0.500, 0.250,
|
| 1286 |
+
0.438, 0.625, 0.250, 0.500, 0.750, 0.250, 0.562, 0.875, 0.250, 0.625,
|
| 1287 |
+
1.000, 0.375, 0.188, 0.000, 0.375, 0.250, 0.125, 0.375, 0.312, 0.250,
|
| 1288 |
+
0.375, 0.375, 0.375, 0.375, 0.438, 0.500, 0.375, 0.500, 0.625, 0.375,
|
| 1289 |
+
0.562, 0.750, 0.375, 0.625, 0.875, 0.375, 0.688, 1.000, 0.500, 0.250,
|
| 1290 |
+
0.000, 0.500, 0.312, 0.125, 0.500, 0.375, 0.250, 0.500, 0.438, 0.375,
|
| 1291 |
+
0.500, 0.500, 0.500, 0.500, 0.562, 0.625, 0.500, 0.625, 0.750, 0.500,
|
| 1292 |
+
0.688, 0.875, 0.500, 0.750, 1.000, 0.625, 0.312, 0.000, 0.625, 0.375,
|
| 1293 |
+
0.125, 0.625, 0.438, 0.250, 0.625, 0.500, 0.375, 0.625, 0.562, 0.500,
|
| 1294 |
+
0.625, 0.625, 0.625, 0.625, 0.688, 0.750, 0.625, 0.750, 0.875, 0.625,
|
| 1295 |
+
0.812, 1.000, 0.750, 0.375, 0.000, 0.750, 0.438, 0.125, 0.750, 0.500,
|
| 1296 |
+
0.250, 0.750, 0.562, 0.375, 0.750, 0.625, 0.500, 0.750, 0.688, 0.625,
|
| 1297 |
+
0.750, 0.750, 0.750, 0.750, 0.812, 0.875, 0.750, 0.875, 1.000, 0.875,
|
| 1298 |
+
0.438, 0.000, 0.875, 0.500, 0.125, 0.875, 0.562, 0.250, 0.875, 0.625,
|
| 1299 |
+
0.375, 0.875, 0.688, 0.500, 0.875, 0.750, 0.625, 0.875, 0.812, 0.750,
|
| 1300 |
+
0.875, 0.875, 0.875, 0.875, 0.938, 1.000, 1.000, 0.500, 0.000, 1.000,
|
| 1301 |
+
0.562, 0.125, 1.000, 0.625, 0.250, 1.000, 0.688, 0.375, 1.000, 0.750,
|
| 1302 |
+
0.500, 1.000, 0.812, 0.625, 1.000, 0.875, 0.750, 1.000, 0.938, 0.875,
|
| 1303 |
+
1.000, 1.000, 1.000,
|
| 1304 |
+
]).reshape((9, 9, 3))
|
| 1305 |
+
|
| 1306 |
+
cmaps = {
|
| 1307 |
+
"BiPeak": SegmentedBivarColormap(
|
| 1308 |
+
BiPeak, 256, "square", (.5, .5), name="BiPeak"),
|
| 1309 |
+
"BiOrangeBlue": SegmentedBivarColormap(
|
| 1310 |
+
BiOrangeBlue, 256, "square", (0, 0), name="BiOrangeBlue"),
|
| 1311 |
+
"BiCone": SegmentedBivarColormap(BiPeak, 256, "circle", (.5, .5), name="BiCone"),
|
| 1312 |
+
}
|
llava_video/lib/python3.10/site-packages/matplotlib/_cm_listed.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llava_video/lib/python3.10/site-packages/matplotlib/_color_data.py
ADDED
|
@@ -0,0 +1,1141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
BASE_COLORS = {
|
| 2 |
+
'b': (0, 0, 1), # blue
|
| 3 |
+
'g': (0, 0.5, 0), # green
|
| 4 |
+
'r': (1, 0, 0), # red
|
| 5 |
+
'c': (0, 0.75, 0.75), # cyan
|
| 6 |
+
'm': (0.75, 0, 0.75), # magenta
|
| 7 |
+
'y': (0.75, 0.75, 0), # yellow
|
| 8 |
+
'k': (0, 0, 0), # black
|
| 9 |
+
'w': (1, 1, 1), # white
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# These colors are from Tableau
|
| 14 |
+
TABLEAU_COLORS = {
|
| 15 |
+
'tab:blue': '#1f77b4',
|
| 16 |
+
'tab:orange': '#ff7f0e',
|
| 17 |
+
'tab:green': '#2ca02c',
|
| 18 |
+
'tab:red': '#d62728',
|
| 19 |
+
'tab:purple': '#9467bd',
|
| 20 |
+
'tab:brown': '#8c564b',
|
| 21 |
+
'tab:pink': '#e377c2',
|
| 22 |
+
'tab:gray': '#7f7f7f',
|
| 23 |
+
'tab:olive': '#bcbd22',
|
| 24 |
+
'tab:cyan': '#17becf',
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# This mapping of color names -> hex values is taken from
|
| 29 |
+
# a survey run by Randall Munroe see:
|
| 30 |
+
# https://blog.xkcd.com/2010/05/03/color-survey-results/
|
| 31 |
+
# for more details. The results are hosted at
|
| 32 |
+
# https://xkcd.com/color/rgb/
|
| 33 |
+
# and also available as a text file at
|
| 34 |
+
# https://xkcd.com/color/rgb.txt
|
| 35 |
+
#
|
| 36 |
+
# License: https://creativecommons.org/publicdomain/zero/1.0/
|
| 37 |
+
XKCD_COLORS = {
|
| 38 |
+
'cloudy blue': '#acc2d9',
|
| 39 |
+
'dark pastel green': '#56ae57',
|
| 40 |
+
'dust': '#b2996e',
|
| 41 |
+
'electric lime': '#a8ff04',
|
| 42 |
+
'fresh green': '#69d84f',
|
| 43 |
+
'light eggplant': '#894585',
|
| 44 |
+
'nasty green': '#70b23f',
|
| 45 |
+
'really light blue': '#d4ffff',
|
| 46 |
+
'tea': '#65ab7c',
|
| 47 |
+
'warm purple': '#952e8f',
|
| 48 |
+
'yellowish tan': '#fcfc81',
|
| 49 |
+
'cement': '#a5a391',
|
| 50 |
+
'dark grass green': '#388004',
|
| 51 |
+
'dusty teal': '#4c9085',
|
| 52 |
+
'grey teal': '#5e9b8a',
|
| 53 |
+
'macaroni and cheese': '#efb435',
|
| 54 |
+
'pinkish tan': '#d99b82',
|
| 55 |
+
'spruce': '#0a5f38',
|
| 56 |
+
'strong blue': '#0c06f7',
|
| 57 |
+
'toxic green': '#61de2a',
|
| 58 |
+
'windows blue': '#3778bf',
|
| 59 |
+
'blue blue': '#2242c7',
|
| 60 |
+
'blue with a hint of purple': '#533cc6',
|
| 61 |
+
'booger': '#9bb53c',
|
| 62 |
+
'bright sea green': '#05ffa6',
|
| 63 |
+
'dark green blue': '#1f6357',
|
| 64 |
+
'deep turquoise': '#017374',
|
| 65 |
+
'green teal': '#0cb577',
|
| 66 |
+
'strong pink': '#ff0789',
|
| 67 |
+
'bland': '#afa88b',
|
| 68 |
+
'deep aqua': '#08787f',
|
| 69 |
+
'lavender pink': '#dd85d7',
|
| 70 |
+
'light moss green': '#a6c875',
|
| 71 |
+
'light seafoam green': '#a7ffb5',
|
| 72 |
+
'olive yellow': '#c2b709',
|
| 73 |
+
'pig pink': '#e78ea5',
|
| 74 |
+
'deep lilac': '#966ebd',
|
| 75 |
+
'desert': '#ccad60',
|
| 76 |
+
'dusty lavender': '#ac86a8',
|
| 77 |
+
'purpley grey': '#947e94',
|
| 78 |
+
'purply': '#983fb2',
|
| 79 |
+
'candy pink': '#ff63e9',
|
| 80 |
+
'light pastel green': '#b2fba5',
|
| 81 |
+
'boring green': '#63b365',
|
| 82 |
+
'kiwi green': '#8ee53f',
|
| 83 |
+
'light grey green': '#b7e1a1',
|
| 84 |
+
'orange pink': '#ff6f52',
|
| 85 |
+
'tea green': '#bdf8a3',
|
| 86 |
+
'very light brown': '#d3b683',
|
| 87 |
+
'egg shell': '#fffcc4',
|
| 88 |
+
'eggplant purple': '#430541',
|
| 89 |
+
'powder pink': '#ffb2d0',
|
| 90 |
+
'reddish grey': '#997570',
|
| 91 |
+
'baby shit brown': '#ad900d',
|
| 92 |
+
'liliac': '#c48efd',
|
| 93 |
+
'stormy blue': '#507b9c',
|
| 94 |
+
'ugly brown': '#7d7103',
|
| 95 |
+
'custard': '#fffd78',
|
| 96 |
+
'darkish pink': '#da467d',
|
| 97 |
+
'deep brown': '#410200',
|
| 98 |
+
'greenish beige': '#c9d179',
|
| 99 |
+
'manilla': '#fffa86',
|
| 100 |
+
'off blue': '#5684ae',
|
| 101 |
+
'battleship grey': '#6b7c85',
|
| 102 |
+
'browny green': '#6f6c0a',
|
| 103 |
+
'bruise': '#7e4071',
|
| 104 |
+
'kelley green': '#009337',
|
| 105 |
+
'sickly yellow': '#d0e429',
|
| 106 |
+
'sunny yellow': '#fff917',
|
| 107 |
+
'azul': '#1d5dec',
|
| 108 |
+
'darkgreen': '#054907',
|
| 109 |
+
'green/yellow': '#b5ce08',
|
| 110 |
+
'lichen': '#8fb67b',
|
| 111 |
+
'light light green': '#c8ffb0',
|
| 112 |
+
'pale gold': '#fdde6c',
|
| 113 |
+
'sun yellow': '#ffdf22',
|
| 114 |
+
'tan green': '#a9be70',
|
| 115 |
+
'burple': '#6832e3',
|
| 116 |
+
'butterscotch': '#fdb147',
|
| 117 |
+
'toupe': '#c7ac7d',
|
| 118 |
+
'dark cream': '#fff39a',
|
| 119 |
+
'indian red': '#850e04',
|
| 120 |
+
'light lavendar': '#efc0fe',
|
| 121 |
+
'poison green': '#40fd14',
|
| 122 |
+
'baby puke green': '#b6c406',
|
| 123 |
+
'bright yellow green': '#9dff00',
|
| 124 |
+
'charcoal grey': '#3c4142',
|
| 125 |
+
'squash': '#f2ab15',
|
| 126 |
+
'cinnamon': '#ac4f06',
|
| 127 |
+
'light pea green': '#c4fe82',
|
| 128 |
+
'radioactive green': '#2cfa1f',
|
| 129 |
+
'raw sienna': '#9a6200',
|
| 130 |
+
'baby purple': '#ca9bf7',
|
| 131 |
+
'cocoa': '#875f42',
|
| 132 |
+
'light royal blue': '#3a2efe',
|
| 133 |
+
'orangeish': '#fd8d49',
|
| 134 |
+
'rust brown': '#8b3103',
|
| 135 |
+
'sand brown': '#cba560',
|
| 136 |
+
'swamp': '#698339',
|
| 137 |
+
'tealish green': '#0cdc73',
|
| 138 |
+
'burnt siena': '#b75203',
|
| 139 |
+
'camo': '#7f8f4e',
|
| 140 |
+
'dusk blue': '#26538d',
|
| 141 |
+
'fern': '#63a950',
|
| 142 |
+
'old rose': '#c87f89',
|
| 143 |
+
'pale light green': '#b1fc99',
|
| 144 |
+
'peachy pink': '#ff9a8a',
|
| 145 |
+
'rosy pink': '#f6688e',
|
| 146 |
+
'light bluish green': '#76fda8',
|
| 147 |
+
'light bright green': '#53fe5c',
|
| 148 |
+
'light neon green': '#4efd54',
|
| 149 |
+
'light seafoam': '#a0febf',
|
| 150 |
+
'tiffany blue': '#7bf2da',
|
| 151 |
+
'washed out green': '#bcf5a6',
|
| 152 |
+
'browny orange': '#ca6b02',
|
| 153 |
+
'nice blue': '#107ab0',
|
| 154 |
+
'sapphire': '#2138ab',
|
| 155 |
+
'greyish teal': '#719f91',
|
| 156 |
+
'orangey yellow': '#fdb915',
|
| 157 |
+
'parchment': '#fefcaf',
|
| 158 |
+
'straw': '#fcf679',
|
| 159 |
+
'very dark brown': '#1d0200',
|
| 160 |
+
'terracota': '#cb6843',
|
| 161 |
+
'ugly blue': '#31668a',
|
| 162 |
+
'clear blue': '#247afd',
|
| 163 |
+
'creme': '#ffffb6',
|
| 164 |
+
'foam green': '#90fda9',
|
| 165 |
+
'grey/green': '#86a17d',
|
| 166 |
+
'light gold': '#fddc5c',
|
| 167 |
+
'seafoam blue': '#78d1b6',
|
| 168 |
+
'topaz': '#13bbaf',
|
| 169 |
+
'violet pink': '#fb5ffc',
|
| 170 |
+
'wintergreen': '#20f986',
|
| 171 |
+
'yellow tan': '#ffe36e',
|
| 172 |
+
'dark fuchsia': '#9d0759',
|
| 173 |
+
'indigo blue': '#3a18b1',
|
| 174 |
+
'light yellowish green': '#c2ff89',
|
| 175 |
+
'pale magenta': '#d767ad',
|
| 176 |
+
'rich purple': '#720058',
|
| 177 |
+
'sunflower yellow': '#ffda03',
|
| 178 |
+
'green/blue': '#01c08d',
|
| 179 |
+
'leather': '#ac7434',
|
| 180 |
+
'racing green': '#014600',
|
| 181 |
+
'vivid purple': '#9900fa',
|
| 182 |
+
'dark royal blue': '#02066f',
|
| 183 |
+
'hazel': '#8e7618',
|
| 184 |
+
'muted pink': '#d1768f',
|
| 185 |
+
'booger green': '#96b403',
|
| 186 |
+
'canary': '#fdff63',
|
| 187 |
+
'cool grey': '#95a3a6',
|
| 188 |
+
'dark taupe': '#7f684e',
|
| 189 |
+
'darkish purple': '#751973',
|
| 190 |
+
'true green': '#089404',
|
| 191 |
+
'coral pink': '#ff6163',
|
| 192 |
+
'dark sage': '#598556',
|
| 193 |
+
'dark slate blue': '#214761',
|
| 194 |
+
'flat blue': '#3c73a8',
|
| 195 |
+
'mushroom': '#ba9e88',
|
| 196 |
+
'rich blue': '#021bf9',
|
| 197 |
+
'dirty purple': '#734a65',
|
| 198 |
+
'greenblue': '#23c48b',
|
| 199 |
+
'icky green': '#8fae22',
|
| 200 |
+
'light khaki': '#e6f2a2',
|
| 201 |
+
'warm blue': '#4b57db',
|
| 202 |
+
'dark hot pink': '#d90166',
|
| 203 |
+
'deep sea blue': '#015482',
|
| 204 |
+
'carmine': '#9d0216',
|
| 205 |
+
'dark yellow green': '#728f02',
|
| 206 |
+
'pale peach': '#ffe5ad',
|
| 207 |
+
'plum purple': '#4e0550',
|
| 208 |
+
'golden rod': '#f9bc08',
|
| 209 |
+
'neon red': '#ff073a',
|
| 210 |
+
'old pink': '#c77986',
|
| 211 |
+
'very pale blue': '#d6fffe',
|
| 212 |
+
'blood orange': '#fe4b03',
|
| 213 |
+
'grapefruit': '#fd5956',
|
| 214 |
+
'sand yellow': '#fce166',
|
| 215 |
+
'clay brown': '#b2713d',
|
| 216 |
+
'dark blue grey': '#1f3b4d',
|
| 217 |
+
'flat green': '#699d4c',
|
| 218 |
+
'light green blue': '#56fca2',
|
| 219 |
+
'warm pink': '#fb5581',
|
| 220 |
+
'dodger blue': '#3e82fc',
|
| 221 |
+
'gross green': '#a0bf16',
|
| 222 |
+
'ice': '#d6fffa',
|
| 223 |
+
'metallic blue': '#4f738e',
|
| 224 |
+
'pale salmon': '#ffb19a',
|
| 225 |
+
'sap green': '#5c8b15',
|
| 226 |
+
'algae': '#54ac68',
|
| 227 |
+
'bluey grey': '#89a0b0',
|
| 228 |
+
'greeny grey': '#7ea07a',
|
| 229 |
+
'highlighter green': '#1bfc06',
|
| 230 |
+
'light light blue': '#cafffb',
|
| 231 |
+
'light mint': '#b6ffbb',
|
| 232 |
+
'raw umber': '#a75e09',
|
| 233 |
+
'vivid blue': '#152eff',
|
| 234 |
+
'deep lavender': '#8d5eb7',
|
| 235 |
+
'dull teal': '#5f9e8f',
|
| 236 |
+
'light greenish blue': '#63f7b4',
|
| 237 |
+
'mud green': '#606602',
|
| 238 |
+
'pinky': '#fc86aa',
|
| 239 |
+
'red wine': '#8c0034',
|
| 240 |
+
'shit green': '#758000',
|
| 241 |
+
'tan brown': '#ab7e4c',
|
| 242 |
+
'darkblue': '#030764',
|
| 243 |
+
'rosa': '#fe86a4',
|
| 244 |
+
'lipstick': '#d5174e',
|
| 245 |
+
'pale mauve': '#fed0fc',
|
| 246 |
+
'claret': '#680018',
|
| 247 |
+
'dandelion': '#fedf08',
|
| 248 |
+
'orangered': '#fe420f',
|
| 249 |
+
'poop green': '#6f7c00',
|
| 250 |
+
'ruby': '#ca0147',
|
| 251 |
+
'dark': '#1b2431',
|
| 252 |
+
'greenish turquoise': '#00fbb0',
|
| 253 |
+
'pastel red': '#db5856',
|
| 254 |
+
'piss yellow': '#ddd618',
|
| 255 |
+
'bright cyan': '#41fdfe',
|
| 256 |
+
'dark coral': '#cf524e',
|
| 257 |
+
'algae green': '#21c36f',
|
| 258 |
+
'darkish red': '#a90308',
|
| 259 |
+
'reddy brown': '#6e1005',
|
| 260 |
+
'blush pink': '#fe828c',
|
| 261 |
+
'camouflage green': '#4b6113',
|
| 262 |
+
'lawn green': '#4da409',
|
| 263 |
+
'putty': '#beae8a',
|
| 264 |
+
'vibrant blue': '#0339f8',
|
| 265 |
+
'dark sand': '#a88f59',
|
| 266 |
+
'purple/blue': '#5d21d0',
|
| 267 |
+
'saffron': '#feb209',
|
| 268 |
+
'twilight': '#4e518b',
|
| 269 |
+
'warm brown': '#964e02',
|
| 270 |
+
'bluegrey': '#85a3b2',
|
| 271 |
+
'bubble gum pink': '#ff69af',
|
| 272 |
+
'duck egg blue': '#c3fbf4',
|
| 273 |
+
'greenish cyan': '#2afeb7',
|
| 274 |
+
'petrol': '#005f6a',
|
| 275 |
+
'royal': '#0c1793',
|
| 276 |
+
'butter': '#ffff81',
|
| 277 |
+
'dusty orange': '#f0833a',
|
| 278 |
+
'off yellow': '#f1f33f',
|
| 279 |
+
'pale olive green': '#b1d27b',
|
| 280 |
+
'orangish': '#fc824a',
|
| 281 |
+
'leaf': '#71aa34',
|
| 282 |
+
'light blue grey': '#b7c9e2',
|
| 283 |
+
'dried blood': '#4b0101',
|
| 284 |
+
'lightish purple': '#a552e6',
|
| 285 |
+
'rusty red': '#af2f0d',
|
| 286 |
+
'lavender blue': '#8b88f8',
|
| 287 |
+
'light grass green': '#9af764',
|
| 288 |
+
'light mint green': '#a6fbb2',
|
| 289 |
+
'sunflower': '#ffc512',
|
| 290 |
+
'velvet': '#750851',
|
| 291 |
+
'brick orange': '#c14a09',
|
| 292 |
+
'lightish red': '#fe2f4a',
|
| 293 |
+
'pure blue': '#0203e2',
|
| 294 |
+
'twilight blue': '#0a437a',
|
| 295 |
+
'violet red': '#a50055',
|
| 296 |
+
'yellowy brown': '#ae8b0c',
|
| 297 |
+
'carnation': '#fd798f',
|
| 298 |
+
'muddy yellow': '#bfac05',
|
| 299 |
+
'dark seafoam green': '#3eaf76',
|
| 300 |
+
'deep rose': '#c74767',
|
| 301 |
+
'dusty red': '#b9484e',
|
| 302 |
+
'grey/blue': '#647d8e',
|
| 303 |
+
'lemon lime': '#bffe28',
|
| 304 |
+
'purple/pink': '#d725de',
|
| 305 |
+
'brown yellow': '#b29705',
|
| 306 |
+
'purple brown': '#673a3f',
|
| 307 |
+
'wisteria': '#a87dc2',
|
| 308 |
+
'banana yellow': '#fafe4b',
|
| 309 |
+
'lipstick red': '#c0022f',
|
| 310 |
+
'water blue': '#0e87cc',
|
| 311 |
+
'brown grey': '#8d8468',
|
| 312 |
+
'vibrant purple': '#ad03de',
|
| 313 |
+
'baby green': '#8cff9e',
|
| 314 |
+
'barf green': '#94ac02',
|
| 315 |
+
'eggshell blue': '#c4fff7',
|
| 316 |
+
'sandy yellow': '#fdee73',
|
| 317 |
+
'cool green': '#33b864',
|
| 318 |
+
'pale': '#fff9d0',
|
| 319 |
+
'blue/grey': '#758da3',
|
| 320 |
+
'hot magenta': '#f504c9',
|
| 321 |
+
'greyblue': '#77a1b5',
|
| 322 |
+
'purpley': '#8756e4',
|
| 323 |
+
'baby shit green': '#889717',
|
| 324 |
+
'brownish pink': '#c27e79',
|
| 325 |
+
'dark aquamarine': '#017371',
|
| 326 |
+
'diarrhea': '#9f8303',
|
| 327 |
+
'light mustard': '#f7d560',
|
| 328 |
+
'pale sky blue': '#bdf6fe',
|
| 329 |
+
'turtle green': '#75b84f',
|
| 330 |
+
'bright olive': '#9cbb04',
|
| 331 |
+
'dark grey blue': '#29465b',
|
| 332 |
+
'greeny brown': '#696006',
|
| 333 |
+
'lemon green': '#adf802',
|
| 334 |
+
'light periwinkle': '#c1c6fc',
|
| 335 |
+
'seaweed green': '#35ad6b',
|
| 336 |
+
'sunshine yellow': '#fffd37',
|
| 337 |
+
'ugly purple': '#a442a0',
|
| 338 |
+
'medium pink': '#f36196',
|
| 339 |
+
'puke brown': '#947706',
|
| 340 |
+
'very light pink': '#fff4f2',
|
| 341 |
+
'viridian': '#1e9167',
|
| 342 |
+
'bile': '#b5c306',
|
| 343 |
+
'faded yellow': '#feff7f',
|
| 344 |
+
'very pale green': '#cffdbc',
|
| 345 |
+
'vibrant green': '#0add08',
|
| 346 |
+
'bright lime': '#87fd05',
|
| 347 |
+
'spearmint': '#1ef876',
|
| 348 |
+
'light aquamarine': '#7bfdc7',
|
| 349 |
+
'light sage': '#bcecac',
|
| 350 |
+
'yellowgreen': '#bbf90f',
|
| 351 |
+
'baby poo': '#ab9004',
|
| 352 |
+
'dark seafoam': '#1fb57a',
|
| 353 |
+
'deep teal': '#00555a',
|
| 354 |
+
'heather': '#a484ac',
|
| 355 |
+
'rust orange': '#c45508',
|
| 356 |
+
'dirty blue': '#3f829d',
|
| 357 |
+
'fern green': '#548d44',
|
| 358 |
+
'bright lilac': '#c95efb',
|
| 359 |
+
'weird green': '#3ae57f',
|
| 360 |
+
'peacock blue': '#016795',
|
| 361 |
+
'avocado green': '#87a922',
|
| 362 |
+
'faded orange': '#f0944d',
|
| 363 |
+
'grape purple': '#5d1451',
|
| 364 |
+
'hot green': '#25ff29',
|
| 365 |
+
'lime yellow': '#d0fe1d',
|
| 366 |
+
'mango': '#ffa62b',
|
| 367 |
+
'shamrock': '#01b44c',
|
| 368 |
+
'bubblegum': '#ff6cb5',
|
| 369 |
+
'purplish brown': '#6b4247',
|
| 370 |
+
'vomit yellow': '#c7c10c',
|
| 371 |
+
'pale cyan': '#b7fffa',
|
| 372 |
+
'key lime': '#aeff6e',
|
| 373 |
+
'tomato red': '#ec2d01',
|
| 374 |
+
'lightgreen': '#76ff7b',
|
| 375 |
+
'merlot': '#730039',
|
| 376 |
+
'night blue': '#040348',
|
| 377 |
+
'purpleish pink': '#df4ec8',
|
| 378 |
+
'apple': '#6ecb3c',
|
| 379 |
+
'baby poop green': '#8f9805',
|
| 380 |
+
'green apple': '#5edc1f',
|
| 381 |
+
'heliotrope': '#d94ff5',
|
| 382 |
+
'yellow/green': '#c8fd3d',
|
| 383 |
+
'almost black': '#070d0d',
|
| 384 |
+
'cool blue': '#4984b8',
|
| 385 |
+
'leafy green': '#51b73b',
|
| 386 |
+
'mustard brown': '#ac7e04',
|
| 387 |
+
'dusk': '#4e5481',
|
| 388 |
+
'dull brown': '#876e4b',
|
| 389 |
+
'frog green': '#58bc08',
|
| 390 |
+
'vivid green': '#2fef10',
|
| 391 |
+
'bright light green': '#2dfe54',
|
| 392 |
+
'fluro green': '#0aff02',
|
| 393 |
+
'kiwi': '#9cef43',
|
| 394 |
+
'seaweed': '#18d17b',
|
| 395 |
+
'navy green': '#35530a',
|
| 396 |
+
'ultramarine blue': '#1805db',
|
| 397 |
+
'iris': '#6258c4',
|
| 398 |
+
'pastel orange': '#ff964f',
|
| 399 |
+
'yellowish orange': '#ffab0f',
|
| 400 |
+
'perrywinkle': '#8f8ce7',
|
| 401 |
+
'tealish': '#24bca8',
|
| 402 |
+
'dark plum': '#3f012c',
|
| 403 |
+
'pear': '#cbf85f',
|
| 404 |
+
'pinkish orange': '#ff724c',
|
| 405 |
+
'midnight purple': '#280137',
|
| 406 |
+
'light urple': '#b36ff6',
|
| 407 |
+
'dark mint': '#48c072',
|
| 408 |
+
'greenish tan': '#bccb7a',
|
| 409 |
+
'light burgundy': '#a8415b',
|
| 410 |
+
'turquoise blue': '#06b1c4',
|
| 411 |
+
'ugly pink': '#cd7584',
|
| 412 |
+
'sandy': '#f1da7a',
|
| 413 |
+
'electric pink': '#ff0490',
|
| 414 |
+
'muted purple': '#805b87',
|
| 415 |
+
'mid green': '#50a747',
|
| 416 |
+
'greyish': '#a8a495',
|
| 417 |
+
'neon yellow': '#cfff04',
|
| 418 |
+
'banana': '#ffff7e',
|
| 419 |
+
'carnation pink': '#ff7fa7',
|
| 420 |
+
'tomato': '#ef4026',
|
| 421 |
+
'sea': '#3c9992',
|
| 422 |
+
'muddy brown': '#886806',
|
| 423 |
+
'turquoise green': '#04f489',
|
| 424 |
+
'buff': '#fef69e',
|
| 425 |
+
'fawn': '#cfaf7b',
|
| 426 |
+
'muted blue': '#3b719f',
|
| 427 |
+
'pale rose': '#fdc1c5',
|
| 428 |
+
'dark mint green': '#20c073',
|
| 429 |
+
'amethyst': '#9b5fc0',
|
| 430 |
+
'blue/green': '#0f9b8e',
|
| 431 |
+
'chestnut': '#742802',
|
| 432 |
+
'sick green': '#9db92c',
|
| 433 |
+
'pea': '#a4bf20',
|
| 434 |
+
'rusty orange': '#cd5909',
|
| 435 |
+
'stone': '#ada587',
|
| 436 |
+
'rose red': '#be013c',
|
| 437 |
+
'pale aqua': '#b8ffeb',
|
| 438 |
+
'deep orange': '#dc4d01',
|
| 439 |
+
'earth': '#a2653e',
|
| 440 |
+
'mossy green': '#638b27',
|
| 441 |
+
'grassy green': '#419c03',
|
| 442 |
+
'pale lime green': '#b1ff65',
|
| 443 |
+
'light grey blue': '#9dbcd4',
|
| 444 |
+
'pale grey': '#fdfdfe',
|
| 445 |
+
'asparagus': '#77ab56',
|
| 446 |
+
'blueberry': '#464196',
|
| 447 |
+
'purple red': '#990147',
|
| 448 |
+
'pale lime': '#befd73',
|
| 449 |
+
'greenish teal': '#32bf84',
|
| 450 |
+
'caramel': '#af6f09',
|
| 451 |
+
'deep magenta': '#a0025c',
|
| 452 |
+
'light peach': '#ffd8b1',
|
| 453 |
+
'milk chocolate': '#7f4e1e',
|
| 454 |
+
'ocher': '#bf9b0c',
|
| 455 |
+
'off green': '#6ba353',
|
| 456 |
+
'purply pink': '#f075e6',
|
| 457 |
+
'lightblue': '#7bc8f6',
|
| 458 |
+
'dusky blue': '#475f94',
|
| 459 |
+
'golden': '#f5bf03',
|
| 460 |
+
'light beige': '#fffeb6',
|
| 461 |
+
'butter yellow': '#fffd74',
|
| 462 |
+
'dusky purple': '#895b7b',
|
| 463 |
+
'french blue': '#436bad',
|
| 464 |
+
'ugly yellow': '#d0c101',
|
| 465 |
+
'greeny yellow': '#c6f808',
|
| 466 |
+
'orangish red': '#f43605',
|
| 467 |
+
'shamrock green': '#02c14d',
|
| 468 |
+
'orangish brown': '#b25f03',
|
| 469 |
+
'tree green': '#2a7e19',
|
| 470 |
+
'deep violet': '#490648',
|
| 471 |
+
'gunmetal': '#536267',
|
| 472 |
+
'blue/purple': '#5a06ef',
|
| 473 |
+
'cherry': '#cf0234',
|
| 474 |
+
'sandy brown': '#c4a661',
|
| 475 |
+
'warm grey': '#978a84',
|
| 476 |
+
'dark indigo': '#1f0954',
|
| 477 |
+
'midnight': '#03012d',
|
| 478 |
+
'bluey green': '#2bb179',
|
| 479 |
+
'grey pink': '#c3909b',
|
| 480 |
+
'soft purple': '#a66fb5',
|
| 481 |
+
'blood': '#770001',
|
| 482 |
+
'brown red': '#922b05',
|
| 483 |
+
'medium grey': '#7d7f7c',
|
| 484 |
+
'berry': '#990f4b',
|
| 485 |
+
'poo': '#8f7303',
|
| 486 |
+
'purpley pink': '#c83cb9',
|
| 487 |
+
'light salmon': '#fea993',
|
| 488 |
+
'snot': '#acbb0d',
|
| 489 |
+
'easter purple': '#c071fe',
|
| 490 |
+
'light yellow green': '#ccfd7f',
|
| 491 |
+
'dark navy blue': '#00022e',
|
| 492 |
+
'drab': '#828344',
|
| 493 |
+
'light rose': '#ffc5cb',
|
| 494 |
+
'rouge': '#ab1239',
|
| 495 |
+
'purplish red': '#b0054b',
|
| 496 |
+
'slime green': '#99cc04',
|
| 497 |
+
'baby poop': '#937c00',
|
| 498 |
+
'irish green': '#019529',
|
| 499 |
+
'pink/purple': '#ef1de7',
|
| 500 |
+
'dark navy': '#000435',
|
| 501 |
+
'greeny blue': '#42b395',
|
| 502 |
+
'light plum': '#9d5783',
|
| 503 |
+
'pinkish grey': '#c8aca9',
|
| 504 |
+
'dirty orange': '#c87606',
|
| 505 |
+
'rust red': '#aa2704',
|
| 506 |
+
'pale lilac': '#e4cbff',
|
| 507 |
+
'orangey red': '#fa4224',
|
| 508 |
+
'primary blue': '#0804f9',
|
| 509 |
+
'kermit green': '#5cb200',
|
| 510 |
+
'brownish purple': '#76424e',
|
| 511 |
+
'murky green': '#6c7a0e',
|
| 512 |
+
'wheat': '#fbdd7e',
|
| 513 |
+
'very dark purple': '#2a0134',
|
| 514 |
+
'bottle green': '#044a05',
|
| 515 |
+
'watermelon': '#fd4659',
|
| 516 |
+
'deep sky blue': '#0d75f8',
|
| 517 |
+
'fire engine red': '#fe0002',
|
| 518 |
+
'yellow ochre': '#cb9d06',
|
| 519 |
+
'pumpkin orange': '#fb7d07',
|
| 520 |
+
'pale olive': '#b9cc81',
|
| 521 |
+
'light lilac': '#edc8ff',
|
| 522 |
+
'lightish green': '#61e160',
|
| 523 |
+
'carolina blue': '#8ab8fe',
|
| 524 |
+
'mulberry': '#920a4e',
|
| 525 |
+
'shocking pink': '#fe02a2',
|
| 526 |
+
'auburn': '#9a3001',
|
| 527 |
+
'bright lime green': '#65fe08',
|
| 528 |
+
'celadon': '#befdb7',
|
| 529 |
+
'pinkish brown': '#b17261',
|
| 530 |
+
'poo brown': '#885f01',
|
| 531 |
+
'bright sky blue': '#02ccfe',
|
| 532 |
+
'celery': '#c1fd95',
|
| 533 |
+
'dirt brown': '#836539',
|
| 534 |
+
'strawberry': '#fb2943',
|
| 535 |
+
'dark lime': '#84b701',
|
| 536 |
+
'copper': '#b66325',
|
| 537 |
+
'medium brown': '#7f5112',
|
| 538 |
+
'muted green': '#5fa052',
|
| 539 |
+
"robin's egg": '#6dedfd',
|
| 540 |
+
'bright aqua': '#0bf9ea',
|
| 541 |
+
'bright lavender': '#c760ff',
|
| 542 |
+
'ivory': '#ffffcb',
|
| 543 |
+
'very light purple': '#f6cefc',
|
| 544 |
+
'light navy': '#155084',
|
| 545 |
+
'pink red': '#f5054f',
|
| 546 |
+
'olive brown': '#645403',
|
| 547 |
+
'poop brown': '#7a5901',
|
| 548 |
+
'mustard green': '#a8b504',
|
| 549 |
+
'ocean green': '#3d9973',
|
| 550 |
+
'very dark blue': '#000133',
|
| 551 |
+
'dusty green': '#76a973',
|
| 552 |
+
'light navy blue': '#2e5a88',
|
| 553 |
+
'minty green': '#0bf77d',
|
| 554 |
+
'adobe': '#bd6c48',
|
| 555 |
+
'barney': '#ac1db8',
|
| 556 |
+
'jade green': '#2baf6a',
|
| 557 |
+
'bright light blue': '#26f7fd',
|
| 558 |
+
'light lime': '#aefd6c',
|
| 559 |
+
'dark khaki': '#9b8f55',
|
| 560 |
+
'orange yellow': '#ffad01',
|
| 561 |
+
'ocre': '#c69c04',
|
| 562 |
+
'maize': '#f4d054',
|
| 563 |
+
'faded pink': '#de9dac',
|
| 564 |
+
'british racing green': '#05480d',
|
| 565 |
+
'sandstone': '#c9ae74',
|
| 566 |
+
'mud brown': '#60460f',
|
| 567 |
+
'light sea green': '#98f6b0',
|
| 568 |
+
'robin egg blue': '#8af1fe',
|
| 569 |
+
'aqua marine': '#2ee8bb',
|
| 570 |
+
'dark sea green': '#11875d',
|
| 571 |
+
'soft pink': '#fdb0c0',
|
| 572 |
+
'orangey brown': '#b16002',
|
| 573 |
+
'cherry red': '#f7022a',
|
| 574 |
+
'burnt yellow': '#d5ab09',
|
| 575 |
+
'brownish grey': '#86775f',
|
| 576 |
+
'camel': '#c69f59',
|
| 577 |
+
'purplish grey': '#7a687f',
|
| 578 |
+
'marine': '#042e60',
|
| 579 |
+
'greyish pink': '#c88d94',
|
| 580 |
+
'pale turquoise': '#a5fbd5',
|
| 581 |
+
'pastel yellow': '#fffe71',
|
| 582 |
+
'bluey purple': '#6241c7',
|
| 583 |
+
'canary yellow': '#fffe40',
|
| 584 |
+
'faded red': '#d3494e',
|
| 585 |
+
'sepia': '#985e2b',
|
| 586 |
+
'coffee': '#a6814c',
|
| 587 |
+
'bright magenta': '#ff08e8',
|
| 588 |
+
'mocha': '#9d7651',
|
| 589 |
+
'ecru': '#feffca',
|
| 590 |
+
'purpleish': '#98568d',
|
| 591 |
+
'cranberry': '#9e003a',
|
| 592 |
+
'darkish green': '#287c37',
|
| 593 |
+
'brown orange': '#b96902',
|
| 594 |
+
'dusky rose': '#ba6873',
|
| 595 |
+
'melon': '#ff7855',
|
| 596 |
+
'sickly green': '#94b21c',
|
| 597 |
+
'silver': '#c5c9c7',
|
| 598 |
+
'purply blue': '#661aee',
|
| 599 |
+
'purpleish blue': '#6140ef',
|
| 600 |
+
'hospital green': '#9be5aa',
|
| 601 |
+
'shit brown': '#7b5804',
|
| 602 |
+
'mid blue': '#276ab3',
|
| 603 |
+
'amber': '#feb308',
|
| 604 |
+
'easter green': '#8cfd7e',
|
| 605 |
+
'soft blue': '#6488ea',
|
| 606 |
+
'cerulean blue': '#056eee',
|
| 607 |
+
'golden brown': '#b27a01',
|
| 608 |
+
'bright turquoise': '#0ffef9',
|
| 609 |
+
'red pink': '#fa2a55',
|
| 610 |
+
'red purple': '#820747',
|
| 611 |
+
'greyish brown': '#7a6a4f',
|
| 612 |
+
'vermillion': '#f4320c',
|
| 613 |
+
'russet': '#a13905',
|
| 614 |
+
'steel grey': '#6f828a',
|
| 615 |
+
'lighter purple': '#a55af4',
|
| 616 |
+
'bright violet': '#ad0afd',
|
| 617 |
+
'prussian blue': '#004577',
|
| 618 |
+
'slate green': '#658d6d',
|
| 619 |
+
'dirty pink': '#ca7b80',
|
| 620 |
+
'dark blue green': '#005249',
|
| 621 |
+
'pine': '#2b5d34',
|
| 622 |
+
'yellowy green': '#bff128',
|
| 623 |
+
'dark gold': '#b59410',
|
| 624 |
+
'bluish': '#2976bb',
|
| 625 |
+
'darkish blue': '#014182',
|
| 626 |
+
'dull red': '#bb3f3f',
|
| 627 |
+
'pinky red': '#fc2647',
|
| 628 |
+
'bronze': '#a87900',
|
| 629 |
+
'pale teal': '#82cbb2',
|
| 630 |
+
'military green': '#667c3e',
|
| 631 |
+
'barbie pink': '#fe46a5',
|
| 632 |
+
'bubblegum pink': '#fe83cc',
|
| 633 |
+
'pea soup green': '#94a617',
|
| 634 |
+
'dark mustard': '#a88905',
|
| 635 |
+
'shit': '#7f5f00',
|
| 636 |
+
'medium purple': '#9e43a2',
|
| 637 |
+
'very dark green': '#062e03',
|
| 638 |
+
'dirt': '#8a6e45',
|
| 639 |
+
'dusky pink': '#cc7a8b',
|
| 640 |
+
'red violet': '#9e0168',
|
| 641 |
+
'lemon yellow': '#fdff38',
|
| 642 |
+
'pistachio': '#c0fa8b',
|
| 643 |
+
'dull yellow': '#eedc5b',
|
| 644 |
+
'dark lime green': '#7ebd01',
|
| 645 |
+
'denim blue': '#3b5b92',
|
| 646 |
+
'teal blue': '#01889f',
|
| 647 |
+
'lightish blue': '#3d7afd',
|
| 648 |
+
'purpley blue': '#5f34e7',
|
| 649 |
+
'light indigo': '#6d5acf',
|
| 650 |
+
'swamp green': '#748500',
|
| 651 |
+
'brown green': '#706c11',
|
| 652 |
+
'dark maroon': '#3c0008',
|
| 653 |
+
'hot purple': '#cb00f5',
|
| 654 |
+
'dark forest green': '#002d04',
|
| 655 |
+
'faded blue': '#658cbb',
|
| 656 |
+
'drab green': '#749551',
|
| 657 |
+
'light lime green': '#b9ff66',
|
| 658 |
+
'snot green': '#9dc100',
|
| 659 |
+
'yellowish': '#faee66',
|
| 660 |
+
'light blue green': '#7efbb3',
|
| 661 |
+
'bordeaux': '#7b002c',
|
| 662 |
+
'light mauve': '#c292a1',
|
| 663 |
+
'ocean': '#017b92',
|
| 664 |
+
'marigold': '#fcc006',
|
| 665 |
+
'muddy green': '#657432',
|
| 666 |
+
'dull orange': '#d8863b',
|
| 667 |
+
'steel': '#738595',
|
| 668 |
+
'electric purple': '#aa23ff',
|
| 669 |
+
'fluorescent green': '#08ff08',
|
| 670 |
+
'yellowish brown': '#9b7a01',
|
| 671 |
+
'blush': '#f29e8e',
|
| 672 |
+
'soft green': '#6fc276',
|
| 673 |
+
'bright orange': '#ff5b00',
|
| 674 |
+
'lemon': '#fdff52',
|
| 675 |
+
'purple grey': '#866f85',
|
| 676 |
+
'acid green': '#8ffe09',
|
| 677 |
+
'pale lavender': '#eecffe',
|
| 678 |
+
'violet blue': '#510ac9',
|
| 679 |
+
'light forest green': '#4f9153',
|
| 680 |
+
'burnt red': '#9f2305',
|
| 681 |
+
'khaki green': '#728639',
|
| 682 |
+
'cerise': '#de0c62',
|
| 683 |
+
'faded purple': '#916e99',
|
| 684 |
+
'apricot': '#ffb16d',
|
| 685 |
+
'dark olive green': '#3c4d03',
|
| 686 |
+
'grey brown': '#7f7053',
|
| 687 |
+
'green grey': '#77926f',
|
| 688 |
+
'true blue': '#010fcc',
|
| 689 |
+
'pale violet': '#ceaefa',
|
| 690 |
+
'periwinkle blue': '#8f99fb',
|
| 691 |
+
'light sky blue': '#c6fcff',
|
| 692 |
+
'blurple': '#5539cc',
|
| 693 |
+
'green brown': '#544e03',
|
| 694 |
+
'bluegreen': '#017a79',
|
| 695 |
+
'bright teal': '#01f9c6',
|
| 696 |
+
'brownish yellow': '#c9b003',
|
| 697 |
+
'pea soup': '#929901',
|
| 698 |
+
'forest': '#0b5509',
|
| 699 |
+
'barney purple': '#a00498',
|
| 700 |
+
'ultramarine': '#2000b1',
|
| 701 |
+
'purplish': '#94568c',
|
| 702 |
+
'puke yellow': '#c2be0e',
|
| 703 |
+
'bluish grey': '#748b97',
|
| 704 |
+
'dark periwinkle': '#665fd1',
|
| 705 |
+
'dark lilac': '#9c6da5',
|
| 706 |
+
'reddish': '#c44240',
|
| 707 |
+
'light maroon': '#a24857',
|
| 708 |
+
'dusty purple': '#825f87',
|
| 709 |
+
'terra cotta': '#c9643b',
|
| 710 |
+
'avocado': '#90b134',
|
| 711 |
+
'marine blue': '#01386a',
|
| 712 |
+
'teal green': '#25a36f',
|
| 713 |
+
'slate grey': '#59656d',
|
| 714 |
+
'lighter green': '#75fd63',
|
| 715 |
+
'electric green': '#21fc0d',
|
| 716 |
+
'dusty blue': '#5a86ad',
|
| 717 |
+
'golden yellow': '#fec615',
|
| 718 |
+
'bright yellow': '#fffd01',
|
| 719 |
+
'light lavender': '#dfc5fe',
|
| 720 |
+
'umber': '#b26400',
|
| 721 |
+
'poop': '#7f5e00',
|
| 722 |
+
'dark peach': '#de7e5d',
|
| 723 |
+
'jungle green': '#048243',
|
| 724 |
+
'eggshell': '#ffffd4',
|
| 725 |
+
'denim': '#3b638c',
|
| 726 |
+
'yellow brown': '#b79400',
|
| 727 |
+
'dull purple': '#84597e',
|
| 728 |
+
'chocolate brown': '#411900',
|
| 729 |
+
'wine red': '#7b0323',
|
| 730 |
+
'neon blue': '#04d9ff',
|
| 731 |
+
'dirty green': '#667e2c',
|
| 732 |
+
'light tan': '#fbeeac',
|
| 733 |
+
'ice blue': '#d7fffe',
|
| 734 |
+
'cadet blue': '#4e7496',
|
| 735 |
+
'dark mauve': '#874c62',
|
| 736 |
+
'very light blue': '#d5ffff',
|
| 737 |
+
'grey purple': '#826d8c',
|
| 738 |
+
'pastel pink': '#ffbacd',
|
| 739 |
+
'very light green': '#d1ffbd',
|
| 740 |
+
'dark sky blue': '#448ee4',
|
| 741 |
+
'evergreen': '#05472a',
|
| 742 |
+
'dull pink': '#d5869d',
|
| 743 |
+
'aubergine': '#3d0734',
|
| 744 |
+
'mahogany': '#4a0100',
|
| 745 |
+
'reddish orange': '#f8481c',
|
| 746 |
+
'deep green': '#02590f',
|
| 747 |
+
'vomit green': '#89a203',
|
| 748 |
+
'purple pink': '#e03fd8',
|
| 749 |
+
'dusty pink': '#d58a94',
|
| 750 |
+
'faded green': '#7bb274',
|
| 751 |
+
'camo green': '#526525',
|
| 752 |
+
'pinky purple': '#c94cbe',
|
| 753 |
+
'pink purple': '#db4bda',
|
| 754 |
+
'brownish red': '#9e3623',
|
| 755 |
+
'dark rose': '#b5485d',
|
| 756 |
+
'mud': '#735c12',
|
| 757 |
+
'brownish': '#9c6d57',
|
| 758 |
+
'emerald green': '#028f1e',
|
| 759 |
+
'pale brown': '#b1916e',
|
| 760 |
+
'dull blue': '#49759c',
|
| 761 |
+
'burnt umber': '#a0450e',
|
| 762 |
+
'medium green': '#39ad48',
|
| 763 |
+
'clay': '#b66a50',
|
| 764 |
+
'light aqua': '#8cffdb',
|
| 765 |
+
'light olive green': '#a4be5c',
|
| 766 |
+
'brownish orange': '#cb7723',
|
| 767 |
+
'dark aqua': '#05696b',
|
| 768 |
+
'purplish pink': '#ce5dae',
|
| 769 |
+
'dark salmon': '#c85a53',
|
| 770 |
+
'greenish grey': '#96ae8d',
|
| 771 |
+
'jade': '#1fa774',
|
| 772 |
+
'ugly green': '#7a9703',
|
| 773 |
+
'dark beige': '#ac9362',
|
| 774 |
+
'emerald': '#01a049',
|
| 775 |
+
'pale red': '#d9544d',
|
| 776 |
+
'light magenta': '#fa5ff7',
|
| 777 |
+
'sky': '#82cafc',
|
| 778 |
+
'light cyan': '#acfffc',
|
| 779 |
+
'yellow orange': '#fcb001',
|
| 780 |
+
'reddish purple': '#910951',
|
| 781 |
+
'reddish pink': '#fe2c54',
|
| 782 |
+
'orchid': '#c875c4',
|
| 783 |
+
'dirty yellow': '#cdc50a',
|
| 784 |
+
'orange red': '#fd411e',
|
| 785 |
+
'deep red': '#9a0200',
|
| 786 |
+
'orange brown': '#be6400',
|
| 787 |
+
'cobalt blue': '#030aa7',
|
| 788 |
+
'neon pink': '#fe019a',
|
| 789 |
+
'rose pink': '#f7879a',
|
| 790 |
+
'greyish purple': '#887191',
|
| 791 |
+
'raspberry': '#b00149',
|
| 792 |
+
'aqua green': '#12e193',
|
| 793 |
+
'salmon pink': '#fe7b7c',
|
| 794 |
+
'tangerine': '#ff9408',
|
| 795 |
+
'brownish green': '#6a6e09',
|
| 796 |
+
'red brown': '#8b2e16',
|
| 797 |
+
'greenish brown': '#696112',
|
| 798 |
+
'pumpkin': '#e17701',
|
| 799 |
+
'pine green': '#0a481e',
|
| 800 |
+
'charcoal': '#343837',
|
| 801 |
+
'baby pink': '#ffb7ce',
|
| 802 |
+
'cornflower': '#6a79f7',
|
| 803 |
+
'blue violet': '#5d06e9',
|
| 804 |
+
'chocolate': '#3d1c02',
|
| 805 |
+
'greyish green': '#82a67d',
|
| 806 |
+
'scarlet': '#be0119',
|
| 807 |
+
'green yellow': '#c9ff27',
|
| 808 |
+
'dark olive': '#373e02',
|
| 809 |
+
'sienna': '#a9561e',
|
| 810 |
+
'pastel purple': '#caa0ff',
|
| 811 |
+
'terracotta': '#ca6641',
|
| 812 |
+
'aqua blue': '#02d8e9',
|
| 813 |
+
'sage green': '#88b378',
|
| 814 |
+
'blood red': '#980002',
|
| 815 |
+
'deep pink': '#cb0162',
|
| 816 |
+
'grass': '#5cac2d',
|
| 817 |
+
'moss': '#769958',
|
| 818 |
+
'pastel blue': '#a2bffe',
|
| 819 |
+
'bluish green': '#10a674',
|
| 820 |
+
'green blue': '#06b48b',
|
| 821 |
+
'dark tan': '#af884a',
|
| 822 |
+
'greenish blue': '#0b8b87',
|
| 823 |
+
'pale orange': '#ffa756',
|
| 824 |
+
'vomit': '#a2a415',
|
| 825 |
+
'forrest green': '#154406',
|
| 826 |
+
'dark lavender': '#856798',
|
| 827 |
+
'dark violet': '#34013f',
|
| 828 |
+
'purple blue': '#632de9',
|
| 829 |
+
'dark cyan': '#0a888a',
|
| 830 |
+
'olive drab': '#6f7632',
|
| 831 |
+
'pinkish': '#d46a7e',
|
| 832 |
+
'cobalt': '#1e488f',
|
| 833 |
+
'neon purple': '#bc13fe',
|
| 834 |
+
'light turquoise': '#7ef4cc',
|
| 835 |
+
'apple green': '#76cd26',
|
| 836 |
+
'dull green': '#74a662',
|
| 837 |
+
'wine': '#80013f',
|
| 838 |
+
'powder blue': '#b1d1fc',
|
| 839 |
+
'off white': '#ffffe4',
|
| 840 |
+
'electric blue': '#0652ff',
|
| 841 |
+
'dark turquoise': '#045c5a',
|
| 842 |
+
'blue purple': '#5729ce',
|
| 843 |
+
'azure': '#069af3',
|
| 844 |
+
'bright red': '#ff000d',
|
| 845 |
+
'pinkish red': '#f10c45',
|
| 846 |
+
'cornflower blue': '#5170d7',
|
| 847 |
+
'light olive': '#acbf69',
|
| 848 |
+
'grape': '#6c3461',
|
| 849 |
+
'greyish blue': '#5e819d',
|
| 850 |
+
'purplish blue': '#601ef9',
|
| 851 |
+
'yellowish green': '#b0dd16',
|
| 852 |
+
'greenish yellow': '#cdfd02',
|
| 853 |
+
'medium blue': '#2c6fbb',
|
| 854 |
+
'dusty rose': '#c0737a',
|
| 855 |
+
'light violet': '#d6b4fc',
|
| 856 |
+
'midnight blue': '#020035',
|
| 857 |
+
'bluish purple': '#703be7',
|
| 858 |
+
'red orange': '#fd3c06',
|
| 859 |
+
'dark magenta': '#960056',
|
| 860 |
+
'greenish': '#40a368',
|
| 861 |
+
'ocean blue': '#03719c',
|
| 862 |
+
'coral': '#fc5a50',
|
| 863 |
+
'cream': '#ffffc2',
|
| 864 |
+
'reddish brown': '#7f2b0a',
|
| 865 |
+
'burnt sienna': '#b04e0f',
|
| 866 |
+
'brick': '#a03623',
|
| 867 |
+
'sage': '#87ae73',
|
| 868 |
+
'grey green': '#789b73',
|
| 869 |
+
'white': '#ffffff',
|
| 870 |
+
"robin's egg blue": '#98eff9',
|
| 871 |
+
'moss green': '#658b38',
|
| 872 |
+
'steel blue': '#5a7d9a',
|
| 873 |
+
'eggplant': '#380835',
|
| 874 |
+
'light yellow': '#fffe7a',
|
| 875 |
+
'leaf green': '#5ca904',
|
| 876 |
+
'light grey': '#d8dcd6',
|
| 877 |
+
'puke': '#a5a502',
|
| 878 |
+
'pinkish purple': '#d648d7',
|
| 879 |
+
'sea blue': '#047495',
|
| 880 |
+
'pale purple': '#b790d4',
|
| 881 |
+
'slate blue': '#5b7c99',
|
| 882 |
+
'blue grey': '#607c8e',
|
| 883 |
+
'hunter green': '#0b4008',
|
| 884 |
+
'fuchsia': '#ed0dd9',
|
| 885 |
+
'crimson': '#8c000f',
|
| 886 |
+
'pale yellow': '#ffff84',
|
| 887 |
+
'ochre': '#bf9005',
|
| 888 |
+
'mustard yellow': '#d2bd0a',
|
| 889 |
+
'light red': '#ff474c',
|
| 890 |
+
'cerulean': '#0485d1',
|
| 891 |
+
'pale pink': '#ffcfdc',
|
| 892 |
+
'deep blue': '#040273',
|
| 893 |
+
'rust': '#a83c09',
|
| 894 |
+
'light teal': '#90e4c1',
|
| 895 |
+
'slate': '#516572',
|
| 896 |
+
'goldenrod': '#fac205',
|
| 897 |
+
'dark yellow': '#d5b60a',
|
| 898 |
+
'dark grey': '#363737',
|
| 899 |
+
'army green': '#4b5d16',
|
| 900 |
+
'grey blue': '#6b8ba4',
|
| 901 |
+
'seafoam': '#80f9ad',
|
| 902 |
+
'puce': '#a57e52',
|
| 903 |
+
'spring green': '#a9f971',
|
| 904 |
+
'dark orange': '#c65102',
|
| 905 |
+
'sand': '#e2ca76',
|
| 906 |
+
'pastel green': '#b0ff9d',
|
| 907 |
+
'mint': '#9ffeb0',
|
| 908 |
+
'light orange': '#fdaa48',
|
| 909 |
+
'bright pink': '#fe01b1',
|
| 910 |
+
'chartreuse': '#c1f80a',
|
| 911 |
+
'deep purple': '#36013f',
|
| 912 |
+
'dark brown': '#341c02',
|
| 913 |
+
'taupe': '#b9a281',
|
| 914 |
+
'pea green': '#8eab12',
|
| 915 |
+
'puke green': '#9aae07',
|
| 916 |
+
'kelly green': '#02ab2e',
|
| 917 |
+
'seafoam green': '#7af9ab',
|
| 918 |
+
'blue green': '#137e6d',
|
| 919 |
+
'khaki': '#aaa662',
|
| 920 |
+
'burgundy': '#610023',
|
| 921 |
+
'dark teal': '#014d4e',
|
| 922 |
+
'brick red': '#8f1402',
|
| 923 |
+
'royal purple': '#4b006e',
|
| 924 |
+
'plum': '#580f41',
|
| 925 |
+
'mint green': '#8fff9f',
|
| 926 |
+
'gold': '#dbb40c',
|
| 927 |
+
'baby blue': '#a2cffe',
|
| 928 |
+
'yellow green': '#c0fb2d',
|
| 929 |
+
'bright purple': '#be03fd',
|
| 930 |
+
'dark red': '#840000',
|
| 931 |
+
'pale blue': '#d0fefe',
|
| 932 |
+
'grass green': '#3f9b0b',
|
| 933 |
+
'navy': '#01153e',
|
| 934 |
+
'aquamarine': '#04d8b2',
|
| 935 |
+
'burnt orange': '#c04e01',
|
| 936 |
+
'neon green': '#0cff0c',
|
| 937 |
+
'bright blue': '#0165fc',
|
| 938 |
+
'rose': '#cf6275',
|
| 939 |
+
'light pink': '#ffd1df',
|
| 940 |
+
'mustard': '#ceb301',
|
| 941 |
+
'indigo': '#380282',
|
| 942 |
+
'lime': '#aaff32',
|
| 943 |
+
'sea green': '#53fca1',
|
| 944 |
+
'periwinkle': '#8e82fe',
|
| 945 |
+
'dark pink': '#cb416b',
|
| 946 |
+
'olive green': '#677a04',
|
| 947 |
+
'peach': '#ffb07c',
|
| 948 |
+
'pale green': '#c7fdb5',
|
| 949 |
+
'light brown': '#ad8150',
|
| 950 |
+
'hot pink': '#ff028d',
|
| 951 |
+
'black': '#000000',
|
| 952 |
+
'lilac': '#cea2fd',
|
| 953 |
+
'navy blue': '#001146',
|
| 954 |
+
'royal blue': '#0504aa',
|
| 955 |
+
'beige': '#e6daa6',
|
| 956 |
+
'salmon': '#ff796c',
|
| 957 |
+
'olive': '#6e750e',
|
| 958 |
+
'maroon': '#650021',
|
| 959 |
+
'bright green': '#01ff07',
|
| 960 |
+
'dark purple': '#35063e',
|
| 961 |
+
'mauve': '#ae7181',
|
| 962 |
+
'forest green': '#06470c',
|
| 963 |
+
'aqua': '#13eac9',
|
| 964 |
+
'cyan': '#00ffff',
|
| 965 |
+
'tan': '#d1b26f',
|
| 966 |
+
'dark blue': '#00035b',
|
| 967 |
+
'lavender': '#c79fef',
|
| 968 |
+
'turquoise': '#06c2ac',
|
| 969 |
+
'dark green': '#033500',
|
| 970 |
+
'violet': '#9a0eea',
|
| 971 |
+
'light purple': '#bf77f6',
|
| 972 |
+
'lime green': '#89fe05',
|
| 973 |
+
'grey': '#929591',
|
| 974 |
+
'sky blue': '#75bbfd',
|
| 975 |
+
'yellow': '#ffff14',
|
| 976 |
+
'magenta': '#c20078',
|
| 977 |
+
'light green': '#96f97b',
|
| 978 |
+
'orange': '#f97306',
|
| 979 |
+
'teal': '#029386',
|
| 980 |
+
'light blue': '#95d0fc',
|
| 981 |
+
'red': '#e50000',
|
| 982 |
+
'brown': '#653700',
|
| 983 |
+
'pink': '#ff81c0',
|
| 984 |
+
'blue': '#0343df',
|
| 985 |
+
'green': '#15b01a',
|
| 986 |
+
'purple': '#7e1e9c'}
|
| 987 |
+
|
| 988 |
+
# Normalize name to "xkcd:<name>" to avoid name collisions.
|
| 989 |
+
XKCD_COLORS = {'xkcd:' + name: value for name, value in XKCD_COLORS.items()}
|
| 990 |
+
|
| 991 |
+
|
| 992 |
+
# https://drafts.csswg.org/css-color-4/#named-colors
|
| 993 |
+
CSS4_COLORS = {
|
| 994 |
+
'aliceblue': '#F0F8FF',
|
| 995 |
+
'antiquewhite': '#FAEBD7',
|
| 996 |
+
'aqua': '#00FFFF',
|
| 997 |
+
'aquamarine': '#7FFFD4',
|
| 998 |
+
'azure': '#F0FFFF',
|
| 999 |
+
'beige': '#F5F5DC',
|
| 1000 |
+
'bisque': '#FFE4C4',
|
| 1001 |
+
'black': '#000000',
|
| 1002 |
+
'blanchedalmond': '#FFEBCD',
|
| 1003 |
+
'blue': '#0000FF',
|
| 1004 |
+
'blueviolet': '#8A2BE2',
|
| 1005 |
+
'brown': '#A52A2A',
|
| 1006 |
+
'burlywood': '#DEB887',
|
| 1007 |
+
'cadetblue': '#5F9EA0',
|
| 1008 |
+
'chartreuse': '#7FFF00',
|
| 1009 |
+
'chocolate': '#D2691E',
|
| 1010 |
+
'coral': '#FF7F50',
|
| 1011 |
+
'cornflowerblue': '#6495ED',
|
| 1012 |
+
'cornsilk': '#FFF8DC',
|
| 1013 |
+
'crimson': '#DC143C',
|
| 1014 |
+
'cyan': '#00FFFF',
|
| 1015 |
+
'darkblue': '#00008B',
|
| 1016 |
+
'darkcyan': '#008B8B',
|
| 1017 |
+
'darkgoldenrod': '#B8860B',
|
| 1018 |
+
'darkgray': '#A9A9A9',
|
| 1019 |
+
'darkgreen': '#006400',
|
| 1020 |
+
'darkgrey': '#A9A9A9',
|
| 1021 |
+
'darkkhaki': '#BDB76B',
|
| 1022 |
+
'darkmagenta': '#8B008B',
|
| 1023 |
+
'darkolivegreen': '#556B2F',
|
| 1024 |
+
'darkorange': '#FF8C00',
|
| 1025 |
+
'darkorchid': '#9932CC',
|
| 1026 |
+
'darkred': '#8B0000',
|
| 1027 |
+
'darksalmon': '#E9967A',
|
| 1028 |
+
'darkseagreen': '#8FBC8F',
|
| 1029 |
+
'darkslateblue': '#483D8B',
|
| 1030 |
+
'darkslategray': '#2F4F4F',
|
| 1031 |
+
'darkslategrey': '#2F4F4F',
|
| 1032 |
+
'darkturquoise': '#00CED1',
|
| 1033 |
+
'darkviolet': '#9400D3',
|
| 1034 |
+
'deeppink': '#FF1493',
|
| 1035 |
+
'deepskyblue': '#00BFFF',
|
| 1036 |
+
'dimgray': '#696969',
|
| 1037 |
+
'dimgrey': '#696969',
|
| 1038 |
+
'dodgerblue': '#1E90FF',
|
| 1039 |
+
'firebrick': '#B22222',
|
| 1040 |
+
'floralwhite': '#FFFAF0',
|
| 1041 |
+
'forestgreen': '#228B22',
|
| 1042 |
+
'fuchsia': '#FF00FF',
|
| 1043 |
+
'gainsboro': '#DCDCDC',
|
| 1044 |
+
'ghostwhite': '#F8F8FF',
|
| 1045 |
+
'gold': '#FFD700',
|
| 1046 |
+
'goldenrod': '#DAA520',
|
| 1047 |
+
'gray': '#808080',
|
| 1048 |
+
'green': '#008000',
|
| 1049 |
+
'greenyellow': '#ADFF2F',
|
| 1050 |
+
'grey': '#808080',
|
| 1051 |
+
'honeydew': '#F0FFF0',
|
| 1052 |
+
'hotpink': '#FF69B4',
|
| 1053 |
+
'indianred': '#CD5C5C',
|
| 1054 |
+
'indigo': '#4B0082',
|
| 1055 |
+
'ivory': '#FFFFF0',
|
| 1056 |
+
'khaki': '#F0E68C',
|
| 1057 |
+
'lavender': '#E6E6FA',
|
| 1058 |
+
'lavenderblush': '#FFF0F5',
|
| 1059 |
+
'lawngreen': '#7CFC00',
|
| 1060 |
+
'lemonchiffon': '#FFFACD',
|
| 1061 |
+
'lightblue': '#ADD8E6',
|
| 1062 |
+
'lightcoral': '#F08080',
|
| 1063 |
+
'lightcyan': '#E0FFFF',
|
| 1064 |
+
'lightgoldenrodyellow': '#FAFAD2',
|
| 1065 |
+
'lightgray': '#D3D3D3',
|
| 1066 |
+
'lightgreen': '#90EE90',
|
| 1067 |
+
'lightgrey': '#D3D3D3',
|
| 1068 |
+
'lightpink': '#FFB6C1',
|
| 1069 |
+
'lightsalmon': '#FFA07A',
|
| 1070 |
+
'lightseagreen': '#20B2AA',
|
| 1071 |
+
'lightskyblue': '#87CEFA',
|
| 1072 |
+
'lightslategray': '#778899',
|
| 1073 |
+
'lightslategrey': '#778899',
|
| 1074 |
+
'lightsteelblue': '#B0C4DE',
|
| 1075 |
+
'lightyellow': '#FFFFE0',
|
| 1076 |
+
'lime': '#00FF00',
|
| 1077 |
+
'limegreen': '#32CD32',
|
| 1078 |
+
'linen': '#FAF0E6',
|
| 1079 |
+
'magenta': '#FF00FF',
|
| 1080 |
+
'maroon': '#800000',
|
| 1081 |
+
'mediumaquamarine': '#66CDAA',
|
| 1082 |
+
'mediumblue': '#0000CD',
|
| 1083 |
+
'mediumorchid': '#BA55D3',
|
| 1084 |
+
'mediumpurple': '#9370DB',
|
| 1085 |
+
'mediumseagreen': '#3CB371',
|
| 1086 |
+
'mediumslateblue': '#7B68EE',
|
| 1087 |
+
'mediumspringgreen': '#00FA9A',
|
| 1088 |
+
'mediumturquoise': '#48D1CC',
|
| 1089 |
+
'mediumvioletred': '#C71585',
|
| 1090 |
+
'midnightblue': '#191970',
|
| 1091 |
+
'mintcream': '#F5FFFA',
|
| 1092 |
+
'mistyrose': '#FFE4E1',
|
| 1093 |
+
'moccasin': '#FFE4B5',
|
| 1094 |
+
'navajowhite': '#FFDEAD',
|
| 1095 |
+
'navy': '#000080',
|
| 1096 |
+
'oldlace': '#FDF5E6',
|
| 1097 |
+
'olive': '#808000',
|
| 1098 |
+
'olivedrab': '#6B8E23',
|
| 1099 |
+
'orange': '#FFA500',
|
| 1100 |
+
'orangered': '#FF4500',
|
| 1101 |
+
'orchid': '#DA70D6',
|
| 1102 |
+
'palegoldenrod': '#EEE8AA',
|
| 1103 |
+
'palegreen': '#98FB98',
|
| 1104 |
+
'paleturquoise': '#AFEEEE',
|
| 1105 |
+
'palevioletred': '#DB7093',
|
| 1106 |
+
'papayawhip': '#FFEFD5',
|
| 1107 |
+
'peachpuff': '#FFDAB9',
|
| 1108 |
+
'peru': '#CD853F',
|
| 1109 |
+
'pink': '#FFC0CB',
|
| 1110 |
+
'plum': '#DDA0DD',
|
| 1111 |
+
'powderblue': '#B0E0E6',
|
| 1112 |
+
'purple': '#800080',
|
| 1113 |
+
'rebeccapurple': '#663399',
|
| 1114 |
+
'red': '#FF0000',
|
| 1115 |
+
'rosybrown': '#BC8F8F',
|
| 1116 |
+
'royalblue': '#4169E1',
|
| 1117 |
+
'saddlebrown': '#8B4513',
|
| 1118 |
+
'salmon': '#FA8072',
|
| 1119 |
+
'sandybrown': '#F4A460',
|
| 1120 |
+
'seagreen': '#2E8B57',
|
| 1121 |
+
'seashell': '#FFF5EE',
|
| 1122 |
+
'sienna': '#A0522D',
|
| 1123 |
+
'silver': '#C0C0C0',
|
| 1124 |
+
'skyblue': '#87CEEB',
|
| 1125 |
+
'slateblue': '#6A5ACD',
|
| 1126 |
+
'slategray': '#708090',
|
| 1127 |
+
'slategrey': '#708090',
|
| 1128 |
+
'snow': '#FFFAFA',
|
| 1129 |
+
'springgreen': '#00FF7F',
|
| 1130 |
+
'steelblue': '#4682B4',
|
| 1131 |
+
'tan': '#D2B48C',
|
| 1132 |
+
'teal': '#008080',
|
| 1133 |
+
'thistle': '#D8BFD8',
|
| 1134 |
+
'tomato': '#FF6347',
|
| 1135 |
+
'turquoise': '#40E0D0',
|
| 1136 |
+
'violet': '#EE82EE',
|
| 1137 |
+
'wheat': '#F5DEB3',
|
| 1138 |
+
'white': '#FFFFFF',
|
| 1139 |
+
'whitesmoke': '#F5F5F5',
|
| 1140 |
+
'yellow': '#FFFF00',
|
| 1141 |
+
'yellowgreen': '#9ACD32'}
|
llava_video/lib/python3.10/site-packages/matplotlib/_docstring.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import inspect
|
| 2 |
+
|
| 3 |
+
from . import _api
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def kwarg_doc(text):
|
| 7 |
+
"""
|
| 8 |
+
Decorator for defining the kwdoc documentation of artist properties.
|
| 9 |
+
|
| 10 |
+
This decorator can be applied to artist property setter methods.
|
| 11 |
+
The given text is stored in a private attribute ``_kwarg_doc`` on
|
| 12 |
+
the method. It is used to overwrite auto-generated documentation
|
| 13 |
+
in the *kwdoc list* for artists. The kwdoc list is used to document
|
| 14 |
+
``**kwargs`` when they are properties of an artist. See e.g. the
|
| 15 |
+
``**kwargs`` section in `.Axes.text`.
|
| 16 |
+
|
| 17 |
+
The text should contain the supported types, as well as the default
|
| 18 |
+
value if applicable, e.g.:
|
| 19 |
+
|
| 20 |
+
@_docstring.kwarg_doc("bool, default: :rc:`text.usetex`")
|
| 21 |
+
def set_usetex(self, usetex):
|
| 22 |
+
|
| 23 |
+
See Also
|
| 24 |
+
--------
|
| 25 |
+
matplotlib.artist.kwdoc
|
| 26 |
+
|
| 27 |
+
"""
|
| 28 |
+
def decorator(func):
|
| 29 |
+
func._kwarg_doc = text
|
| 30 |
+
return func
|
| 31 |
+
return decorator
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class Substitution:
|
| 35 |
+
"""
|
| 36 |
+
A decorator that performs %-substitution on an object's docstring.
|
| 37 |
+
|
| 38 |
+
This decorator should be robust even if ``obj.__doc__`` is None (for
|
| 39 |
+
example, if -OO was passed to the interpreter).
|
| 40 |
+
|
| 41 |
+
Usage: construct a docstring.Substitution with a sequence or dictionary
|
| 42 |
+
suitable for performing substitution; then decorate a suitable function
|
| 43 |
+
with the constructed object, e.g.::
|
| 44 |
+
|
| 45 |
+
sub_author_name = Substitution(author='Jason')
|
| 46 |
+
|
| 47 |
+
@sub_author_name
|
| 48 |
+
def some_function(x):
|
| 49 |
+
"%(author)s wrote this function"
|
| 50 |
+
|
| 51 |
+
# note that some_function.__doc__ is now "Jason wrote this function"
|
| 52 |
+
|
| 53 |
+
One can also use positional arguments::
|
| 54 |
+
|
| 55 |
+
sub_first_last_names = Substitution('Edgar Allen', 'Poe')
|
| 56 |
+
|
| 57 |
+
@sub_first_last_names
|
| 58 |
+
def some_function(x):
|
| 59 |
+
"%s %s wrote the Raven"
|
| 60 |
+
"""
|
| 61 |
+
def __init__(self, *args, **kwargs):
|
| 62 |
+
if args and kwargs:
|
| 63 |
+
raise TypeError("Only positional or keyword args are allowed")
|
| 64 |
+
self.params = args or kwargs
|
| 65 |
+
|
| 66 |
+
def __call__(self, func):
|
| 67 |
+
if func.__doc__:
|
| 68 |
+
func.__doc__ = inspect.cleandoc(func.__doc__) % self.params
|
| 69 |
+
return func
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
class _ArtistKwdocLoader(dict):
|
| 73 |
+
def __missing__(self, key):
|
| 74 |
+
if not key.endswith(":kwdoc"):
|
| 75 |
+
raise KeyError(key)
|
| 76 |
+
name = key[:-len(":kwdoc")]
|
| 77 |
+
from matplotlib.artist import Artist, kwdoc
|
| 78 |
+
try:
|
| 79 |
+
cls, = (cls for cls in _api.recursive_subclasses(Artist)
|
| 80 |
+
if cls.__name__ == name)
|
| 81 |
+
except ValueError as e:
|
| 82 |
+
raise KeyError(key) from e
|
| 83 |
+
return self.setdefault(key, kwdoc(cls))
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
class _ArtistPropertiesSubstitution:
|
| 87 |
+
"""
|
| 88 |
+
A class to substitute formatted placeholders in docstrings.
|
| 89 |
+
|
| 90 |
+
This is realized in a single instance ``_docstring.interpd``.
|
| 91 |
+
|
| 92 |
+
Use `~._ArtistPropertiesSubstition.register` to define placeholders and
|
| 93 |
+
their substitution, e.g. ``_docstring.interpd.register(name="some value")``.
|
| 94 |
+
|
| 95 |
+
Use this as a decorator to apply the substitution::
|
| 96 |
+
|
| 97 |
+
@_docstring.interpd
|
| 98 |
+
def some_func():
|
| 99 |
+
'''Replace %(name)s.'''
|
| 100 |
+
|
| 101 |
+
Decorating a class triggers substitution both on the class docstring and
|
| 102 |
+
on the class' ``__init__`` docstring (which is a commonly required
|
| 103 |
+
pattern for Artist subclasses).
|
| 104 |
+
|
| 105 |
+
Substitutions of the form ``%(classname:kwdoc)s`` (ending with the
|
| 106 |
+
literal ":kwdoc" suffix) trigger lookup of an Artist subclass with the
|
| 107 |
+
given *classname*, and are substituted with the `.kwdoc` of that class.
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
def __init__(self):
|
| 111 |
+
self.params = _ArtistKwdocLoader()
|
| 112 |
+
|
| 113 |
+
def register(self, **kwargs):
|
| 114 |
+
"""
|
| 115 |
+
Register substitutions.
|
| 116 |
+
|
| 117 |
+
``_docstring.interpd.register(name="some value")`` makes "name" available
|
| 118 |
+
as a named parameter that will be replaced by "some value".
|
| 119 |
+
"""
|
| 120 |
+
self.params.update(**kwargs)
|
| 121 |
+
|
| 122 |
+
def __call__(self, obj):
|
| 123 |
+
if obj.__doc__:
|
| 124 |
+
obj.__doc__ = inspect.cleandoc(obj.__doc__) % self.params
|
| 125 |
+
if isinstance(obj, type) and obj.__init__ != object.__init__:
|
| 126 |
+
self(obj.__init__)
|
| 127 |
+
return obj
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def copy(source):
|
| 131 |
+
"""Copy a docstring from another source function (if present)."""
|
| 132 |
+
def do_copy(target):
|
| 133 |
+
if source.__doc__:
|
| 134 |
+
target.__doc__ = source.__doc__
|
| 135 |
+
return target
|
| 136 |
+
return do_copy
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
# Create a decorator that will house the various docstring snippets reused
|
| 140 |
+
# throughout Matplotlib.
|
| 141 |
+
interpd = _ArtistPropertiesSubstitution()
|
llava_video/lib/python3.10/site-packages/matplotlib/_enums.pyi
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from enum import Enum
|
| 2 |
+
|
| 3 |
+
class _AutoStringNameEnum(Enum):
|
| 4 |
+
def __hash__(self) -> int: ...
|
| 5 |
+
|
| 6 |
+
class JoinStyle(str, _AutoStringNameEnum):
|
| 7 |
+
miter: str
|
| 8 |
+
round: str
|
| 9 |
+
bevel: str
|
| 10 |
+
@staticmethod
|
| 11 |
+
def demo() -> None: ...
|
| 12 |
+
|
| 13 |
+
class CapStyle(str, _AutoStringNameEnum):
|
| 14 |
+
butt: str
|
| 15 |
+
projecting: str
|
| 16 |
+
round: str
|
| 17 |
+
@staticmethod
|
| 18 |
+
def demo() -> None: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/_image.pyi
ADDED
|
File without changes
|
llava_video/lib/python3.10/site-packages/matplotlib/_mathtext.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llava_video/lib/python3.10/site-packages/matplotlib/_pylab_helpers.py
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Manage figures for the pyplot interface.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import atexit
|
| 6 |
+
from collections import OrderedDict
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class Gcf:
|
| 10 |
+
"""
|
| 11 |
+
Singleton to maintain the relation between figures and their managers, and
|
| 12 |
+
keep track of and "active" figure and manager.
|
| 13 |
+
|
| 14 |
+
The canvas of a figure created through pyplot is associated with a figure
|
| 15 |
+
manager, which handles the interaction between the figure and the backend.
|
| 16 |
+
pyplot keeps track of figure managers using an identifier, the "figure
|
| 17 |
+
number" or "manager number" (which can actually be any hashable value);
|
| 18 |
+
this number is available as the :attr:`number` attribute of the manager.
|
| 19 |
+
|
| 20 |
+
This class is never instantiated; it consists of an `OrderedDict` mapping
|
| 21 |
+
figure/manager numbers to managers, and a set of class methods that
|
| 22 |
+
manipulate this `OrderedDict`.
|
| 23 |
+
|
| 24 |
+
Attributes
|
| 25 |
+
----------
|
| 26 |
+
figs : OrderedDict
|
| 27 |
+
`OrderedDict` mapping numbers to managers; the active manager is at the
|
| 28 |
+
end.
|
| 29 |
+
"""
|
| 30 |
+
|
| 31 |
+
figs = OrderedDict()
|
| 32 |
+
|
| 33 |
+
@classmethod
|
| 34 |
+
def get_fig_manager(cls, num):
|
| 35 |
+
"""
|
| 36 |
+
If manager number *num* exists, make it the active one and return it;
|
| 37 |
+
otherwise return *None*.
|
| 38 |
+
"""
|
| 39 |
+
manager = cls.figs.get(num, None)
|
| 40 |
+
if manager is not None:
|
| 41 |
+
cls.set_active(manager)
|
| 42 |
+
return manager
|
| 43 |
+
|
| 44 |
+
@classmethod
|
| 45 |
+
def destroy(cls, num):
|
| 46 |
+
"""
|
| 47 |
+
Destroy manager *num* -- either a manager instance or a manager number.
|
| 48 |
+
|
| 49 |
+
In the interactive backends, this is bound to the window "destroy" and
|
| 50 |
+
"delete" events.
|
| 51 |
+
|
| 52 |
+
It is recommended to pass a manager instance, to avoid confusion when
|
| 53 |
+
two managers share the same number.
|
| 54 |
+
"""
|
| 55 |
+
if all(hasattr(num, attr) for attr in ["num", "destroy"]):
|
| 56 |
+
manager = num
|
| 57 |
+
if cls.figs.get(manager.num) is manager:
|
| 58 |
+
cls.figs.pop(manager.num)
|
| 59 |
+
else:
|
| 60 |
+
try:
|
| 61 |
+
manager = cls.figs.pop(num)
|
| 62 |
+
except KeyError:
|
| 63 |
+
return
|
| 64 |
+
if hasattr(manager, "_cidgcf"):
|
| 65 |
+
manager.canvas.mpl_disconnect(manager._cidgcf)
|
| 66 |
+
manager.destroy()
|
| 67 |
+
|
| 68 |
+
@classmethod
|
| 69 |
+
def destroy_fig(cls, fig):
|
| 70 |
+
"""Destroy figure *fig*."""
|
| 71 |
+
num = next((manager.num for manager in cls.figs.values()
|
| 72 |
+
if manager.canvas.figure == fig), None)
|
| 73 |
+
if num is not None:
|
| 74 |
+
cls.destroy(num)
|
| 75 |
+
|
| 76 |
+
@classmethod
|
| 77 |
+
def destroy_all(cls):
|
| 78 |
+
"""Destroy all figures."""
|
| 79 |
+
for manager in list(cls.figs.values()):
|
| 80 |
+
manager.canvas.mpl_disconnect(manager._cidgcf)
|
| 81 |
+
manager.destroy()
|
| 82 |
+
cls.figs.clear()
|
| 83 |
+
|
| 84 |
+
@classmethod
|
| 85 |
+
def has_fignum(cls, num):
|
| 86 |
+
"""Return whether figure number *num* exists."""
|
| 87 |
+
return num in cls.figs
|
| 88 |
+
|
| 89 |
+
@classmethod
|
| 90 |
+
def get_all_fig_managers(cls):
|
| 91 |
+
"""Return a list of figure managers."""
|
| 92 |
+
return list(cls.figs.values())
|
| 93 |
+
|
| 94 |
+
@classmethod
|
| 95 |
+
def get_num_fig_managers(cls):
|
| 96 |
+
"""Return the number of figures being managed."""
|
| 97 |
+
return len(cls.figs)
|
| 98 |
+
|
| 99 |
+
@classmethod
|
| 100 |
+
def get_active(cls):
|
| 101 |
+
"""Return the active manager, or *None* if there is no manager."""
|
| 102 |
+
return next(reversed(cls.figs.values())) if cls.figs else None
|
| 103 |
+
|
| 104 |
+
@classmethod
|
| 105 |
+
def _set_new_active_manager(cls, manager):
|
| 106 |
+
"""Adopt *manager* into pyplot and make it the active manager."""
|
| 107 |
+
if not hasattr(manager, "_cidgcf"):
|
| 108 |
+
manager._cidgcf = manager.canvas.mpl_connect(
|
| 109 |
+
"button_press_event", lambda event: cls.set_active(manager))
|
| 110 |
+
fig = manager.canvas.figure
|
| 111 |
+
fig._number = manager.num
|
| 112 |
+
label = fig.get_label()
|
| 113 |
+
if label:
|
| 114 |
+
manager.set_window_title(label)
|
| 115 |
+
cls.set_active(manager)
|
| 116 |
+
|
| 117 |
+
@classmethod
|
| 118 |
+
def set_active(cls, manager):
|
| 119 |
+
"""Make *manager* the active manager."""
|
| 120 |
+
cls.figs[manager.num] = manager
|
| 121 |
+
cls.figs.move_to_end(manager.num)
|
| 122 |
+
|
| 123 |
+
@classmethod
|
| 124 |
+
def draw_all(cls, force=False):
|
| 125 |
+
"""
|
| 126 |
+
Redraw all stale managed figures, or, if *force* is True, all managed
|
| 127 |
+
figures.
|
| 128 |
+
"""
|
| 129 |
+
for manager in cls.get_all_fig_managers():
|
| 130 |
+
if force or manager.canvas.figure.stale:
|
| 131 |
+
manager.canvas.draw_idle()
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
atexit.register(Gcf.destroy_all)
|
llava_video/lib/python3.10/site-packages/matplotlib/_pylab_helpers.pyi
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections import OrderedDict
|
| 2 |
+
|
| 3 |
+
from matplotlib.backend_bases import FigureManagerBase
|
| 4 |
+
from matplotlib.figure import Figure
|
| 5 |
+
|
| 6 |
+
class Gcf:
|
| 7 |
+
figs: OrderedDict[int, FigureManagerBase]
|
| 8 |
+
@classmethod
|
| 9 |
+
def get_fig_manager(cls, num: int) -> FigureManagerBase | None: ...
|
| 10 |
+
@classmethod
|
| 11 |
+
def destroy(cls, num: int | FigureManagerBase) -> None: ...
|
| 12 |
+
@classmethod
|
| 13 |
+
def destroy_fig(cls, fig: Figure) -> None: ...
|
| 14 |
+
@classmethod
|
| 15 |
+
def destroy_all(cls) -> None: ...
|
| 16 |
+
@classmethod
|
| 17 |
+
def has_fignum(cls, num: int) -> bool: ...
|
| 18 |
+
@classmethod
|
| 19 |
+
def get_all_fig_managers(cls) -> list[FigureManagerBase]: ...
|
| 20 |
+
@classmethod
|
| 21 |
+
def get_num_fig_managers(cls) -> int: ...
|
| 22 |
+
@classmethod
|
| 23 |
+
def get_active(cls) -> FigureManagerBase | None: ...
|
| 24 |
+
@classmethod
|
| 25 |
+
def _set_new_active_manager(cls, manager: FigureManagerBase) -> None: ...
|
| 26 |
+
@classmethod
|
| 27 |
+
def set_active(cls, manager: FigureManagerBase) -> None: ...
|
| 28 |
+
@classmethod
|
| 29 |
+
def draw_all(cls, force: bool = ...) -> None: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/_tight_layout.py
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Routines to adjust subplot params so that subplots are
|
| 3 |
+
nicely fit in the figure. In doing so, only axis labels, tick labels, Axes
|
| 4 |
+
titles and offsetboxes that are anchored to Axes are currently considered.
|
| 5 |
+
|
| 6 |
+
Internally, this module assumes that the margins (left margin, etc.) which are
|
| 7 |
+
differences between ``Axes.get_tightbbox`` and ``Axes.bbox`` are independent of
|
| 8 |
+
Axes position. This may fail if ``Axes.adjustable`` is ``datalim`` as well as
|
| 9 |
+
such cases as when left or right margin are affected by xlabel.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
|
| 14 |
+
import matplotlib as mpl
|
| 15 |
+
from matplotlib import _api, artist as martist
|
| 16 |
+
from matplotlib.font_manager import FontProperties
|
| 17 |
+
from matplotlib.transforms import Bbox
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _auto_adjust_subplotpars(
|
| 21 |
+
fig, renderer, shape, span_pairs, subplot_list,
|
| 22 |
+
ax_bbox_list=None, pad=1.08, h_pad=None, w_pad=None, rect=None):
|
| 23 |
+
"""
|
| 24 |
+
Return a dict of subplot parameters to adjust spacing between subplots
|
| 25 |
+
or ``None`` if resulting Axes would have zero height or width.
|
| 26 |
+
|
| 27 |
+
Note that this function ignores geometry information of subplot itself, but
|
| 28 |
+
uses what is given by the *shape* and *subplot_list* parameters. Also, the
|
| 29 |
+
results could be incorrect if some subplots have ``adjustable=datalim``.
|
| 30 |
+
|
| 31 |
+
Parameters
|
| 32 |
+
----------
|
| 33 |
+
shape : tuple[int, int]
|
| 34 |
+
Number of rows and columns of the grid.
|
| 35 |
+
span_pairs : list[tuple[slice, slice]]
|
| 36 |
+
List of rowspans and colspans occupied by each subplot.
|
| 37 |
+
subplot_list : list of subplots
|
| 38 |
+
List of subplots that will be used to calculate optimal subplot_params.
|
| 39 |
+
pad : float
|
| 40 |
+
Padding between the figure edge and the edges of subplots, as a
|
| 41 |
+
fraction of the font size.
|
| 42 |
+
h_pad, w_pad : float
|
| 43 |
+
Padding (height/width) between edges of adjacent subplots, as a
|
| 44 |
+
fraction of the font size. Defaults to *pad*.
|
| 45 |
+
rect : tuple
|
| 46 |
+
(left, bottom, right, top), default: None.
|
| 47 |
+
"""
|
| 48 |
+
rows, cols = shape
|
| 49 |
+
|
| 50 |
+
font_size_inch = (FontProperties(
|
| 51 |
+
size=mpl.rcParams["font.size"]).get_size_in_points() / 72)
|
| 52 |
+
pad_inch = pad * font_size_inch
|
| 53 |
+
vpad_inch = h_pad * font_size_inch if h_pad is not None else pad_inch
|
| 54 |
+
hpad_inch = w_pad * font_size_inch if w_pad is not None else pad_inch
|
| 55 |
+
|
| 56 |
+
if len(span_pairs) != len(subplot_list) or len(subplot_list) == 0:
|
| 57 |
+
raise ValueError
|
| 58 |
+
|
| 59 |
+
if rect is None:
|
| 60 |
+
margin_left = margin_bottom = margin_right = margin_top = None
|
| 61 |
+
else:
|
| 62 |
+
margin_left, margin_bottom, _right, _top = rect
|
| 63 |
+
margin_right = 1 - _right if _right else None
|
| 64 |
+
margin_top = 1 - _top if _top else None
|
| 65 |
+
|
| 66 |
+
vspaces = np.zeros((rows + 1, cols))
|
| 67 |
+
hspaces = np.zeros((rows, cols + 1))
|
| 68 |
+
|
| 69 |
+
if ax_bbox_list is None:
|
| 70 |
+
ax_bbox_list = [
|
| 71 |
+
Bbox.union([ax.get_position(original=True) for ax in subplots])
|
| 72 |
+
for subplots in subplot_list]
|
| 73 |
+
|
| 74 |
+
for subplots, ax_bbox, (rowspan, colspan) in zip(
|
| 75 |
+
subplot_list, ax_bbox_list, span_pairs):
|
| 76 |
+
if all(not ax.get_visible() for ax in subplots):
|
| 77 |
+
continue
|
| 78 |
+
|
| 79 |
+
bb = []
|
| 80 |
+
for ax in subplots:
|
| 81 |
+
if ax.get_visible():
|
| 82 |
+
bb += [martist._get_tightbbox_for_layout_only(ax, renderer)]
|
| 83 |
+
|
| 84 |
+
tight_bbox_raw = Bbox.union(bb)
|
| 85 |
+
tight_bbox = fig.transFigure.inverted().transform_bbox(tight_bbox_raw)
|
| 86 |
+
|
| 87 |
+
hspaces[rowspan, colspan.start] += ax_bbox.xmin - tight_bbox.xmin # l
|
| 88 |
+
hspaces[rowspan, colspan.stop] += tight_bbox.xmax - ax_bbox.xmax # r
|
| 89 |
+
vspaces[rowspan.start, colspan] += tight_bbox.ymax - ax_bbox.ymax # t
|
| 90 |
+
vspaces[rowspan.stop, colspan] += ax_bbox.ymin - tight_bbox.ymin # b
|
| 91 |
+
|
| 92 |
+
fig_width_inch, fig_height_inch = fig.get_size_inches()
|
| 93 |
+
|
| 94 |
+
# margins can be negative for Axes with aspect applied, so use max(, 0) to
|
| 95 |
+
# make them nonnegative.
|
| 96 |
+
if not margin_left:
|
| 97 |
+
margin_left = max(hspaces[:, 0].max(), 0) + pad_inch/fig_width_inch
|
| 98 |
+
suplabel = fig._supylabel
|
| 99 |
+
if suplabel and suplabel.get_in_layout():
|
| 100 |
+
rel_width = fig.transFigure.inverted().transform_bbox(
|
| 101 |
+
suplabel.get_window_extent(renderer)).width
|
| 102 |
+
margin_left += rel_width + pad_inch/fig_width_inch
|
| 103 |
+
if not margin_right:
|
| 104 |
+
margin_right = max(hspaces[:, -1].max(), 0) + pad_inch/fig_width_inch
|
| 105 |
+
if not margin_top:
|
| 106 |
+
margin_top = max(vspaces[0, :].max(), 0) + pad_inch/fig_height_inch
|
| 107 |
+
if fig._suptitle and fig._suptitle.get_in_layout():
|
| 108 |
+
rel_height = fig.transFigure.inverted().transform_bbox(
|
| 109 |
+
fig._suptitle.get_window_extent(renderer)).height
|
| 110 |
+
margin_top += rel_height + pad_inch/fig_height_inch
|
| 111 |
+
if not margin_bottom:
|
| 112 |
+
margin_bottom = max(vspaces[-1, :].max(), 0) + pad_inch/fig_height_inch
|
| 113 |
+
suplabel = fig._supxlabel
|
| 114 |
+
if suplabel and suplabel.get_in_layout():
|
| 115 |
+
rel_height = fig.transFigure.inverted().transform_bbox(
|
| 116 |
+
suplabel.get_window_extent(renderer)).height
|
| 117 |
+
margin_bottom += rel_height + pad_inch/fig_height_inch
|
| 118 |
+
|
| 119 |
+
if margin_left + margin_right >= 1:
|
| 120 |
+
_api.warn_external('Tight layout not applied. The left and right '
|
| 121 |
+
'margins cannot be made large enough to '
|
| 122 |
+
'accommodate all Axes decorations.')
|
| 123 |
+
return None
|
| 124 |
+
if margin_bottom + margin_top >= 1:
|
| 125 |
+
_api.warn_external('Tight layout not applied. The bottom and top '
|
| 126 |
+
'margins cannot be made large enough to '
|
| 127 |
+
'accommodate all Axes decorations.')
|
| 128 |
+
return None
|
| 129 |
+
|
| 130 |
+
kwargs = dict(left=margin_left,
|
| 131 |
+
right=1 - margin_right,
|
| 132 |
+
bottom=margin_bottom,
|
| 133 |
+
top=1 - margin_top)
|
| 134 |
+
|
| 135 |
+
if cols > 1:
|
| 136 |
+
hspace = hspaces[:, 1:-1].max() + hpad_inch / fig_width_inch
|
| 137 |
+
# axes widths:
|
| 138 |
+
h_axes = (1 - margin_right - margin_left - hspace * (cols - 1)) / cols
|
| 139 |
+
if h_axes < 0:
|
| 140 |
+
_api.warn_external('Tight layout not applied. tight_layout '
|
| 141 |
+
'cannot make Axes width small enough to '
|
| 142 |
+
'accommodate all Axes decorations')
|
| 143 |
+
return None
|
| 144 |
+
else:
|
| 145 |
+
kwargs["wspace"] = hspace / h_axes
|
| 146 |
+
if rows > 1:
|
| 147 |
+
vspace = vspaces[1:-1, :].max() + vpad_inch / fig_height_inch
|
| 148 |
+
v_axes = (1 - margin_top - margin_bottom - vspace * (rows - 1)) / rows
|
| 149 |
+
if v_axes < 0:
|
| 150 |
+
_api.warn_external('Tight layout not applied. tight_layout '
|
| 151 |
+
'cannot make Axes height small enough to '
|
| 152 |
+
'accommodate all Axes decorations.')
|
| 153 |
+
return None
|
| 154 |
+
else:
|
| 155 |
+
kwargs["hspace"] = vspace / v_axes
|
| 156 |
+
|
| 157 |
+
return kwargs
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def get_subplotspec_list(axes_list, grid_spec=None):
|
| 161 |
+
"""
|
| 162 |
+
Return a list of subplotspec from the given list of Axes.
|
| 163 |
+
|
| 164 |
+
For an instance of Axes that does not support subplotspec, None is inserted
|
| 165 |
+
in the list.
|
| 166 |
+
|
| 167 |
+
If grid_spec is given, None is inserted for those not from the given
|
| 168 |
+
grid_spec.
|
| 169 |
+
"""
|
| 170 |
+
subplotspec_list = []
|
| 171 |
+
for ax in axes_list:
|
| 172 |
+
axes_or_locator = ax.get_axes_locator()
|
| 173 |
+
if axes_or_locator is None:
|
| 174 |
+
axes_or_locator = ax
|
| 175 |
+
|
| 176 |
+
if hasattr(axes_or_locator, "get_subplotspec"):
|
| 177 |
+
subplotspec = axes_or_locator.get_subplotspec()
|
| 178 |
+
if subplotspec is not None:
|
| 179 |
+
subplotspec = subplotspec.get_topmost_subplotspec()
|
| 180 |
+
gs = subplotspec.get_gridspec()
|
| 181 |
+
if grid_spec is not None:
|
| 182 |
+
if gs != grid_spec:
|
| 183 |
+
subplotspec = None
|
| 184 |
+
elif gs.locally_modified_subplot_params():
|
| 185 |
+
subplotspec = None
|
| 186 |
+
else:
|
| 187 |
+
subplotspec = None
|
| 188 |
+
|
| 189 |
+
subplotspec_list.append(subplotspec)
|
| 190 |
+
|
| 191 |
+
return subplotspec_list
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
def get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer,
|
| 195 |
+
pad=1.08, h_pad=None, w_pad=None, rect=None):
|
| 196 |
+
"""
|
| 197 |
+
Return subplot parameters for tight-layouted-figure with specified padding.
|
| 198 |
+
|
| 199 |
+
Parameters
|
| 200 |
+
----------
|
| 201 |
+
fig : Figure
|
| 202 |
+
axes_list : list of Axes
|
| 203 |
+
subplotspec_list : list of `.SubplotSpec`
|
| 204 |
+
The subplotspecs of each Axes.
|
| 205 |
+
renderer : renderer
|
| 206 |
+
pad : float
|
| 207 |
+
Padding between the figure edge and the edges of subplots, as a
|
| 208 |
+
fraction of the font size.
|
| 209 |
+
h_pad, w_pad : float
|
| 210 |
+
Padding (height/width) between edges of adjacent subplots. Defaults to
|
| 211 |
+
*pad*.
|
| 212 |
+
rect : tuple (left, bottom, right, top), default: None.
|
| 213 |
+
rectangle in normalized figure coordinates
|
| 214 |
+
that the whole subplots area (including labels) will fit into.
|
| 215 |
+
Defaults to using the entire figure.
|
| 216 |
+
|
| 217 |
+
Returns
|
| 218 |
+
-------
|
| 219 |
+
subplotspec or None
|
| 220 |
+
subplotspec kwargs to be passed to `.Figure.subplots_adjust` or
|
| 221 |
+
None if tight_layout could not be accomplished.
|
| 222 |
+
"""
|
| 223 |
+
|
| 224 |
+
# Multiple Axes can share same subplotspec (e.g., if using axes_grid1);
|
| 225 |
+
# we need to group them together.
|
| 226 |
+
ss_to_subplots = {ss: [] for ss in subplotspec_list}
|
| 227 |
+
for ax, ss in zip(axes_list, subplotspec_list):
|
| 228 |
+
ss_to_subplots[ss].append(ax)
|
| 229 |
+
if ss_to_subplots.pop(None, None):
|
| 230 |
+
_api.warn_external(
|
| 231 |
+
"This figure includes Axes that are not compatible with "
|
| 232 |
+
"tight_layout, so results might be incorrect.")
|
| 233 |
+
if not ss_to_subplots:
|
| 234 |
+
return {}
|
| 235 |
+
subplot_list = list(ss_to_subplots.values())
|
| 236 |
+
ax_bbox_list = [ss.get_position(fig) for ss in ss_to_subplots]
|
| 237 |
+
|
| 238 |
+
max_nrows = max(ss.get_gridspec().nrows for ss in ss_to_subplots)
|
| 239 |
+
max_ncols = max(ss.get_gridspec().ncols for ss in ss_to_subplots)
|
| 240 |
+
|
| 241 |
+
span_pairs = []
|
| 242 |
+
for ss in ss_to_subplots:
|
| 243 |
+
# The intent here is to support Axes from different gridspecs where
|
| 244 |
+
# one's nrows (or ncols) is a multiple of the other (e.g. 2 and 4),
|
| 245 |
+
# but this doesn't actually work because the computed wspace, in
|
| 246 |
+
# relative-axes-height, corresponds to different physical spacings for
|
| 247 |
+
# the 2-row grid and the 4-row grid. Still, this code is left, mostly
|
| 248 |
+
# for backcompat.
|
| 249 |
+
rows, cols = ss.get_gridspec().get_geometry()
|
| 250 |
+
div_row, mod_row = divmod(max_nrows, rows)
|
| 251 |
+
div_col, mod_col = divmod(max_ncols, cols)
|
| 252 |
+
if mod_row != 0:
|
| 253 |
+
_api.warn_external('tight_layout not applied: number of rows '
|
| 254 |
+
'in subplot specifications must be '
|
| 255 |
+
'multiples of one another.')
|
| 256 |
+
return {}
|
| 257 |
+
if mod_col != 0:
|
| 258 |
+
_api.warn_external('tight_layout not applied: number of '
|
| 259 |
+
'columns in subplot specifications must be '
|
| 260 |
+
'multiples of one another.')
|
| 261 |
+
return {}
|
| 262 |
+
span_pairs.append((
|
| 263 |
+
slice(ss.rowspan.start * div_row, ss.rowspan.stop * div_row),
|
| 264 |
+
slice(ss.colspan.start * div_col, ss.colspan.stop * div_col)))
|
| 265 |
+
|
| 266 |
+
kwargs = _auto_adjust_subplotpars(fig, renderer,
|
| 267 |
+
shape=(max_nrows, max_ncols),
|
| 268 |
+
span_pairs=span_pairs,
|
| 269 |
+
subplot_list=subplot_list,
|
| 270 |
+
ax_bbox_list=ax_bbox_list,
|
| 271 |
+
pad=pad, h_pad=h_pad, w_pad=w_pad)
|
| 272 |
+
|
| 273 |
+
# kwargs can be none if tight_layout fails...
|
| 274 |
+
if rect is not None and kwargs is not None:
|
| 275 |
+
# if rect is given, the whole subplots area (including
|
| 276 |
+
# labels) will fit into the rect instead of the
|
| 277 |
+
# figure. Note that the rect argument of
|
| 278 |
+
# *auto_adjust_subplotpars* specify the area that will be
|
| 279 |
+
# covered by the total area of axes.bbox. Thus we call
|
| 280 |
+
# auto_adjust_subplotpars twice, where the second run
|
| 281 |
+
# with adjusted rect parameters.
|
| 282 |
+
|
| 283 |
+
left, bottom, right, top = rect
|
| 284 |
+
if left is not None:
|
| 285 |
+
left += kwargs["left"]
|
| 286 |
+
if bottom is not None:
|
| 287 |
+
bottom += kwargs["bottom"]
|
| 288 |
+
if right is not None:
|
| 289 |
+
right -= (1 - kwargs["right"])
|
| 290 |
+
if top is not None:
|
| 291 |
+
top -= (1 - kwargs["top"])
|
| 292 |
+
|
| 293 |
+
kwargs = _auto_adjust_subplotpars(fig, renderer,
|
| 294 |
+
shape=(max_nrows, max_ncols),
|
| 295 |
+
span_pairs=span_pairs,
|
| 296 |
+
subplot_list=subplot_list,
|
| 297 |
+
ax_bbox_list=ax_bbox_list,
|
| 298 |
+
pad=pad, h_pad=h_pad, w_pad=w_pad,
|
| 299 |
+
rect=(left, bottom, right, top))
|
| 300 |
+
|
| 301 |
+
return kwargs
|
llava_video/lib/python3.10/site-packages/matplotlib/_tri.pyi
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This is a private module implemented in C++
|
| 2 |
+
from typing import final
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
import numpy.typing as npt
|
| 6 |
+
|
| 7 |
+
@final
|
| 8 |
+
class TrapezoidMapTriFinder:
|
| 9 |
+
def __init__(self, triangulation: Triangulation): ...
|
| 10 |
+
def find_many(self, x: npt.NDArray[np.float64], y: npt.NDArray[np.float64]) -> npt.NDArray[np.int_]: ...
|
| 11 |
+
def get_tree_stats(self) -> list[int | float]: ...
|
| 12 |
+
def initialize(self) -> None: ...
|
| 13 |
+
def print_tree(self) -> None: ...
|
| 14 |
+
|
| 15 |
+
@final
|
| 16 |
+
class TriContourGenerator:
|
| 17 |
+
def __init__(self, triangulation: Triangulation, z: npt.NDArray[np.float64]): ...
|
| 18 |
+
def create_contour(self, level: float) -> tuple[list[float], list[int]]: ...
|
| 19 |
+
def create_filled_contour(self, lower_level: float, upper_level: float) -> tuple[list[float], list[int]]: ...
|
| 20 |
+
|
| 21 |
+
@final
|
| 22 |
+
class Triangulation:
|
| 23 |
+
def __init__(
|
| 24 |
+
self,
|
| 25 |
+
x: npt.NDArray[np.float64],
|
| 26 |
+
y: npt.NDArray[np.float64],
|
| 27 |
+
triangles: npt.NDArray[np.int_],
|
| 28 |
+
mask: npt.NDArray[np.bool_] | tuple[()],
|
| 29 |
+
edges: npt.NDArray[np.int_] | tuple[()],
|
| 30 |
+
neighbors: npt.NDArray[np.int_] | tuple[()],
|
| 31 |
+
correct_triangle_orientation: bool,
|
| 32 |
+
): ...
|
| 33 |
+
def calculate_plane_coefficients(self, z: npt.ArrayLike) -> npt.NDArray[np.float64]: ...
|
| 34 |
+
def get_edges(self) -> npt.NDArray[np.int_]: ...
|
| 35 |
+
def get_neighbors(self) -> npt.NDArray[np.int_]: ...
|
| 36 |
+
def set_mask(self, mask: npt.NDArray[np.bool_] | tuple[()]) -> None: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/_type1font.py
ADDED
|
@@ -0,0 +1,879 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A class representing a Type 1 font.
|
| 3 |
+
|
| 4 |
+
This version reads pfa and pfb files and splits them for embedding in
|
| 5 |
+
pdf files. It also supports SlantFont and ExtendFont transformations,
|
| 6 |
+
similarly to pdfTeX and friends. There is no support yet for subsetting.
|
| 7 |
+
|
| 8 |
+
Usage::
|
| 9 |
+
|
| 10 |
+
font = Type1Font(filename)
|
| 11 |
+
clear_part, encrypted_part, finale = font.parts
|
| 12 |
+
slanted_font = font.transform({'slant': 0.167})
|
| 13 |
+
extended_font = font.transform({'extend': 1.2})
|
| 14 |
+
|
| 15 |
+
Sources:
|
| 16 |
+
|
| 17 |
+
* Adobe Technical Note #5040, Supporting Downloadable PostScript
|
| 18 |
+
Language Fonts.
|
| 19 |
+
|
| 20 |
+
* Adobe Type 1 Font Format, Adobe Systems Incorporated, third printing,
|
| 21 |
+
v1.1, 1993. ISBN 0-201-57044-0.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
from __future__ import annotations
|
| 25 |
+
|
| 26 |
+
import binascii
|
| 27 |
+
import functools
|
| 28 |
+
import logging
|
| 29 |
+
import re
|
| 30 |
+
import string
|
| 31 |
+
import struct
|
| 32 |
+
import typing as T
|
| 33 |
+
|
| 34 |
+
import numpy as np
|
| 35 |
+
|
| 36 |
+
from matplotlib.cbook import _format_approx
|
| 37 |
+
from . import _api
|
| 38 |
+
|
| 39 |
+
_log = logging.getLogger(__name__)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class _Token:
|
| 43 |
+
"""
|
| 44 |
+
A token in a PostScript stream.
|
| 45 |
+
|
| 46 |
+
Attributes
|
| 47 |
+
----------
|
| 48 |
+
pos : int
|
| 49 |
+
Position, i.e. offset from the beginning of the data.
|
| 50 |
+
raw : str
|
| 51 |
+
Raw text of the token.
|
| 52 |
+
kind : str
|
| 53 |
+
Description of the token (for debugging or testing).
|
| 54 |
+
"""
|
| 55 |
+
__slots__ = ('pos', 'raw')
|
| 56 |
+
kind = '?'
|
| 57 |
+
|
| 58 |
+
def __init__(self, pos, raw):
|
| 59 |
+
_log.debug('type1font._Token %s at %d: %r', self.kind, pos, raw)
|
| 60 |
+
self.pos = pos
|
| 61 |
+
self.raw = raw
|
| 62 |
+
|
| 63 |
+
def __str__(self):
|
| 64 |
+
return f"<{self.kind} {self.raw} @{self.pos}>"
|
| 65 |
+
|
| 66 |
+
def endpos(self):
|
| 67 |
+
"""Position one past the end of the token"""
|
| 68 |
+
return self.pos + len(self.raw)
|
| 69 |
+
|
| 70 |
+
def is_keyword(self, *names):
|
| 71 |
+
"""Is this a name token with one of the names?"""
|
| 72 |
+
return False
|
| 73 |
+
|
| 74 |
+
def is_slash_name(self):
|
| 75 |
+
"""Is this a name token that starts with a slash?"""
|
| 76 |
+
return False
|
| 77 |
+
|
| 78 |
+
def is_delim(self):
|
| 79 |
+
"""Is this a delimiter token?"""
|
| 80 |
+
return False
|
| 81 |
+
|
| 82 |
+
def is_number(self):
|
| 83 |
+
"""Is this a number token?"""
|
| 84 |
+
return False
|
| 85 |
+
|
| 86 |
+
def value(self):
|
| 87 |
+
return self.raw
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
class _NameToken(_Token):
|
| 91 |
+
kind = 'name'
|
| 92 |
+
|
| 93 |
+
def is_slash_name(self):
|
| 94 |
+
return self.raw.startswith('/')
|
| 95 |
+
|
| 96 |
+
def value(self):
|
| 97 |
+
return self.raw[1:]
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
class _BooleanToken(_Token):
|
| 101 |
+
kind = 'boolean'
|
| 102 |
+
|
| 103 |
+
def value(self):
|
| 104 |
+
return self.raw == 'true'
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
class _KeywordToken(_Token):
|
| 108 |
+
kind = 'keyword'
|
| 109 |
+
|
| 110 |
+
def is_keyword(self, *names):
|
| 111 |
+
return self.raw in names
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
class _DelimiterToken(_Token):
|
| 115 |
+
kind = 'delimiter'
|
| 116 |
+
|
| 117 |
+
def is_delim(self):
|
| 118 |
+
return True
|
| 119 |
+
|
| 120 |
+
def opposite(self):
|
| 121 |
+
return {'[': ']', ']': '[',
|
| 122 |
+
'{': '}', '}': '{',
|
| 123 |
+
'<<': '>>', '>>': '<<'
|
| 124 |
+
}[self.raw]
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
class _WhitespaceToken(_Token):
|
| 128 |
+
kind = 'whitespace'
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
class _StringToken(_Token):
|
| 132 |
+
kind = 'string'
|
| 133 |
+
_escapes_re = re.compile(r'\\([\\()nrtbf]|[0-7]{1,3})')
|
| 134 |
+
_replacements = {'\\': '\\', '(': '(', ')': ')', 'n': '\n',
|
| 135 |
+
'r': '\r', 't': '\t', 'b': '\b', 'f': '\f'}
|
| 136 |
+
_ws_re = re.compile('[\0\t\r\f\n ]')
|
| 137 |
+
|
| 138 |
+
@classmethod
|
| 139 |
+
def _escape(cls, match):
|
| 140 |
+
group = match.group(1)
|
| 141 |
+
try:
|
| 142 |
+
return cls._replacements[group]
|
| 143 |
+
except KeyError:
|
| 144 |
+
return chr(int(group, 8))
|
| 145 |
+
|
| 146 |
+
@functools.lru_cache
|
| 147 |
+
def value(self):
|
| 148 |
+
if self.raw[0] == '(':
|
| 149 |
+
return self._escapes_re.sub(self._escape, self.raw[1:-1])
|
| 150 |
+
else:
|
| 151 |
+
data = self._ws_re.sub('', self.raw[1:-1])
|
| 152 |
+
if len(data) % 2 == 1:
|
| 153 |
+
data += '0'
|
| 154 |
+
return binascii.unhexlify(data)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
class _BinaryToken(_Token):
|
| 158 |
+
kind = 'binary'
|
| 159 |
+
|
| 160 |
+
def value(self):
|
| 161 |
+
return self.raw[1:]
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
class _NumberToken(_Token):
|
| 165 |
+
kind = 'number'
|
| 166 |
+
|
| 167 |
+
def is_number(self):
|
| 168 |
+
return True
|
| 169 |
+
|
| 170 |
+
def value(self):
|
| 171 |
+
if '.' not in self.raw:
|
| 172 |
+
return int(self.raw)
|
| 173 |
+
else:
|
| 174 |
+
return float(self.raw)
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def _tokenize(data: bytes, skip_ws: bool) -> T.Generator[_Token, int, None]:
|
| 178 |
+
"""
|
| 179 |
+
A generator that produces _Token instances from Type-1 font code.
|
| 180 |
+
|
| 181 |
+
The consumer of the generator may send an integer to the tokenizer to
|
| 182 |
+
indicate that the next token should be _BinaryToken of the given length.
|
| 183 |
+
|
| 184 |
+
Parameters
|
| 185 |
+
----------
|
| 186 |
+
data : bytes
|
| 187 |
+
The data of the font to tokenize.
|
| 188 |
+
|
| 189 |
+
skip_ws : bool
|
| 190 |
+
If true, the generator will drop any _WhitespaceTokens from the output.
|
| 191 |
+
"""
|
| 192 |
+
|
| 193 |
+
text = data.decode('ascii', 'replace')
|
| 194 |
+
whitespace_or_comment_re = re.compile(r'[\0\t\r\f\n ]+|%[^\r\n]*')
|
| 195 |
+
token_re = re.compile(r'/{0,2}[^]\0\t\r\f\n ()<>{}/%[]+')
|
| 196 |
+
instring_re = re.compile(r'[()\\]')
|
| 197 |
+
hex_re = re.compile(r'^<[0-9a-fA-F\0\t\r\f\n ]*>$')
|
| 198 |
+
oct_re = re.compile(r'[0-7]{1,3}')
|
| 199 |
+
pos = 0
|
| 200 |
+
next_binary: int | None = None
|
| 201 |
+
|
| 202 |
+
while pos < len(text):
|
| 203 |
+
if next_binary is not None:
|
| 204 |
+
n = next_binary
|
| 205 |
+
next_binary = (yield _BinaryToken(pos, data[pos:pos+n]))
|
| 206 |
+
pos += n
|
| 207 |
+
continue
|
| 208 |
+
match = whitespace_or_comment_re.match(text, pos)
|
| 209 |
+
if match:
|
| 210 |
+
if not skip_ws:
|
| 211 |
+
next_binary = (yield _WhitespaceToken(pos, match.group()))
|
| 212 |
+
pos = match.end()
|
| 213 |
+
elif text[pos] == '(':
|
| 214 |
+
# PostScript string rules:
|
| 215 |
+
# - parentheses must be balanced
|
| 216 |
+
# - backslashes escape backslashes and parens
|
| 217 |
+
# - also codes \n\r\t\b\f and octal escapes are recognized
|
| 218 |
+
# - other backslashes do not escape anything
|
| 219 |
+
start = pos
|
| 220 |
+
pos += 1
|
| 221 |
+
depth = 1
|
| 222 |
+
while depth:
|
| 223 |
+
match = instring_re.search(text, pos)
|
| 224 |
+
if match is None:
|
| 225 |
+
raise ValueError(
|
| 226 |
+
f'Unterminated string starting at {start}')
|
| 227 |
+
pos = match.end()
|
| 228 |
+
if match.group() == '(':
|
| 229 |
+
depth += 1
|
| 230 |
+
elif match.group() == ')':
|
| 231 |
+
depth -= 1
|
| 232 |
+
else: # a backslash
|
| 233 |
+
char = text[pos]
|
| 234 |
+
if char in r'\()nrtbf':
|
| 235 |
+
pos += 1
|
| 236 |
+
else:
|
| 237 |
+
octal = oct_re.match(text, pos)
|
| 238 |
+
if octal:
|
| 239 |
+
pos = octal.end()
|
| 240 |
+
else:
|
| 241 |
+
pass # non-escaping backslash
|
| 242 |
+
next_binary = (yield _StringToken(start, text[start:pos]))
|
| 243 |
+
elif text[pos:pos + 2] in ('<<', '>>'):
|
| 244 |
+
next_binary = (yield _DelimiterToken(pos, text[pos:pos + 2]))
|
| 245 |
+
pos += 2
|
| 246 |
+
elif text[pos] == '<':
|
| 247 |
+
start = pos
|
| 248 |
+
try:
|
| 249 |
+
pos = text.index('>', pos) + 1
|
| 250 |
+
except ValueError as e:
|
| 251 |
+
raise ValueError(f'Unterminated hex string starting at {start}'
|
| 252 |
+
) from e
|
| 253 |
+
if not hex_re.match(text[start:pos]):
|
| 254 |
+
raise ValueError(f'Malformed hex string starting at {start}')
|
| 255 |
+
next_binary = (yield _StringToken(pos, text[start:pos]))
|
| 256 |
+
else:
|
| 257 |
+
match = token_re.match(text, pos)
|
| 258 |
+
if match:
|
| 259 |
+
raw = match.group()
|
| 260 |
+
if raw.startswith('/'):
|
| 261 |
+
next_binary = (yield _NameToken(pos, raw))
|
| 262 |
+
elif match.group() in ('true', 'false'):
|
| 263 |
+
next_binary = (yield _BooleanToken(pos, raw))
|
| 264 |
+
else:
|
| 265 |
+
try:
|
| 266 |
+
float(raw)
|
| 267 |
+
next_binary = (yield _NumberToken(pos, raw))
|
| 268 |
+
except ValueError:
|
| 269 |
+
next_binary = (yield _KeywordToken(pos, raw))
|
| 270 |
+
pos = match.end()
|
| 271 |
+
else:
|
| 272 |
+
next_binary = (yield _DelimiterToken(pos, text[pos]))
|
| 273 |
+
pos += 1
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
class _BalancedExpression(_Token):
|
| 277 |
+
pass
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
def _expression(initial, tokens, data):
|
| 281 |
+
"""
|
| 282 |
+
Consume some number of tokens and return a balanced PostScript expression.
|
| 283 |
+
|
| 284 |
+
Parameters
|
| 285 |
+
----------
|
| 286 |
+
initial : _Token
|
| 287 |
+
The token that triggered parsing a balanced expression.
|
| 288 |
+
tokens : iterator of _Token
|
| 289 |
+
Following tokens.
|
| 290 |
+
data : bytes
|
| 291 |
+
Underlying data that the token positions point to.
|
| 292 |
+
|
| 293 |
+
Returns
|
| 294 |
+
-------
|
| 295 |
+
_BalancedExpression
|
| 296 |
+
"""
|
| 297 |
+
delim_stack = []
|
| 298 |
+
token = initial
|
| 299 |
+
while True:
|
| 300 |
+
if token.is_delim():
|
| 301 |
+
if token.raw in ('[', '{'):
|
| 302 |
+
delim_stack.append(token)
|
| 303 |
+
elif token.raw in (']', '}'):
|
| 304 |
+
if not delim_stack:
|
| 305 |
+
raise RuntimeError(f"unmatched closing token {token}")
|
| 306 |
+
match = delim_stack.pop()
|
| 307 |
+
if match.raw != token.opposite():
|
| 308 |
+
raise RuntimeError(
|
| 309 |
+
f"opening token {match} closed by {token}"
|
| 310 |
+
)
|
| 311 |
+
if not delim_stack:
|
| 312 |
+
break
|
| 313 |
+
else:
|
| 314 |
+
raise RuntimeError(f'unknown delimiter {token}')
|
| 315 |
+
elif not delim_stack:
|
| 316 |
+
break
|
| 317 |
+
token = next(tokens)
|
| 318 |
+
return _BalancedExpression(
|
| 319 |
+
initial.pos,
|
| 320 |
+
data[initial.pos:token.endpos()].decode('ascii', 'replace')
|
| 321 |
+
)
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
class Type1Font:
|
| 325 |
+
"""
|
| 326 |
+
A class representing a Type-1 font, for use by backends.
|
| 327 |
+
|
| 328 |
+
Attributes
|
| 329 |
+
----------
|
| 330 |
+
parts : tuple
|
| 331 |
+
A 3-tuple of the cleartext part, the encrypted part, and the finale of
|
| 332 |
+
zeros.
|
| 333 |
+
|
| 334 |
+
decrypted : bytes
|
| 335 |
+
The decrypted form of ``parts[1]``.
|
| 336 |
+
|
| 337 |
+
prop : dict[str, Any]
|
| 338 |
+
A dictionary of font properties. Noteworthy keys include:
|
| 339 |
+
|
| 340 |
+
- FontName: PostScript name of the font
|
| 341 |
+
- Encoding: dict from numeric codes to glyph names
|
| 342 |
+
- FontMatrix: bytes object encoding a matrix
|
| 343 |
+
- UniqueID: optional font identifier, dropped when modifying the font
|
| 344 |
+
- CharStrings: dict from glyph names to byte code
|
| 345 |
+
- Subrs: array of byte code subroutines
|
| 346 |
+
- OtherSubrs: bytes object encoding some PostScript code
|
| 347 |
+
"""
|
| 348 |
+
__slots__ = ('parts', 'decrypted', 'prop', '_pos', '_abbr')
|
| 349 |
+
# the _pos dict contains (begin, end) indices to parts[0] + decrypted
|
| 350 |
+
# so that they can be replaced when transforming the font;
|
| 351 |
+
# but since sometimes a definition appears in both parts[0] and decrypted,
|
| 352 |
+
# _pos[name] is an array of such pairs
|
| 353 |
+
#
|
| 354 |
+
# _abbr maps three standard abbreviations to their particular names in
|
| 355 |
+
# this font (e.g. 'RD' is named '-|' in some fonts)
|
| 356 |
+
|
| 357 |
+
def __init__(self, input):
|
| 358 |
+
"""
|
| 359 |
+
Initialize a Type-1 font.
|
| 360 |
+
|
| 361 |
+
Parameters
|
| 362 |
+
----------
|
| 363 |
+
input : str or 3-tuple
|
| 364 |
+
Either a pfb file name, or a 3-tuple of already-decoded Type-1
|
| 365 |
+
font `~.Type1Font.parts`.
|
| 366 |
+
"""
|
| 367 |
+
if isinstance(input, tuple) and len(input) == 3:
|
| 368 |
+
self.parts = input
|
| 369 |
+
else:
|
| 370 |
+
with open(input, 'rb') as file:
|
| 371 |
+
data = self._read(file)
|
| 372 |
+
self.parts = self._split(data)
|
| 373 |
+
|
| 374 |
+
self.decrypted = self._decrypt(self.parts[1], 'eexec')
|
| 375 |
+
self._abbr = {'RD': 'RD', 'ND': 'ND', 'NP': 'NP'}
|
| 376 |
+
self._parse()
|
| 377 |
+
|
| 378 |
+
def _read(self, file):
|
| 379 |
+
"""Read the font from a file, decoding into usable parts."""
|
| 380 |
+
rawdata = file.read()
|
| 381 |
+
if not rawdata.startswith(b'\x80'):
|
| 382 |
+
return rawdata
|
| 383 |
+
|
| 384 |
+
data = b''
|
| 385 |
+
while rawdata:
|
| 386 |
+
if not rawdata.startswith(b'\x80'):
|
| 387 |
+
raise RuntimeError('Broken pfb file (expected byte 128, '
|
| 388 |
+
'got %d)' % rawdata[0])
|
| 389 |
+
type = rawdata[1]
|
| 390 |
+
if type in (1, 2):
|
| 391 |
+
length, = struct.unpack('<i', rawdata[2:6])
|
| 392 |
+
segment = rawdata[6:6 + length]
|
| 393 |
+
rawdata = rawdata[6 + length:]
|
| 394 |
+
|
| 395 |
+
if type == 1: # ASCII text: include verbatim
|
| 396 |
+
data += segment
|
| 397 |
+
elif type == 2: # binary data: encode in hexadecimal
|
| 398 |
+
data += binascii.hexlify(segment)
|
| 399 |
+
elif type == 3: # end of file
|
| 400 |
+
break
|
| 401 |
+
else:
|
| 402 |
+
raise RuntimeError('Unknown segment type %d in pfb file' % type)
|
| 403 |
+
|
| 404 |
+
return data
|
| 405 |
+
|
| 406 |
+
def _split(self, data):
|
| 407 |
+
"""
|
| 408 |
+
Split the Type 1 font into its three main parts.
|
| 409 |
+
|
| 410 |
+
The three parts are: (1) the cleartext part, which ends in a
|
| 411 |
+
eexec operator; (2) the encrypted part; (3) the fixed part,
|
| 412 |
+
which contains 512 ASCII zeros possibly divided on various
|
| 413 |
+
lines, a cleartomark operator, and possibly something else.
|
| 414 |
+
"""
|
| 415 |
+
|
| 416 |
+
# Cleartext part: just find the eexec and skip whitespace
|
| 417 |
+
idx = data.index(b'eexec')
|
| 418 |
+
idx += len(b'eexec')
|
| 419 |
+
while data[idx] in b' \t\r\n':
|
| 420 |
+
idx += 1
|
| 421 |
+
len1 = idx
|
| 422 |
+
|
| 423 |
+
# Encrypted part: find the cleartomark operator and count
|
| 424 |
+
# zeros backward
|
| 425 |
+
idx = data.rindex(b'cleartomark') - 1
|
| 426 |
+
zeros = 512
|
| 427 |
+
while zeros and data[idx] in b'0' or data[idx] in b'\r\n':
|
| 428 |
+
if data[idx] in b'0':
|
| 429 |
+
zeros -= 1
|
| 430 |
+
idx -= 1
|
| 431 |
+
if zeros:
|
| 432 |
+
# this may have been a problem on old implementations that
|
| 433 |
+
# used the zeros as necessary padding
|
| 434 |
+
_log.info('Insufficiently many zeros in Type 1 font')
|
| 435 |
+
|
| 436 |
+
# Convert encrypted part to binary (if we read a pfb file, we may end
|
| 437 |
+
# up converting binary to hexadecimal to binary again; but if we read
|
| 438 |
+
# a pfa file, this part is already in hex, and I am not quite sure if
|
| 439 |
+
# even the pfb format guarantees that it will be in binary).
|
| 440 |
+
idx1 = len1 + ((idx - len1 + 2) & ~1) # ensure an even number of bytes
|
| 441 |
+
binary = binascii.unhexlify(data[len1:idx1])
|
| 442 |
+
|
| 443 |
+
return data[:len1], binary, data[idx+1:]
|
| 444 |
+
|
| 445 |
+
@staticmethod
|
| 446 |
+
def _decrypt(ciphertext, key, ndiscard=4):
|
| 447 |
+
"""
|
| 448 |
+
Decrypt ciphertext using the Type-1 font algorithm.
|
| 449 |
+
|
| 450 |
+
The algorithm is described in Adobe's "Adobe Type 1 Font Format".
|
| 451 |
+
The key argument can be an integer, or one of the strings
|
| 452 |
+
'eexec' and 'charstring', which map to the key specified for the
|
| 453 |
+
corresponding part of Type-1 fonts.
|
| 454 |
+
|
| 455 |
+
The ndiscard argument should be an integer, usually 4.
|
| 456 |
+
That number of bytes is discarded from the beginning of plaintext.
|
| 457 |
+
"""
|
| 458 |
+
|
| 459 |
+
key = _api.check_getitem({'eexec': 55665, 'charstring': 4330}, key=key)
|
| 460 |
+
plaintext = []
|
| 461 |
+
for byte in ciphertext:
|
| 462 |
+
plaintext.append(byte ^ (key >> 8))
|
| 463 |
+
key = ((key+byte) * 52845 + 22719) & 0xffff
|
| 464 |
+
|
| 465 |
+
return bytes(plaintext[ndiscard:])
|
| 466 |
+
|
| 467 |
+
@staticmethod
|
| 468 |
+
def _encrypt(plaintext, key, ndiscard=4):
|
| 469 |
+
"""
|
| 470 |
+
Encrypt plaintext using the Type-1 font algorithm.
|
| 471 |
+
|
| 472 |
+
The algorithm is described in Adobe's "Adobe Type 1 Font Format".
|
| 473 |
+
The key argument can be an integer, or one of the strings
|
| 474 |
+
'eexec' and 'charstring', which map to the key specified for the
|
| 475 |
+
corresponding part of Type-1 fonts.
|
| 476 |
+
|
| 477 |
+
The ndiscard argument should be an integer, usually 4. That
|
| 478 |
+
number of bytes is prepended to the plaintext before encryption.
|
| 479 |
+
This function prepends NUL bytes for reproducibility, even though
|
| 480 |
+
the original algorithm uses random bytes, presumably to avoid
|
| 481 |
+
cryptanalysis.
|
| 482 |
+
"""
|
| 483 |
+
|
| 484 |
+
key = _api.check_getitem({'eexec': 55665, 'charstring': 4330}, key=key)
|
| 485 |
+
ciphertext = []
|
| 486 |
+
for byte in b'\0' * ndiscard + plaintext:
|
| 487 |
+
c = byte ^ (key >> 8)
|
| 488 |
+
ciphertext.append(c)
|
| 489 |
+
key = ((key + c) * 52845 + 22719) & 0xffff
|
| 490 |
+
|
| 491 |
+
return bytes(ciphertext)
|
| 492 |
+
|
| 493 |
+
def _parse(self):
|
| 494 |
+
"""
|
| 495 |
+
Find the values of various font properties. This limited kind
|
| 496 |
+
of parsing is described in Chapter 10 "Adobe Type Manager
|
| 497 |
+
Compatibility" of the Type-1 spec.
|
| 498 |
+
"""
|
| 499 |
+
# Start with reasonable defaults
|
| 500 |
+
prop = {'Weight': 'Regular', 'ItalicAngle': 0.0, 'isFixedPitch': False,
|
| 501 |
+
'UnderlinePosition': -100, 'UnderlineThickness': 50}
|
| 502 |
+
pos = {}
|
| 503 |
+
data = self.parts[0] + self.decrypted
|
| 504 |
+
|
| 505 |
+
source = _tokenize(data, True)
|
| 506 |
+
while True:
|
| 507 |
+
# See if there is a key to be assigned a value
|
| 508 |
+
# e.g. /FontName in /FontName /Helvetica def
|
| 509 |
+
try:
|
| 510 |
+
token = next(source)
|
| 511 |
+
except StopIteration:
|
| 512 |
+
break
|
| 513 |
+
if token.is_delim():
|
| 514 |
+
# skip over this - we want top-level keys only
|
| 515 |
+
_expression(token, source, data)
|
| 516 |
+
if token.is_slash_name():
|
| 517 |
+
key = token.value()
|
| 518 |
+
keypos = token.pos
|
| 519 |
+
else:
|
| 520 |
+
continue
|
| 521 |
+
|
| 522 |
+
# Some values need special parsing
|
| 523 |
+
if key in ('Subrs', 'CharStrings', 'Encoding', 'OtherSubrs'):
|
| 524 |
+
prop[key], endpos = {
|
| 525 |
+
'Subrs': self._parse_subrs,
|
| 526 |
+
'CharStrings': self._parse_charstrings,
|
| 527 |
+
'Encoding': self._parse_encoding,
|
| 528 |
+
'OtherSubrs': self._parse_othersubrs
|
| 529 |
+
}[key](source, data)
|
| 530 |
+
pos.setdefault(key, []).append((keypos, endpos))
|
| 531 |
+
continue
|
| 532 |
+
|
| 533 |
+
try:
|
| 534 |
+
token = next(source)
|
| 535 |
+
except StopIteration:
|
| 536 |
+
break
|
| 537 |
+
|
| 538 |
+
if isinstance(token, _KeywordToken):
|
| 539 |
+
# constructs like
|
| 540 |
+
# FontDirectory /Helvetica known {...} {...} ifelse
|
| 541 |
+
# mean the key was not really a key
|
| 542 |
+
continue
|
| 543 |
+
|
| 544 |
+
if token.is_delim():
|
| 545 |
+
value = _expression(token, source, data).raw
|
| 546 |
+
else:
|
| 547 |
+
value = token.value()
|
| 548 |
+
|
| 549 |
+
# look for a 'def' possibly preceded by access modifiers
|
| 550 |
+
try:
|
| 551 |
+
kw = next(
|
| 552 |
+
kw for kw in source
|
| 553 |
+
if not kw.is_keyword('readonly', 'noaccess', 'executeonly')
|
| 554 |
+
)
|
| 555 |
+
except StopIteration:
|
| 556 |
+
break
|
| 557 |
+
|
| 558 |
+
# sometimes noaccess def and readonly def are abbreviated
|
| 559 |
+
if kw.is_keyword('def', self._abbr['ND'], self._abbr['NP']):
|
| 560 |
+
prop[key] = value
|
| 561 |
+
pos.setdefault(key, []).append((keypos, kw.endpos()))
|
| 562 |
+
|
| 563 |
+
# detect the standard abbreviations
|
| 564 |
+
if value == '{noaccess def}':
|
| 565 |
+
self._abbr['ND'] = key
|
| 566 |
+
elif value == '{noaccess put}':
|
| 567 |
+
self._abbr['NP'] = key
|
| 568 |
+
elif value == '{string currentfile exch readstring pop}':
|
| 569 |
+
self._abbr['RD'] = key
|
| 570 |
+
|
| 571 |
+
# Fill in the various *Name properties
|
| 572 |
+
if 'FontName' not in prop:
|
| 573 |
+
prop['FontName'] = (prop.get('FullName') or
|
| 574 |
+
prop.get('FamilyName') or
|
| 575 |
+
'Unknown')
|
| 576 |
+
if 'FullName' not in prop:
|
| 577 |
+
prop['FullName'] = prop['FontName']
|
| 578 |
+
if 'FamilyName' not in prop:
|
| 579 |
+
extras = ('(?i)([ -](regular|plain|italic|oblique|(semi)?bold|'
|
| 580 |
+
'(ultra)?light|extra|condensed))+$')
|
| 581 |
+
prop['FamilyName'] = re.sub(extras, '', prop['FullName'])
|
| 582 |
+
# Decrypt the encrypted parts
|
| 583 |
+
ndiscard = prop.get('lenIV', 4)
|
| 584 |
+
cs = prop['CharStrings']
|
| 585 |
+
for key, value in cs.items():
|
| 586 |
+
cs[key] = self._decrypt(value, 'charstring', ndiscard)
|
| 587 |
+
if 'Subrs' in prop:
|
| 588 |
+
prop['Subrs'] = [
|
| 589 |
+
self._decrypt(value, 'charstring', ndiscard)
|
| 590 |
+
for value in prop['Subrs']
|
| 591 |
+
]
|
| 592 |
+
|
| 593 |
+
self.prop = prop
|
| 594 |
+
self._pos = pos
|
| 595 |
+
|
| 596 |
+
def _parse_subrs(self, tokens, _data):
|
| 597 |
+
count_token = next(tokens)
|
| 598 |
+
if not count_token.is_number():
|
| 599 |
+
raise RuntimeError(
|
| 600 |
+
f"Token following /Subrs must be a number, was {count_token}"
|
| 601 |
+
)
|
| 602 |
+
count = count_token.value()
|
| 603 |
+
array = [None] * count
|
| 604 |
+
next(t for t in tokens if t.is_keyword('array'))
|
| 605 |
+
for _ in range(count):
|
| 606 |
+
next(t for t in tokens if t.is_keyword('dup'))
|
| 607 |
+
index_token = next(tokens)
|
| 608 |
+
if not index_token.is_number():
|
| 609 |
+
raise RuntimeError(
|
| 610 |
+
"Token following dup in Subrs definition must be a "
|
| 611 |
+
f"number, was {index_token}"
|
| 612 |
+
)
|
| 613 |
+
nbytes_token = next(tokens)
|
| 614 |
+
if not nbytes_token.is_number():
|
| 615 |
+
raise RuntimeError(
|
| 616 |
+
"Second token following dup in Subrs definition must "
|
| 617 |
+
f"be a number, was {nbytes_token}"
|
| 618 |
+
)
|
| 619 |
+
token = next(tokens)
|
| 620 |
+
if not token.is_keyword(self._abbr['RD']):
|
| 621 |
+
raise RuntimeError(
|
| 622 |
+
f"Token preceding subr must be {self._abbr['RD']}, "
|
| 623 |
+
f"was {token}"
|
| 624 |
+
)
|
| 625 |
+
binary_token = tokens.send(1+nbytes_token.value())
|
| 626 |
+
array[index_token.value()] = binary_token.value()
|
| 627 |
+
|
| 628 |
+
return array, next(tokens).endpos()
|
| 629 |
+
|
| 630 |
+
@staticmethod
|
| 631 |
+
def _parse_charstrings(tokens, _data):
|
| 632 |
+
count_token = next(tokens)
|
| 633 |
+
if not count_token.is_number():
|
| 634 |
+
raise RuntimeError(
|
| 635 |
+
"Token following /CharStrings must be a number, "
|
| 636 |
+
f"was {count_token}"
|
| 637 |
+
)
|
| 638 |
+
count = count_token.value()
|
| 639 |
+
charstrings = {}
|
| 640 |
+
next(t for t in tokens if t.is_keyword('begin'))
|
| 641 |
+
while True:
|
| 642 |
+
token = next(t for t in tokens
|
| 643 |
+
if t.is_keyword('end') or t.is_slash_name())
|
| 644 |
+
if token.raw == 'end':
|
| 645 |
+
return charstrings, token.endpos()
|
| 646 |
+
glyphname = token.value()
|
| 647 |
+
nbytes_token = next(tokens)
|
| 648 |
+
if not nbytes_token.is_number():
|
| 649 |
+
raise RuntimeError(
|
| 650 |
+
f"Token following /{glyphname} in CharStrings definition "
|
| 651 |
+
f"must be a number, was {nbytes_token}"
|
| 652 |
+
)
|
| 653 |
+
next(tokens) # usually RD or |-
|
| 654 |
+
binary_token = tokens.send(1+nbytes_token.value())
|
| 655 |
+
charstrings[glyphname] = binary_token.value()
|
| 656 |
+
|
| 657 |
+
@staticmethod
|
| 658 |
+
def _parse_encoding(tokens, _data):
|
| 659 |
+
# this only works for encodings that follow the Adobe manual
|
| 660 |
+
# but some old fonts include non-compliant data - we log a warning
|
| 661 |
+
# and return a possibly incomplete encoding
|
| 662 |
+
encoding = {}
|
| 663 |
+
while True:
|
| 664 |
+
token = next(t for t in tokens
|
| 665 |
+
if t.is_keyword('StandardEncoding', 'dup', 'def'))
|
| 666 |
+
if token.is_keyword('StandardEncoding'):
|
| 667 |
+
return _StandardEncoding, token.endpos()
|
| 668 |
+
if token.is_keyword('def'):
|
| 669 |
+
return encoding, token.endpos()
|
| 670 |
+
index_token = next(tokens)
|
| 671 |
+
if not index_token.is_number():
|
| 672 |
+
_log.warning(
|
| 673 |
+
f"Parsing encoding: expected number, got {index_token}"
|
| 674 |
+
)
|
| 675 |
+
continue
|
| 676 |
+
name_token = next(tokens)
|
| 677 |
+
if not name_token.is_slash_name():
|
| 678 |
+
_log.warning(
|
| 679 |
+
f"Parsing encoding: expected slash-name, got {name_token}"
|
| 680 |
+
)
|
| 681 |
+
continue
|
| 682 |
+
encoding[index_token.value()] = name_token.value()
|
| 683 |
+
|
| 684 |
+
@staticmethod
|
| 685 |
+
def _parse_othersubrs(tokens, data):
|
| 686 |
+
init_pos = None
|
| 687 |
+
while True:
|
| 688 |
+
token = next(tokens)
|
| 689 |
+
if init_pos is None:
|
| 690 |
+
init_pos = token.pos
|
| 691 |
+
if token.is_delim():
|
| 692 |
+
_expression(token, tokens, data)
|
| 693 |
+
elif token.is_keyword('def', 'ND', '|-'):
|
| 694 |
+
return data[init_pos:token.endpos()], token.endpos()
|
| 695 |
+
|
| 696 |
+
def transform(self, effects):
|
| 697 |
+
"""
|
| 698 |
+
Return a new font that is slanted and/or extended.
|
| 699 |
+
|
| 700 |
+
Parameters
|
| 701 |
+
----------
|
| 702 |
+
effects : dict
|
| 703 |
+
A dict with optional entries:
|
| 704 |
+
|
| 705 |
+
- 'slant' : float, default: 0
|
| 706 |
+
Tangent of the angle that the font is to be slanted to the
|
| 707 |
+
right. Negative values slant to the left.
|
| 708 |
+
- 'extend' : float, default: 1
|
| 709 |
+
Scaling factor for the font width. Values less than 1 condense
|
| 710 |
+
the glyphs.
|
| 711 |
+
|
| 712 |
+
Returns
|
| 713 |
+
-------
|
| 714 |
+
`Type1Font`
|
| 715 |
+
"""
|
| 716 |
+
fontname = self.prop['FontName']
|
| 717 |
+
italicangle = self.prop['ItalicAngle']
|
| 718 |
+
|
| 719 |
+
array = [
|
| 720 |
+
float(x) for x in (self.prop['FontMatrix']
|
| 721 |
+
.lstrip('[').rstrip(']').split())
|
| 722 |
+
]
|
| 723 |
+
oldmatrix = np.eye(3, 3)
|
| 724 |
+
oldmatrix[0:3, 0] = array[::2]
|
| 725 |
+
oldmatrix[0:3, 1] = array[1::2]
|
| 726 |
+
modifier = np.eye(3, 3)
|
| 727 |
+
|
| 728 |
+
if 'slant' in effects:
|
| 729 |
+
slant = effects['slant']
|
| 730 |
+
fontname += f'_Slant_{int(1000 * slant)}'
|
| 731 |
+
italicangle = round(
|
| 732 |
+
float(italicangle) - np.arctan(slant) / np.pi * 180,
|
| 733 |
+
5
|
| 734 |
+
)
|
| 735 |
+
modifier[1, 0] = slant
|
| 736 |
+
|
| 737 |
+
if 'extend' in effects:
|
| 738 |
+
extend = effects['extend']
|
| 739 |
+
fontname += f'_Extend_{int(1000 * extend)}'
|
| 740 |
+
modifier[0, 0] = extend
|
| 741 |
+
|
| 742 |
+
newmatrix = np.dot(modifier, oldmatrix)
|
| 743 |
+
array[::2] = newmatrix[0:3, 0]
|
| 744 |
+
array[1::2] = newmatrix[0:3, 1]
|
| 745 |
+
fontmatrix = (
|
| 746 |
+
f"[{' '.join(_format_approx(x, 6) for x in array)}]"
|
| 747 |
+
)
|
| 748 |
+
replacements = (
|
| 749 |
+
[(x, f'/FontName/{fontname} def')
|
| 750 |
+
for x in self._pos['FontName']]
|
| 751 |
+
+ [(x, f'/ItalicAngle {italicangle} def')
|
| 752 |
+
for x in self._pos['ItalicAngle']]
|
| 753 |
+
+ [(x, f'/FontMatrix {fontmatrix} readonly def')
|
| 754 |
+
for x in self._pos['FontMatrix']]
|
| 755 |
+
+ [(x, '') for x in self._pos.get('UniqueID', [])]
|
| 756 |
+
)
|
| 757 |
+
|
| 758 |
+
data = bytearray(self.parts[0])
|
| 759 |
+
data.extend(self.decrypted)
|
| 760 |
+
len0 = len(self.parts[0])
|
| 761 |
+
for (pos0, pos1), value in sorted(replacements, reverse=True):
|
| 762 |
+
data[pos0:pos1] = value.encode('ascii', 'replace')
|
| 763 |
+
if pos0 < len(self.parts[0]):
|
| 764 |
+
if pos1 >= len(self.parts[0]):
|
| 765 |
+
raise RuntimeError(
|
| 766 |
+
f"text to be replaced with {value} spans "
|
| 767 |
+
"the eexec boundary"
|
| 768 |
+
)
|
| 769 |
+
len0 += len(value) - pos1 + pos0
|
| 770 |
+
|
| 771 |
+
data = bytes(data)
|
| 772 |
+
return Type1Font((
|
| 773 |
+
data[:len0],
|
| 774 |
+
self._encrypt(data[len0:], 'eexec'),
|
| 775 |
+
self.parts[2]
|
| 776 |
+
))
|
| 777 |
+
|
| 778 |
+
|
| 779 |
+
_StandardEncoding = {
|
| 780 |
+
**{ord(letter): letter for letter in string.ascii_letters},
|
| 781 |
+
0: '.notdef',
|
| 782 |
+
32: 'space',
|
| 783 |
+
33: 'exclam',
|
| 784 |
+
34: 'quotedbl',
|
| 785 |
+
35: 'numbersign',
|
| 786 |
+
36: 'dollar',
|
| 787 |
+
37: 'percent',
|
| 788 |
+
38: 'ampersand',
|
| 789 |
+
39: 'quoteright',
|
| 790 |
+
40: 'parenleft',
|
| 791 |
+
41: 'parenright',
|
| 792 |
+
42: 'asterisk',
|
| 793 |
+
43: 'plus',
|
| 794 |
+
44: 'comma',
|
| 795 |
+
45: 'hyphen',
|
| 796 |
+
46: 'period',
|
| 797 |
+
47: 'slash',
|
| 798 |
+
48: 'zero',
|
| 799 |
+
49: 'one',
|
| 800 |
+
50: 'two',
|
| 801 |
+
51: 'three',
|
| 802 |
+
52: 'four',
|
| 803 |
+
53: 'five',
|
| 804 |
+
54: 'six',
|
| 805 |
+
55: 'seven',
|
| 806 |
+
56: 'eight',
|
| 807 |
+
57: 'nine',
|
| 808 |
+
58: 'colon',
|
| 809 |
+
59: 'semicolon',
|
| 810 |
+
60: 'less',
|
| 811 |
+
61: 'equal',
|
| 812 |
+
62: 'greater',
|
| 813 |
+
63: 'question',
|
| 814 |
+
64: 'at',
|
| 815 |
+
91: 'bracketleft',
|
| 816 |
+
92: 'backslash',
|
| 817 |
+
93: 'bracketright',
|
| 818 |
+
94: 'asciicircum',
|
| 819 |
+
95: 'underscore',
|
| 820 |
+
96: 'quoteleft',
|
| 821 |
+
123: 'braceleft',
|
| 822 |
+
124: 'bar',
|
| 823 |
+
125: 'braceright',
|
| 824 |
+
126: 'asciitilde',
|
| 825 |
+
161: 'exclamdown',
|
| 826 |
+
162: 'cent',
|
| 827 |
+
163: 'sterling',
|
| 828 |
+
164: 'fraction',
|
| 829 |
+
165: 'yen',
|
| 830 |
+
166: 'florin',
|
| 831 |
+
167: 'section',
|
| 832 |
+
168: 'currency',
|
| 833 |
+
169: 'quotesingle',
|
| 834 |
+
170: 'quotedblleft',
|
| 835 |
+
171: 'guillemotleft',
|
| 836 |
+
172: 'guilsinglleft',
|
| 837 |
+
173: 'guilsinglright',
|
| 838 |
+
174: 'fi',
|
| 839 |
+
175: 'fl',
|
| 840 |
+
177: 'endash',
|
| 841 |
+
178: 'dagger',
|
| 842 |
+
179: 'daggerdbl',
|
| 843 |
+
180: 'periodcentered',
|
| 844 |
+
182: 'paragraph',
|
| 845 |
+
183: 'bullet',
|
| 846 |
+
184: 'quotesinglbase',
|
| 847 |
+
185: 'quotedblbase',
|
| 848 |
+
186: 'quotedblright',
|
| 849 |
+
187: 'guillemotright',
|
| 850 |
+
188: 'ellipsis',
|
| 851 |
+
189: 'perthousand',
|
| 852 |
+
191: 'questiondown',
|
| 853 |
+
193: 'grave',
|
| 854 |
+
194: 'acute',
|
| 855 |
+
195: 'circumflex',
|
| 856 |
+
196: 'tilde',
|
| 857 |
+
197: 'macron',
|
| 858 |
+
198: 'breve',
|
| 859 |
+
199: 'dotaccent',
|
| 860 |
+
200: 'dieresis',
|
| 861 |
+
202: 'ring',
|
| 862 |
+
203: 'cedilla',
|
| 863 |
+
205: 'hungarumlaut',
|
| 864 |
+
206: 'ogonek',
|
| 865 |
+
207: 'caron',
|
| 866 |
+
208: 'emdash',
|
| 867 |
+
225: 'AE',
|
| 868 |
+
227: 'ordfeminine',
|
| 869 |
+
232: 'Lslash',
|
| 870 |
+
233: 'Oslash',
|
| 871 |
+
234: 'OE',
|
| 872 |
+
235: 'ordmasculine',
|
| 873 |
+
241: 'ae',
|
| 874 |
+
245: 'dotlessi',
|
| 875 |
+
248: 'lslash',
|
| 876 |
+
249: 'oslash',
|
| 877 |
+
250: 'oe',
|
| 878 |
+
251: 'germandbls',
|
| 879 |
+
}
|
llava_video/lib/python3.10/site-packages/matplotlib/_version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
version = "3.10.0"
|
llava_video/lib/python3.10/site-packages/matplotlib/axis.pyi
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable, Iterable, Sequence
|
| 2 |
+
import datetime
|
| 3 |
+
from typing import Any, Literal, overload
|
| 4 |
+
from typing_extensions import Self # < Py 3.11
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
from numpy.typing import ArrayLike
|
| 8 |
+
|
| 9 |
+
import matplotlib.artist as martist
|
| 10 |
+
from matplotlib import cbook
|
| 11 |
+
from matplotlib.axes import Axes
|
| 12 |
+
from matplotlib.backend_bases import RendererBase
|
| 13 |
+
from matplotlib.lines import Line2D
|
| 14 |
+
from matplotlib.text import Text
|
| 15 |
+
from matplotlib.ticker import Locator, Formatter
|
| 16 |
+
from matplotlib.transforms import Transform, Bbox
|
| 17 |
+
from matplotlib.typing import ColorType
|
| 18 |
+
from matplotlib.units import ConversionInterface
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
GRIDLINE_INTERPOLATION_STEPS: int
|
| 22 |
+
|
| 23 |
+
class Tick(martist.Artist):
|
| 24 |
+
axes: Axes
|
| 25 |
+
tick1line: Line2D
|
| 26 |
+
tick2line: Line2D
|
| 27 |
+
gridline: Line2D
|
| 28 |
+
label1: Text
|
| 29 |
+
label2: Text
|
| 30 |
+
def __init__(
|
| 31 |
+
self,
|
| 32 |
+
axes: Axes,
|
| 33 |
+
loc: float,
|
| 34 |
+
*,
|
| 35 |
+
size: float | None = ...,
|
| 36 |
+
width: float | None = ...,
|
| 37 |
+
color: ColorType | None = ...,
|
| 38 |
+
tickdir: Literal["in", "inout", "out"] | None = ...,
|
| 39 |
+
pad: float | None = ...,
|
| 40 |
+
labelsize: float | None = ...,
|
| 41 |
+
labelcolor: ColorType | None = ...,
|
| 42 |
+
labelfontfamily: str | Sequence[str] | None = ...,
|
| 43 |
+
zorder: float | None = ...,
|
| 44 |
+
gridOn: bool | None = ...,
|
| 45 |
+
tick1On: bool = ...,
|
| 46 |
+
tick2On: bool = ...,
|
| 47 |
+
label1On: bool = ...,
|
| 48 |
+
label2On: bool = ...,
|
| 49 |
+
major: bool = ...,
|
| 50 |
+
labelrotation: float = ...,
|
| 51 |
+
grid_color: ColorType | None = ...,
|
| 52 |
+
grid_linestyle: str | None = ...,
|
| 53 |
+
grid_linewidth: float | None = ...,
|
| 54 |
+
grid_alpha: float | None = ...,
|
| 55 |
+
**kwargs
|
| 56 |
+
) -> None: ...
|
| 57 |
+
def get_tickdir(self) -> Literal["in", "inout", "out"]: ...
|
| 58 |
+
def get_tick_padding(self) -> float: ...
|
| 59 |
+
def get_children(self) -> list[martist.Artist]: ...
|
| 60 |
+
stale: bool
|
| 61 |
+
def set_pad(self, val: float) -> None: ...
|
| 62 |
+
def get_pad(self) -> None: ...
|
| 63 |
+
def get_loc(self) -> float: ...
|
| 64 |
+
def set_url(self, url: str | None) -> None: ...
|
| 65 |
+
def get_view_interval(self) -> ArrayLike: ...
|
| 66 |
+
def update_position(self, loc: float) -> None: ...
|
| 67 |
+
|
| 68 |
+
class XTick(Tick):
|
| 69 |
+
__name__: str
|
| 70 |
+
def __init__(self, *args, **kwargs) -> None: ...
|
| 71 |
+
stale: bool
|
| 72 |
+
def update_position(self, loc: float) -> None: ...
|
| 73 |
+
def get_view_interval(self) -> np.ndarray: ...
|
| 74 |
+
|
| 75 |
+
class YTick(Tick):
|
| 76 |
+
__name__: str
|
| 77 |
+
def __init__(self, *args, **kwargs) -> None: ...
|
| 78 |
+
stale: bool
|
| 79 |
+
def update_position(self, loc: float) -> None: ...
|
| 80 |
+
def get_view_interval(self) -> np.ndarray: ...
|
| 81 |
+
|
| 82 |
+
class Ticker:
|
| 83 |
+
def __init__(self) -> None: ...
|
| 84 |
+
@property
|
| 85 |
+
def locator(self) -> Locator | None: ...
|
| 86 |
+
@locator.setter
|
| 87 |
+
def locator(self, locator: Locator) -> None: ...
|
| 88 |
+
@property
|
| 89 |
+
def formatter(self) -> Formatter | None: ...
|
| 90 |
+
@formatter.setter
|
| 91 |
+
def formatter(self, formatter: Formatter) -> None: ...
|
| 92 |
+
|
| 93 |
+
class _LazyTickList:
|
| 94 |
+
def __init__(self, major: bool) -> None: ...
|
| 95 |
+
@overload
|
| 96 |
+
def __get__(self, instance: None, owner: None) -> Self: ...
|
| 97 |
+
@overload
|
| 98 |
+
def __get__(self, instance: Axis, owner: type[Axis]) -> list[Tick]: ...
|
| 99 |
+
|
| 100 |
+
class Axis(martist.Artist):
|
| 101 |
+
OFFSETTEXTPAD: int
|
| 102 |
+
isDefault_label: bool
|
| 103 |
+
axes: Axes
|
| 104 |
+
major: Ticker
|
| 105 |
+
minor: Ticker
|
| 106 |
+
callbacks: cbook.CallbackRegistry
|
| 107 |
+
label: Text
|
| 108 |
+
offsetText: Text
|
| 109 |
+
labelpad: float
|
| 110 |
+
pickradius: float
|
| 111 |
+
def __init__(self, axes, *, pickradius: float = ...,
|
| 112 |
+
clear: bool = ...) -> None: ...
|
| 113 |
+
@property
|
| 114 |
+
def isDefault_majloc(self) -> bool: ...
|
| 115 |
+
@isDefault_majloc.setter
|
| 116 |
+
def isDefault_majloc(self, value: bool) -> None: ...
|
| 117 |
+
@property
|
| 118 |
+
def isDefault_majfmt(self) -> bool: ...
|
| 119 |
+
@isDefault_majfmt.setter
|
| 120 |
+
def isDefault_majfmt(self, value: bool) -> None: ...
|
| 121 |
+
@property
|
| 122 |
+
def isDefault_minloc(self) -> bool: ...
|
| 123 |
+
@isDefault_minloc.setter
|
| 124 |
+
def isDefault_minloc(self, value: bool) -> None: ...
|
| 125 |
+
@property
|
| 126 |
+
def isDefault_minfmt(self) -> bool: ...
|
| 127 |
+
@isDefault_minfmt.setter
|
| 128 |
+
def isDefault_minfmt(self, value: bool) -> None: ...
|
| 129 |
+
majorTicks: _LazyTickList
|
| 130 |
+
minorTicks: _LazyTickList
|
| 131 |
+
def get_remove_overlapping_locs(self) -> bool: ...
|
| 132 |
+
def set_remove_overlapping_locs(self, val: bool) -> None: ...
|
| 133 |
+
@property
|
| 134 |
+
def remove_overlapping_locs(self) -> bool: ...
|
| 135 |
+
@remove_overlapping_locs.setter
|
| 136 |
+
def remove_overlapping_locs(self, val: bool) -> None: ...
|
| 137 |
+
stale: bool
|
| 138 |
+
def set_label_coords(
|
| 139 |
+
self, x: float, y: float, transform: Transform | None = ...
|
| 140 |
+
) -> None: ...
|
| 141 |
+
def get_transform(self) -> Transform: ...
|
| 142 |
+
def get_scale(self) -> str: ...
|
| 143 |
+
def limit_range_for_scale(
|
| 144 |
+
self, vmin: float, vmax: float
|
| 145 |
+
) -> tuple[float, float]: ...
|
| 146 |
+
def get_children(self) -> list[martist.Artist]: ...
|
| 147 |
+
# TODO units
|
| 148 |
+
converter: Any
|
| 149 |
+
units: Any
|
| 150 |
+
def clear(self) -> None: ...
|
| 151 |
+
def reset_ticks(self) -> None: ...
|
| 152 |
+
def minorticks_on(self) -> None: ...
|
| 153 |
+
def minorticks_off(self) -> None: ...
|
| 154 |
+
def set_tick_params(
|
| 155 |
+
self,
|
| 156 |
+
which: Literal["major", "minor", "both"] = ...,
|
| 157 |
+
reset: bool = ...,
|
| 158 |
+
**kwargs
|
| 159 |
+
) -> None: ...
|
| 160 |
+
def get_tick_params(
|
| 161 |
+
self, which: Literal["major", "minor"] = ...
|
| 162 |
+
) -> dict[str, Any]: ...
|
| 163 |
+
def get_view_interval(self) -> tuple[float, float]: ...
|
| 164 |
+
def set_view_interval(
|
| 165 |
+
self, vmin: float, vmax: float, ignore: bool = ...
|
| 166 |
+
) -> None: ...
|
| 167 |
+
def get_data_interval(self) -> tuple[float, float]: ...
|
| 168 |
+
def set_data_interval(
|
| 169 |
+
self, vmin: float, vmax: float, ignore: bool = ...
|
| 170 |
+
) -> None: ...
|
| 171 |
+
def get_inverted(self) -> bool: ...
|
| 172 |
+
def set_inverted(self, inverted: bool) -> None: ...
|
| 173 |
+
def set_default_intervals(self) -> None: ...
|
| 174 |
+
def get_tightbbox(
|
| 175 |
+
self, renderer: RendererBase | None = ..., *, for_layout_only: bool = ...
|
| 176 |
+
) -> Bbox | None: ...
|
| 177 |
+
def get_tick_padding(self) -> float: ...
|
| 178 |
+
def get_gridlines(self) -> list[Line2D]: ...
|
| 179 |
+
def get_label(self) -> Text: ...
|
| 180 |
+
def get_offset_text(self) -> Text: ...
|
| 181 |
+
def get_pickradius(self) -> float: ...
|
| 182 |
+
def get_majorticklabels(self) -> list[Text]: ...
|
| 183 |
+
def get_minorticklabels(self) -> list[Text]: ...
|
| 184 |
+
def get_ticklabels(
|
| 185 |
+
self, minor: bool = ..., which: Literal["major", "minor", "both"] | None = ...
|
| 186 |
+
) -> list[Text]: ...
|
| 187 |
+
def get_majorticklines(self) -> list[Line2D]: ...
|
| 188 |
+
def get_minorticklines(self) -> list[Line2D]: ...
|
| 189 |
+
def get_ticklines(self, minor: bool = ...) -> list[Line2D]: ...
|
| 190 |
+
def get_majorticklocs(self) -> np.ndarray: ...
|
| 191 |
+
def get_minorticklocs(self) -> np.ndarray: ...
|
| 192 |
+
def get_ticklocs(self, *, minor: bool = ...) -> np.ndarray: ...
|
| 193 |
+
def get_ticks_direction(self, minor: bool = ...) -> np.ndarray: ...
|
| 194 |
+
def get_label_text(self) -> str: ...
|
| 195 |
+
def get_major_locator(self) -> Locator: ...
|
| 196 |
+
def get_minor_locator(self) -> Locator: ...
|
| 197 |
+
def get_major_formatter(self) -> Formatter: ...
|
| 198 |
+
def get_minor_formatter(self) -> Formatter: ...
|
| 199 |
+
def get_major_ticks(self, numticks: int | None = ...) -> list[Tick]: ...
|
| 200 |
+
def get_minor_ticks(self, numticks: int | None = ...) -> list[Tick]: ...
|
| 201 |
+
def grid(
|
| 202 |
+
self,
|
| 203 |
+
visible: bool | None = ...,
|
| 204 |
+
which: Literal["major", "minor", "both"] = ...,
|
| 205 |
+
**kwargs
|
| 206 |
+
) -> None: ...
|
| 207 |
+
# TODO units
|
| 208 |
+
def update_units(self, data): ...
|
| 209 |
+
def have_units(self) -> bool: ...
|
| 210 |
+
def convert_units(self, x): ...
|
| 211 |
+
def get_converter(self) -> ConversionInterface | None: ...
|
| 212 |
+
def set_converter(self, converter: ConversionInterface) -> None: ...
|
| 213 |
+
def set_units(self, u) -> None: ...
|
| 214 |
+
def get_units(self): ...
|
| 215 |
+
def set_label_text(
|
| 216 |
+
self, label: str, fontdict: dict[str, Any] | None = ..., **kwargs
|
| 217 |
+
) -> Text: ...
|
| 218 |
+
def set_major_formatter(
|
| 219 |
+
self, formatter: Formatter | str | Callable[[float, float], str]
|
| 220 |
+
) -> None: ...
|
| 221 |
+
def set_minor_formatter(
|
| 222 |
+
self, formatter: Formatter | str | Callable[[float, float], str]
|
| 223 |
+
) -> None: ...
|
| 224 |
+
def set_major_locator(self, locator: Locator) -> None: ...
|
| 225 |
+
def set_minor_locator(self, locator: Locator) -> None: ...
|
| 226 |
+
def set_pickradius(self, pickradius: float) -> None: ...
|
| 227 |
+
def set_ticklabels(
|
| 228 |
+
self,
|
| 229 |
+
labels: Iterable[str | Text],
|
| 230 |
+
*,
|
| 231 |
+
minor: bool = ...,
|
| 232 |
+
fontdict: dict[str, Any] | None = ...,
|
| 233 |
+
**kwargs
|
| 234 |
+
) -> list[Text]: ...
|
| 235 |
+
def set_ticks(
|
| 236 |
+
self,
|
| 237 |
+
ticks: ArrayLike,
|
| 238 |
+
labels: Iterable[str] | None = ...,
|
| 239 |
+
*,
|
| 240 |
+
minor: bool = ...,
|
| 241 |
+
**kwargs
|
| 242 |
+
) -> list[Tick]: ...
|
| 243 |
+
def axis_date(self, tz: str | datetime.tzinfo | None = ...) -> None: ...
|
| 244 |
+
def get_tick_space(self) -> int: ...
|
| 245 |
+
def get_label_position(self) -> Literal["top", "bottom"]: ...
|
| 246 |
+
def set_label_position(
|
| 247 |
+
self, position: Literal["top", "bottom", "left", "right"]
|
| 248 |
+
) -> None: ...
|
| 249 |
+
def get_minpos(self) -> float: ...
|
| 250 |
+
|
| 251 |
+
class XAxis(Axis):
|
| 252 |
+
__name__: str
|
| 253 |
+
axis_name: str
|
| 254 |
+
def __init__(self, *args, **kwargs) -> None: ...
|
| 255 |
+
label_position: Literal["bottom", "top"]
|
| 256 |
+
stale: bool
|
| 257 |
+
def set_label_position(self, position: Literal["bottom", "top"]) -> None: ... # type: ignore[override]
|
| 258 |
+
def set_ticks_position(
|
| 259 |
+
self, position: Literal["top", "bottom", "both", "default", "none"]
|
| 260 |
+
) -> None: ...
|
| 261 |
+
def tick_top(self) -> None: ...
|
| 262 |
+
def tick_bottom(self) -> None: ...
|
| 263 |
+
def get_ticks_position(self) -> Literal["top", "bottom", "default", "unknown"]: ...
|
| 264 |
+
def get_tick_space(self) -> int: ...
|
| 265 |
+
|
| 266 |
+
class YAxis(Axis):
|
| 267 |
+
__name__: str
|
| 268 |
+
axis_name: str
|
| 269 |
+
def __init__(self, *args, **kwargs) -> None: ...
|
| 270 |
+
label_position: Literal["left", "right"]
|
| 271 |
+
stale: bool
|
| 272 |
+
def set_label_position(self, position: Literal["left", "right"]) -> None: ... # type: ignore[override]
|
| 273 |
+
def set_offset_position(self, position: Literal["left", "right"]) -> None: ...
|
| 274 |
+
def set_ticks_position(
|
| 275 |
+
self, position: Literal["left", "right", "both", "default", "none"]
|
| 276 |
+
) -> None: ...
|
| 277 |
+
def tick_right(self) -> None: ...
|
| 278 |
+
def tick_left(self) -> None: ...
|
| 279 |
+
def get_ticks_position(self) -> Literal["left", "right", "default", "unknown"]: ...
|
| 280 |
+
def get_tick_space(self) -> int: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/backend_bases.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llava_video/lib/python3.10/site-packages/matplotlib/cbook.pyi
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import collections.abc
|
| 2 |
+
from collections.abc import Callable, Collection, Generator, Iterable, Iterator
|
| 3 |
+
import contextlib
|
| 4 |
+
import os
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
from matplotlib.artist import Artist
|
| 8 |
+
|
| 9 |
+
import numpy as np
|
| 10 |
+
from numpy.typing import ArrayLike
|
| 11 |
+
|
| 12 |
+
from typing import (
|
| 13 |
+
Any,
|
| 14 |
+
Generic,
|
| 15 |
+
IO,
|
| 16 |
+
Literal,
|
| 17 |
+
TypeVar,
|
| 18 |
+
overload,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
_T = TypeVar("_T")
|
| 22 |
+
|
| 23 |
+
def _get_running_interactive_framework() -> str | None: ...
|
| 24 |
+
|
| 25 |
+
class CallbackRegistry:
|
| 26 |
+
exception_handler: Callable[[Exception], Any]
|
| 27 |
+
callbacks: dict[Any, dict[int, Any]]
|
| 28 |
+
def __init__(
|
| 29 |
+
self,
|
| 30 |
+
exception_handler: Callable[[Exception], Any] | None = ...,
|
| 31 |
+
*,
|
| 32 |
+
signals: Iterable[Any] | None = ...,
|
| 33 |
+
) -> None: ...
|
| 34 |
+
def connect(self, signal: Any, func: Callable) -> int: ...
|
| 35 |
+
def disconnect(self, cid: int) -> None: ...
|
| 36 |
+
def process(self, s: Any, *args, **kwargs) -> None: ...
|
| 37 |
+
def blocked(
|
| 38 |
+
self, *, signal: Any | None = ...
|
| 39 |
+
) -> contextlib.AbstractContextManager[None]: ...
|
| 40 |
+
|
| 41 |
+
class silent_list(list[_T]):
|
| 42 |
+
type: str | None
|
| 43 |
+
def __init__(self, type: str | None, seq: Iterable[_T] | None = ...) -> None: ...
|
| 44 |
+
|
| 45 |
+
def strip_math(s: str) -> str: ...
|
| 46 |
+
def is_writable_file_like(obj: Any) -> bool: ...
|
| 47 |
+
def file_requires_unicode(x: Any) -> bool: ...
|
| 48 |
+
@overload
|
| 49 |
+
def to_filehandle(
|
| 50 |
+
fname: str | os.PathLike | IO,
|
| 51 |
+
flag: str = ...,
|
| 52 |
+
return_opened: Literal[False] = ...,
|
| 53 |
+
encoding: str | None = ...,
|
| 54 |
+
) -> IO: ...
|
| 55 |
+
@overload
|
| 56 |
+
def to_filehandle(
|
| 57 |
+
fname: str | os.PathLike | IO,
|
| 58 |
+
flag: str,
|
| 59 |
+
return_opened: Literal[True],
|
| 60 |
+
encoding: str | None = ...,
|
| 61 |
+
) -> tuple[IO, bool]: ...
|
| 62 |
+
@overload
|
| 63 |
+
def to_filehandle(
|
| 64 |
+
fname: str | os.PathLike | IO,
|
| 65 |
+
*, # if flag given, will match previous sig
|
| 66 |
+
return_opened: Literal[True],
|
| 67 |
+
encoding: str | None = ...,
|
| 68 |
+
) -> tuple[IO, bool]: ...
|
| 69 |
+
def open_file_cm(
|
| 70 |
+
path_or_file: str | os.PathLike | IO,
|
| 71 |
+
mode: str = ...,
|
| 72 |
+
encoding: str | None = ...,
|
| 73 |
+
) -> contextlib.AbstractContextManager[IO]: ...
|
| 74 |
+
def is_scalar_or_string(val: Any) -> bool: ...
|
| 75 |
+
@overload
|
| 76 |
+
def get_sample_data(
|
| 77 |
+
fname: str | os.PathLike, asfileobj: Literal[True] = ...
|
| 78 |
+
) -> np.ndarray | IO: ...
|
| 79 |
+
@overload
|
| 80 |
+
def get_sample_data(fname: str | os.PathLike, asfileobj: Literal[False]) -> str: ...
|
| 81 |
+
def _get_data_path(*args: Path | str) -> Path: ...
|
| 82 |
+
def flatten(
|
| 83 |
+
seq: Iterable[Any], scalarp: Callable[[Any], bool] = ...
|
| 84 |
+
) -> Generator[Any, None, None]: ...
|
| 85 |
+
|
| 86 |
+
class _Stack(Generic[_T]):
|
| 87 |
+
def __init__(self) -> None: ...
|
| 88 |
+
def clear(self) -> None: ...
|
| 89 |
+
def __call__(self) -> _T: ...
|
| 90 |
+
def __len__(self) -> int: ...
|
| 91 |
+
def __getitem__(self, ind: int) -> _T: ...
|
| 92 |
+
def forward(self) -> _T: ...
|
| 93 |
+
def back(self) -> _T: ...
|
| 94 |
+
def push(self, o: _T) -> _T: ...
|
| 95 |
+
def home(self) -> _T: ...
|
| 96 |
+
|
| 97 |
+
def safe_masked_invalid(x: ArrayLike, copy: bool = ...) -> np.ndarray: ...
|
| 98 |
+
def print_cycles(
|
| 99 |
+
objects: Iterable[Any], outstream: IO = ..., show_progress: bool = ...
|
| 100 |
+
) -> None: ...
|
| 101 |
+
|
| 102 |
+
class Grouper(Generic[_T]):
|
| 103 |
+
def __init__(self, init: Iterable[_T] = ...) -> None: ...
|
| 104 |
+
def __contains__(self, item: _T) -> bool: ...
|
| 105 |
+
def join(self, a: _T, *args: _T) -> None: ...
|
| 106 |
+
def joined(self, a: _T, b: _T) -> bool: ...
|
| 107 |
+
def remove(self, a: _T) -> None: ...
|
| 108 |
+
def __iter__(self) -> Iterator[list[_T]]: ...
|
| 109 |
+
def get_siblings(self, a: _T) -> list[_T]: ...
|
| 110 |
+
|
| 111 |
+
class GrouperView(Generic[_T]):
|
| 112 |
+
def __init__(self, grouper: Grouper[_T]) -> None: ...
|
| 113 |
+
def __contains__(self, item: _T) -> bool: ...
|
| 114 |
+
def __iter__(self) -> Iterator[list[_T]]: ...
|
| 115 |
+
def joined(self, a: _T, b: _T) -> bool: ...
|
| 116 |
+
def get_siblings(self, a: _T) -> list[_T]: ...
|
| 117 |
+
|
| 118 |
+
def simple_linear_interpolation(a: ArrayLike, steps: int) -> np.ndarray: ...
|
| 119 |
+
def delete_masked_points(*args): ...
|
| 120 |
+
def _broadcast_with_masks(*args: ArrayLike, compress: bool = ...) -> list[ArrayLike]: ...
|
| 121 |
+
def boxplot_stats(
|
| 122 |
+
X: ArrayLike,
|
| 123 |
+
whis: float | tuple[float, float] = ...,
|
| 124 |
+
bootstrap: int | None = ...,
|
| 125 |
+
labels: ArrayLike | None = ...,
|
| 126 |
+
autorange: bool = ...,
|
| 127 |
+
) -> list[dict[str, Any]]: ...
|
| 128 |
+
|
| 129 |
+
ls_mapper: dict[str, str]
|
| 130 |
+
ls_mapper_r: dict[str, str]
|
| 131 |
+
|
| 132 |
+
def contiguous_regions(mask: ArrayLike) -> list[np.ndarray]: ...
|
| 133 |
+
def is_math_text(s: str) -> bool: ...
|
| 134 |
+
def violin_stats(
|
| 135 |
+
X: ArrayLike, method: Callable, points: int = ..., quantiles: ArrayLike | None = ...
|
| 136 |
+
) -> list[dict[str, Any]]: ...
|
| 137 |
+
def pts_to_prestep(x: ArrayLike, *args: ArrayLike) -> np.ndarray: ...
|
| 138 |
+
def pts_to_poststep(x: ArrayLike, *args: ArrayLike) -> np.ndarray: ...
|
| 139 |
+
def pts_to_midstep(x: np.ndarray, *args: np.ndarray) -> np.ndarray: ...
|
| 140 |
+
|
| 141 |
+
STEP_LOOKUP_MAP: dict[str, Callable]
|
| 142 |
+
|
| 143 |
+
def index_of(y: float | ArrayLike) -> tuple[np.ndarray, np.ndarray]: ...
|
| 144 |
+
def safe_first_element(obj: Collection[_T]) -> _T: ...
|
| 145 |
+
def sanitize_sequence(data): ...
|
| 146 |
+
def normalize_kwargs(
|
| 147 |
+
kw: dict[str, Any],
|
| 148 |
+
alias_mapping: dict[str, list[str]] | type[Artist] | Artist | None = ...,
|
| 149 |
+
) -> dict[str, Any]: ...
|
| 150 |
+
def _lock_path(path: str | os.PathLike) -> contextlib.AbstractContextManager[None]: ...
|
| 151 |
+
def _str_equal(obj: Any, s: str) -> bool: ...
|
| 152 |
+
def _str_lower_equal(obj: Any, s: str) -> bool: ...
|
| 153 |
+
def _array_perimeter(arr: np.ndarray) -> np.ndarray: ...
|
| 154 |
+
def _unfold(arr: np.ndarray, axis: int, size: int, step: int) -> np.ndarray: ...
|
| 155 |
+
def _array_patch_perimeters(x: np.ndarray, rstride: int, cstride: int) -> np.ndarray: ...
|
| 156 |
+
def _setattr_cm(obj: Any, **kwargs) -> contextlib.AbstractContextManager[None]: ...
|
| 157 |
+
|
| 158 |
+
class _OrderedSet(collections.abc.MutableSet):
|
| 159 |
+
def __init__(self) -> None: ...
|
| 160 |
+
def __contains__(self, key) -> bool: ...
|
| 161 |
+
def __iter__(self): ...
|
| 162 |
+
def __len__(self) -> int: ...
|
| 163 |
+
def add(self, key) -> None: ...
|
| 164 |
+
def discard(self, key) -> None: ...
|
| 165 |
+
|
| 166 |
+
def _setup_new_guiapp() -> None: ...
|
| 167 |
+
def _format_approx(number: float, precision: int) -> str: ...
|
| 168 |
+
def _g_sig_digits(value: float, delta: float) -> int: ...
|
| 169 |
+
def _unikey_or_keysym_to_mplkey(unikey: str, keysym: str) -> str: ...
|
| 170 |
+
def _is_torch_array(x: Any) -> bool: ...
|
| 171 |
+
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ap handling utilities, and the `ScalarMappable` mixin.
|
| 3 |
+
|
| 4 |
+
.. seealso::
|
| 5 |
+
|
| 6 |
+
:doc:`/gallery/color/colormap_reference` for a list of builtin colormaps.
|
| 7 |
+
|
| 8 |
+
:ref:`colormap-manipulation` for examples of how to make
|
| 9 |
+
colormaps.
|
| 10 |
+
|
| 11 |
+
:ref:`colormaps` an in-depth discussion of choosing
|
| 12 |
+
colormaps.
|
| 13 |
+
|
| 14 |
+
:ref:`colormapnorms` for more details about data normalization.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
from collections.abc import Mapping
|
| 18 |
+
|
| 19 |
+
import matplotlib as mpl
|
| 20 |
+
from matplotlib import _api, colors
|
| 21 |
+
# TODO make this warn on access
|
| 22 |
+
from matplotlib.colorizer import _ScalarMappable as ScalarMappable # noqa
|
| 23 |
+
from matplotlib._cm import datad
|
| 24 |
+
from matplotlib._cm_listed import cmaps as cmaps_listed
|
| 25 |
+
from matplotlib._cm_multivar import cmap_families as multivar_cmaps
|
| 26 |
+
from matplotlib._cm_bivar import cmaps as bivar_cmaps
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
_LUTSIZE = mpl.rcParams['image.lut']
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def _gen_cmap_registry():
|
| 33 |
+
"""
|
| 34 |
+
Generate a dict mapping standard colormap names to standard colormaps, as
|
| 35 |
+
well as the reversed colormaps.
|
| 36 |
+
"""
|
| 37 |
+
cmap_d = {**cmaps_listed}
|
| 38 |
+
for name, spec in datad.items():
|
| 39 |
+
cmap_d[name] = ( # Precache the cmaps at a fixed lutsize..
|
| 40 |
+
colors.LinearSegmentedColormap(name, spec, _LUTSIZE)
|
| 41 |
+
if 'red' in spec else
|
| 42 |
+
colors.ListedColormap(spec['listed'], name)
|
| 43 |
+
if 'listed' in spec else
|
| 44 |
+
colors.LinearSegmentedColormap.from_list(name, spec, _LUTSIZE))
|
| 45 |
+
|
| 46 |
+
# Register colormap aliases for gray and grey.
|
| 47 |
+
aliases = {
|
| 48 |
+
# alias -> original name
|
| 49 |
+
'grey': 'gray',
|
| 50 |
+
'gist_grey': 'gist_gray',
|
| 51 |
+
'gist_yerg': 'gist_yarg',
|
| 52 |
+
'Grays': 'Greys',
|
| 53 |
+
}
|
| 54 |
+
for alias, original_name in aliases.items():
|
| 55 |
+
cmap = cmap_d[original_name].copy()
|
| 56 |
+
cmap.name = alias
|
| 57 |
+
cmap_d[alias] = cmap
|
| 58 |
+
|
| 59 |
+
# Generate reversed cmaps.
|
| 60 |
+
for cmap in list(cmap_d.values()):
|
| 61 |
+
rmap = cmap.reversed()
|
| 62 |
+
cmap_d[rmap.name] = rmap
|
| 63 |
+
return cmap_d
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
class ColormapRegistry(Mapping):
|
| 67 |
+
r"""
|
| 68 |
+
Container for colormaps that are known to Matplotlib by name.
|
| 69 |
+
|
| 70 |
+
The universal registry instance is `matplotlib.colormaps`. There should be
|
| 71 |
+
no need for users to instantiate `.ColormapRegistry` themselves.
|
| 72 |
+
|
| 73 |
+
Read access uses a dict-like interface mapping names to `.Colormap`\s::
|
| 74 |
+
|
| 75 |
+
import matplotlib as mpl
|
| 76 |
+
cmap = mpl.colormaps['viridis']
|
| 77 |
+
|
| 78 |
+
Returned `.Colormap`\s are copies, so that their modification does not
|
| 79 |
+
change the global definition of the colormap.
|
| 80 |
+
|
| 81 |
+
Additional colormaps can be added via `.ColormapRegistry.register`::
|
| 82 |
+
|
| 83 |
+
mpl.colormaps.register(my_colormap)
|
| 84 |
+
|
| 85 |
+
To get a list of all registered colormaps, you can do::
|
| 86 |
+
|
| 87 |
+
from matplotlib import colormaps
|
| 88 |
+
list(colormaps)
|
| 89 |
+
"""
|
| 90 |
+
def __init__(self, cmaps):
|
| 91 |
+
self._cmaps = cmaps
|
| 92 |
+
self._builtin_cmaps = tuple(cmaps)
|
| 93 |
+
|
| 94 |
+
def __getitem__(self, item):
|
| 95 |
+
try:
|
| 96 |
+
return self._cmaps[item].copy()
|
| 97 |
+
except KeyError:
|
| 98 |
+
raise KeyError(f"{item!r} is not a known colormap name") from None
|
| 99 |
+
|
| 100 |
+
def __iter__(self):
|
| 101 |
+
return iter(self._cmaps)
|
| 102 |
+
|
| 103 |
+
def __len__(self):
|
| 104 |
+
return len(self._cmaps)
|
| 105 |
+
|
| 106 |
+
def __str__(self):
|
| 107 |
+
return ('ColormapRegistry; available colormaps:\n' +
|
| 108 |
+
', '.join(f"'{name}'" for name in self))
|
| 109 |
+
|
| 110 |
+
def __call__(self):
|
| 111 |
+
"""
|
| 112 |
+
Return a list of the registered colormap names.
|
| 113 |
+
|
| 114 |
+
This exists only for backward-compatibility in `.pyplot` which had a
|
| 115 |
+
``plt.colormaps()`` method. The recommended way to get this list is
|
| 116 |
+
now ``list(colormaps)``.
|
| 117 |
+
"""
|
| 118 |
+
return list(self)
|
| 119 |
+
|
| 120 |
+
def register(self, cmap, *, name=None, force=False):
|
| 121 |
+
"""
|
| 122 |
+
Register a new colormap.
|
| 123 |
+
|
| 124 |
+
The colormap name can then be used as a string argument to any ``cmap``
|
| 125 |
+
parameter in Matplotlib. It is also available in ``pyplot.get_cmap``.
|
| 126 |
+
|
| 127 |
+
The colormap registry stores a copy of the given colormap, so that
|
| 128 |
+
future changes to the original colormap instance do not affect the
|
| 129 |
+
registered colormap. Think of this as the registry taking a snapshot
|
| 130 |
+
of the colormap at registration.
|
| 131 |
+
|
| 132 |
+
Parameters
|
| 133 |
+
----------
|
| 134 |
+
cmap : matplotlib.colors.Colormap
|
| 135 |
+
The colormap to register.
|
| 136 |
+
|
| 137 |
+
name : str, optional
|
| 138 |
+
The name for the colormap. If not given, ``cmap.name`` is used.
|
| 139 |
+
|
| 140 |
+
force : bool, default: False
|
| 141 |
+
If False, a ValueError is raised if trying to overwrite an already
|
| 142 |
+
registered name. True supports overwriting registered colormaps
|
| 143 |
+
other than the builtin colormaps.
|
| 144 |
+
"""
|
| 145 |
+
_api.check_isinstance(colors.Colormap, cmap=cmap)
|
| 146 |
+
|
| 147 |
+
name = name or cmap.name
|
| 148 |
+
if name in self:
|
| 149 |
+
if not force:
|
| 150 |
+
# don't allow registering an already existing cmap
|
| 151 |
+
# unless explicitly asked to
|
| 152 |
+
raise ValueError(
|
| 153 |
+
f'A colormap named "{name}" is already registered.')
|
| 154 |
+
elif name in self._builtin_cmaps:
|
| 155 |
+
# We don't allow overriding a builtin.
|
| 156 |
+
raise ValueError("Re-registering the builtin cmap "
|
| 157 |
+
f"{name!r} is not allowed.")
|
| 158 |
+
|
| 159 |
+
# Warn that we are updating an already existing colormap
|
| 160 |
+
_api.warn_external(f"Overwriting the cmap {name!r} "
|
| 161 |
+
"that was already in the registry.")
|
| 162 |
+
|
| 163 |
+
self._cmaps[name] = cmap.copy()
|
| 164 |
+
# Someone may set the extremes of a builtin colormap and want to register it
|
| 165 |
+
# with a different name for future lookups. The object would still have the
|
| 166 |
+
# builtin name, so we should update it to the registered name
|
| 167 |
+
if self._cmaps[name].name != name:
|
| 168 |
+
self._cmaps[name].name = name
|
| 169 |
+
|
| 170 |
+
def unregister(self, name):
|
| 171 |
+
"""
|
| 172 |
+
Remove a colormap from the registry.
|
| 173 |
+
|
| 174 |
+
You cannot remove built-in colormaps.
|
| 175 |
+
|
| 176 |
+
If the named colormap is not registered, returns with no error, raises
|
| 177 |
+
if you try to de-register a default colormap.
|
| 178 |
+
|
| 179 |
+
.. warning::
|
| 180 |
+
|
| 181 |
+
Colormap names are currently a shared namespace that may be used
|
| 182 |
+
by multiple packages. Use `unregister` only if you know you
|
| 183 |
+
have registered that name before. In particular, do not
|
| 184 |
+
unregister just in case to clean the name before registering a
|
| 185 |
+
new colormap.
|
| 186 |
+
|
| 187 |
+
Parameters
|
| 188 |
+
----------
|
| 189 |
+
name : str
|
| 190 |
+
The name of the colormap to be removed.
|
| 191 |
+
|
| 192 |
+
Raises
|
| 193 |
+
------
|
| 194 |
+
ValueError
|
| 195 |
+
If you try to remove a default built-in colormap.
|
| 196 |
+
"""
|
| 197 |
+
if name in self._builtin_cmaps:
|
| 198 |
+
raise ValueError(f"cannot unregister {name!r} which is a builtin "
|
| 199 |
+
"colormap.")
|
| 200 |
+
self._cmaps.pop(name, None)
|
| 201 |
+
|
| 202 |
+
def get_cmap(self, cmap):
|
| 203 |
+
"""
|
| 204 |
+
Return a color map specified through *cmap*.
|
| 205 |
+
|
| 206 |
+
Parameters
|
| 207 |
+
----------
|
| 208 |
+
cmap : str or `~matplotlib.colors.Colormap` or None
|
| 209 |
+
|
| 210 |
+
- if a `.Colormap`, return it
|
| 211 |
+
- if a string, look it up in ``mpl.colormaps``
|
| 212 |
+
- if None, return the Colormap defined in :rc:`image.cmap`
|
| 213 |
+
|
| 214 |
+
Returns
|
| 215 |
+
-------
|
| 216 |
+
Colormap
|
| 217 |
+
"""
|
| 218 |
+
# get the default color map
|
| 219 |
+
if cmap is None:
|
| 220 |
+
return self[mpl.rcParams["image.cmap"]]
|
| 221 |
+
|
| 222 |
+
# if the user passed in a Colormap, simply return it
|
| 223 |
+
if isinstance(cmap, colors.Colormap):
|
| 224 |
+
return cmap
|
| 225 |
+
if isinstance(cmap, str):
|
| 226 |
+
_api.check_in_list(sorted(_colormaps), cmap=cmap)
|
| 227 |
+
# otherwise, it must be a string so look it up
|
| 228 |
+
return self[cmap]
|
| 229 |
+
raise TypeError(
|
| 230 |
+
'get_cmap expects None or an instance of a str or Colormap . ' +
|
| 231 |
+
f'you passed {cmap!r} of type {type(cmap)}'
|
| 232 |
+
)
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
# public access to the colormaps should be via `matplotlib.colormaps`. For now,
|
| 236 |
+
# we still create the registry here, but that should stay an implementation
|
| 237 |
+
# detail.
|
| 238 |
+
_colormaps = ColormapRegistry(_gen_cmap_registry())
|
| 239 |
+
globals().update(_colormaps)
|
| 240 |
+
|
| 241 |
+
_multivar_colormaps = ColormapRegistry(multivar_cmaps)
|
| 242 |
+
|
| 243 |
+
_bivar_colormaps = ColormapRegistry(bivar_cmaps)
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
# This is an exact copy of pyplot.get_cmap(). It was removed in 3.9, but apparently
|
| 247 |
+
# caused more user trouble than expected. Re-added for 3.9.1 and extended the
|
| 248 |
+
# deprecation period for two additional minor releases.
|
| 249 |
+
@_api.deprecated(
|
| 250 |
+
'3.7',
|
| 251 |
+
removal='3.11',
|
| 252 |
+
alternative="``matplotlib.colormaps[name]`` or ``matplotlib.colormaps.get_cmap()``"
|
| 253 |
+
" or ``pyplot.get_cmap()``"
|
| 254 |
+
)
|
| 255 |
+
def get_cmap(name=None, lut=None):
|
| 256 |
+
"""
|
| 257 |
+
Get a colormap instance, defaulting to rc values if *name* is None.
|
| 258 |
+
|
| 259 |
+
Parameters
|
| 260 |
+
----------
|
| 261 |
+
name : `~matplotlib.colors.Colormap` or str or None, default: None
|
| 262 |
+
If a `.Colormap` instance, it will be returned. Otherwise, the name of
|
| 263 |
+
a colormap known to Matplotlib, which will be resampled by *lut*. The
|
| 264 |
+
default, None, means :rc:`image.cmap`.
|
| 265 |
+
lut : int or None, default: None
|
| 266 |
+
If *name* is not already a Colormap instance and *lut* is not None, the
|
| 267 |
+
colormap will be resampled to have *lut* entries in the lookup table.
|
| 268 |
+
|
| 269 |
+
Returns
|
| 270 |
+
-------
|
| 271 |
+
Colormap
|
| 272 |
+
"""
|
| 273 |
+
if name is None:
|
| 274 |
+
name = mpl.rcParams['image.cmap']
|
| 275 |
+
if isinstance(name, colors.Colormap):
|
| 276 |
+
return name
|
| 277 |
+
_api.check_in_list(sorted(_colormaps), name=name)
|
| 278 |
+
if lut is None:
|
| 279 |
+
return _colormaps[name]
|
| 280 |
+
else:
|
| 281 |
+
return _colormaps[name].resampled(lut)
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def _ensure_cmap(cmap):
|
| 285 |
+
"""
|
| 286 |
+
Ensure that we have a `.Colormap` object.
|
| 287 |
+
|
| 288 |
+
For internal use to preserve type stability of errors.
|
| 289 |
+
|
| 290 |
+
Parameters
|
| 291 |
+
----------
|
| 292 |
+
cmap : None, str, Colormap
|
| 293 |
+
|
| 294 |
+
- if a `Colormap`, return it
|
| 295 |
+
- if a string, look it up in mpl.colormaps
|
| 296 |
+
- if None, look up the default color map in mpl.colormaps
|
| 297 |
+
|
| 298 |
+
Returns
|
| 299 |
+
-------
|
| 300 |
+
Colormap
|
| 301 |
+
|
| 302 |
+
"""
|
| 303 |
+
if isinstance(cmap, colors.Colormap):
|
| 304 |
+
return cmap
|
| 305 |
+
cmap_name = cmap if cmap is not None else mpl.rcParams["image.cmap"]
|
| 306 |
+
# use check_in_list to ensure type stability of the exception raised by
|
| 307 |
+
# the internal usage of this (ValueError vs KeyError)
|
| 308 |
+
if cmap_name not in _colormaps:
|
| 309 |
+
_api.check_in_list(sorted(_colormaps), cmap=cmap_name)
|
| 310 |
+
return mpl.colormaps[cmap_name]
|
llava_video/lib/python3.10/site-packages/matplotlib/collections.pyi
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable, Iterable, Sequence
|
| 2 |
+
from typing import Literal
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
from numpy.typing import ArrayLike, NDArray
|
| 6 |
+
|
| 7 |
+
from . import colorizer, transforms
|
| 8 |
+
from .backend_bases import MouseEvent
|
| 9 |
+
from .artist import Artist
|
| 10 |
+
from .colors import Normalize, Colormap
|
| 11 |
+
from .lines import Line2D
|
| 12 |
+
from .path import Path
|
| 13 |
+
from .patches import Patch
|
| 14 |
+
from .ticker import Locator, Formatter
|
| 15 |
+
from .tri import Triangulation
|
| 16 |
+
from .typing import ColorType, LineStyleType, CapStyleType, JoinStyleType
|
| 17 |
+
|
| 18 |
+
class Collection(colorizer.ColorizingArtist):
|
| 19 |
+
def __init__(
|
| 20 |
+
self,
|
| 21 |
+
*,
|
| 22 |
+
edgecolors: ColorType | Sequence[ColorType] | None = ...,
|
| 23 |
+
facecolors: ColorType | Sequence[ColorType] | None = ...,
|
| 24 |
+
linewidths: float | Sequence[float] | None = ...,
|
| 25 |
+
linestyles: LineStyleType | Sequence[LineStyleType] = ...,
|
| 26 |
+
capstyle: CapStyleType | None = ...,
|
| 27 |
+
joinstyle: JoinStyleType | None = ...,
|
| 28 |
+
antialiaseds: bool | Sequence[bool] | None = ...,
|
| 29 |
+
offsets: tuple[float, float] | Sequence[tuple[float, float]] | None = ...,
|
| 30 |
+
offset_transform: transforms.Transform | None = ...,
|
| 31 |
+
norm: Normalize | None = ...,
|
| 32 |
+
cmap: Colormap | None = ...,
|
| 33 |
+
colorizer: colorizer.Colorizer | None = ...,
|
| 34 |
+
pickradius: float = ...,
|
| 35 |
+
hatch: str | None = ...,
|
| 36 |
+
urls: Sequence[str] | None = ...,
|
| 37 |
+
zorder: float = ...,
|
| 38 |
+
**kwargs
|
| 39 |
+
) -> None: ...
|
| 40 |
+
def get_paths(self) -> Sequence[Path]: ...
|
| 41 |
+
def set_paths(self, paths: Sequence[Path]) -> None: ...
|
| 42 |
+
def get_transforms(self) -> Sequence[transforms.Transform]: ...
|
| 43 |
+
def get_offset_transform(self) -> transforms.Transform: ...
|
| 44 |
+
def set_offset_transform(self, offset_transform: transforms.Transform) -> None: ...
|
| 45 |
+
def get_datalim(self, transData: transforms.Transform) -> transforms.Bbox: ...
|
| 46 |
+
def set_pickradius(self, pickradius: float) -> None: ...
|
| 47 |
+
def get_pickradius(self) -> float: ...
|
| 48 |
+
def set_urls(self, urls: Sequence[str | None]) -> None: ...
|
| 49 |
+
def get_urls(self) -> Sequence[str | None]: ...
|
| 50 |
+
def set_hatch(self, hatch: str) -> None: ...
|
| 51 |
+
def get_hatch(self) -> str: ...
|
| 52 |
+
def set_hatch_linewidth(self, lw: float) -> None: ...
|
| 53 |
+
def get_hatch_linewidth(self) -> float: ...
|
| 54 |
+
def set_offsets(self, offsets: ArrayLike) -> None: ...
|
| 55 |
+
def get_offsets(self) -> ArrayLike: ...
|
| 56 |
+
def set_linewidth(self, lw: float | Sequence[float]) -> None: ...
|
| 57 |
+
def set_linestyle(self, ls: LineStyleType | Sequence[LineStyleType]) -> None: ...
|
| 58 |
+
def set_capstyle(self, cs: CapStyleType) -> None: ...
|
| 59 |
+
def get_capstyle(self) -> Literal["butt", "projecting", "round"] | None: ...
|
| 60 |
+
def set_joinstyle(self, js: JoinStyleType) -> None: ...
|
| 61 |
+
def get_joinstyle(self) -> Literal["miter", "round", "bevel"] | None: ...
|
| 62 |
+
def set_antialiased(self, aa: bool | Sequence[bool]) -> None: ...
|
| 63 |
+
def get_antialiased(self) -> NDArray[np.bool_]: ...
|
| 64 |
+
def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ...
|
| 65 |
+
def set_facecolor(self, c: ColorType | Sequence[ColorType]) -> None: ...
|
| 66 |
+
def get_facecolor(self) -> ColorType | Sequence[ColorType]: ...
|
| 67 |
+
def get_edgecolor(self) -> ColorType | Sequence[ColorType]: ...
|
| 68 |
+
def set_edgecolor(self, c: ColorType | Sequence[ColorType]) -> None: ...
|
| 69 |
+
def set_alpha(self, alpha: float | Sequence[float] | None) -> None: ...
|
| 70 |
+
def get_linewidth(self) -> float | Sequence[float]: ...
|
| 71 |
+
def get_linestyle(self) -> LineStyleType | Sequence[LineStyleType]: ...
|
| 72 |
+
def update_scalarmappable(self) -> None: ...
|
| 73 |
+
def get_fill(self) -> bool: ...
|
| 74 |
+
def update_from(self, other: Artist) -> None: ...
|
| 75 |
+
|
| 76 |
+
class _CollectionWithSizes(Collection):
|
| 77 |
+
def get_sizes(self) -> np.ndarray: ...
|
| 78 |
+
def set_sizes(self, sizes: ArrayLike | None, dpi: float = ...) -> None: ...
|
| 79 |
+
|
| 80 |
+
class PathCollection(_CollectionWithSizes):
|
| 81 |
+
def __init__(
|
| 82 |
+
self, paths: Sequence[Path], sizes: ArrayLike | None = ..., **kwargs
|
| 83 |
+
) -> None: ...
|
| 84 |
+
def set_paths(self, paths: Sequence[Path]) -> None: ...
|
| 85 |
+
def get_paths(self) -> Sequence[Path]: ...
|
| 86 |
+
def legend_elements(
|
| 87 |
+
self,
|
| 88 |
+
prop: Literal["colors", "sizes"] = ...,
|
| 89 |
+
num: int | Literal["auto"] | ArrayLike | Locator = ...,
|
| 90 |
+
fmt: str | Formatter | None = ...,
|
| 91 |
+
func: Callable[[ArrayLike], ArrayLike] = ...,
|
| 92 |
+
**kwargs,
|
| 93 |
+
) -> tuple[list[Line2D], list[str]]: ...
|
| 94 |
+
|
| 95 |
+
class PolyCollection(_CollectionWithSizes):
|
| 96 |
+
def __init__(
|
| 97 |
+
self,
|
| 98 |
+
verts: Sequence[ArrayLike],
|
| 99 |
+
sizes: ArrayLike | None = ...,
|
| 100 |
+
*,
|
| 101 |
+
closed: bool = ...,
|
| 102 |
+
**kwargs
|
| 103 |
+
) -> None: ...
|
| 104 |
+
def set_verts(
|
| 105 |
+
self, verts: Sequence[ArrayLike | Path], closed: bool = ...
|
| 106 |
+
) -> None: ...
|
| 107 |
+
def set_paths(self, verts: Sequence[Path], closed: bool = ...) -> None: ...
|
| 108 |
+
def set_verts_and_codes(
|
| 109 |
+
self, verts: Sequence[ArrayLike | Path], codes: Sequence[int]
|
| 110 |
+
) -> None: ...
|
| 111 |
+
|
| 112 |
+
class FillBetweenPolyCollection(PolyCollection):
|
| 113 |
+
def __init__(
|
| 114 |
+
self,
|
| 115 |
+
t_direction: Literal["x", "y"],
|
| 116 |
+
t: ArrayLike,
|
| 117 |
+
f1: ArrayLike,
|
| 118 |
+
f2: ArrayLike,
|
| 119 |
+
*,
|
| 120 |
+
where: Sequence[bool] | None = ...,
|
| 121 |
+
interpolate: bool = ...,
|
| 122 |
+
step: Literal["pre", "post", "mid"] | None = ...,
|
| 123 |
+
**kwargs,
|
| 124 |
+
) -> None: ...
|
| 125 |
+
def set_data(
|
| 126 |
+
self,
|
| 127 |
+
t: ArrayLike,
|
| 128 |
+
f1: ArrayLike,
|
| 129 |
+
f2: ArrayLike,
|
| 130 |
+
*,
|
| 131 |
+
where: Sequence[bool] | None = ...,
|
| 132 |
+
) -> None: ...
|
| 133 |
+
def get_datalim(self, transData: transforms.Transform) -> transforms.Bbox: ...
|
| 134 |
+
|
| 135 |
+
class RegularPolyCollection(_CollectionWithSizes):
|
| 136 |
+
def __init__(
|
| 137 |
+
self, numsides: int, *, rotation: float = ..., sizes: ArrayLike = ..., **kwargs
|
| 138 |
+
) -> None: ...
|
| 139 |
+
def get_numsides(self) -> int: ...
|
| 140 |
+
def get_rotation(self) -> float: ...
|
| 141 |
+
|
| 142 |
+
class StarPolygonCollection(RegularPolyCollection): ...
|
| 143 |
+
class AsteriskPolygonCollection(RegularPolyCollection): ...
|
| 144 |
+
|
| 145 |
+
class LineCollection(Collection):
|
| 146 |
+
def __init__(
|
| 147 |
+
self, segments: Sequence[ArrayLike], *, zorder: float = ..., **kwargs
|
| 148 |
+
) -> None: ...
|
| 149 |
+
def set_segments(self, segments: Sequence[ArrayLike] | None) -> None: ...
|
| 150 |
+
def set_verts(self, segments: Sequence[ArrayLike] | None) -> None: ...
|
| 151 |
+
def set_paths(self, segments: Sequence[ArrayLike] | None) -> None: ... # type: ignore[override]
|
| 152 |
+
def get_segments(self) -> list[np.ndarray]: ...
|
| 153 |
+
def set_color(self, c: ColorType | Sequence[ColorType]) -> None: ...
|
| 154 |
+
def set_colors(self, c: ColorType | Sequence[ColorType]) -> None: ...
|
| 155 |
+
def set_gapcolor(self, gapcolor: ColorType | Sequence[ColorType] | None) -> None: ...
|
| 156 |
+
def get_color(self) -> ColorType | Sequence[ColorType]: ...
|
| 157 |
+
def get_colors(self) -> ColorType | Sequence[ColorType]: ...
|
| 158 |
+
def get_gapcolor(self) -> ColorType | Sequence[ColorType] | None: ...
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
class EventCollection(LineCollection):
|
| 162 |
+
def __init__(
|
| 163 |
+
self,
|
| 164 |
+
positions: ArrayLike,
|
| 165 |
+
orientation: Literal["horizontal", "vertical"] = ...,
|
| 166 |
+
*,
|
| 167 |
+
lineoffset: float = ...,
|
| 168 |
+
linelength: float = ...,
|
| 169 |
+
linewidth: float | Sequence[float] | None = ...,
|
| 170 |
+
color: ColorType | Sequence[ColorType] | None = ...,
|
| 171 |
+
linestyle: LineStyleType | Sequence[LineStyleType] = ...,
|
| 172 |
+
antialiased: bool | Sequence[bool] | None = ...,
|
| 173 |
+
**kwargs
|
| 174 |
+
) -> None: ...
|
| 175 |
+
def get_positions(self) -> list[float]: ...
|
| 176 |
+
def set_positions(self, positions: Sequence[float] | None) -> None: ...
|
| 177 |
+
def add_positions(self, position: Sequence[float] | None) -> None: ...
|
| 178 |
+
def extend_positions(self, position: Sequence[float] | None) -> None: ...
|
| 179 |
+
def append_positions(self, position: Sequence[float] | None) -> None: ...
|
| 180 |
+
def is_horizontal(self) -> bool: ...
|
| 181 |
+
def get_orientation(self) -> Literal["horizontal", "vertical"]: ...
|
| 182 |
+
def switch_orientation(self) -> None: ...
|
| 183 |
+
def set_orientation(
|
| 184 |
+
self, orientation: Literal["horizontal", "vertical"]
|
| 185 |
+
) -> None: ...
|
| 186 |
+
def get_linelength(self) -> float | Sequence[float]: ...
|
| 187 |
+
def set_linelength(self, linelength: float | Sequence[float]) -> None: ...
|
| 188 |
+
def get_lineoffset(self) -> float: ...
|
| 189 |
+
def set_lineoffset(self, lineoffset: float) -> None: ...
|
| 190 |
+
def get_linewidth(self) -> float: ...
|
| 191 |
+
def get_linewidths(self) -> Sequence[float]: ...
|
| 192 |
+
def get_color(self) -> ColorType: ...
|
| 193 |
+
|
| 194 |
+
class CircleCollection(_CollectionWithSizes):
|
| 195 |
+
def __init__(self, sizes: float | ArrayLike, **kwargs) -> None: ...
|
| 196 |
+
|
| 197 |
+
class EllipseCollection(Collection):
|
| 198 |
+
def __init__(
|
| 199 |
+
self,
|
| 200 |
+
widths: ArrayLike,
|
| 201 |
+
heights: ArrayLike,
|
| 202 |
+
angles: ArrayLike,
|
| 203 |
+
*,
|
| 204 |
+
units: Literal[
|
| 205 |
+
"points", "inches", "dots", "width", "height", "x", "y", "xy"
|
| 206 |
+
] = ...,
|
| 207 |
+
**kwargs
|
| 208 |
+
) -> None: ...
|
| 209 |
+
def set_widths(self, widths: ArrayLike) -> None: ...
|
| 210 |
+
def set_heights(self, heights: ArrayLike) -> None: ...
|
| 211 |
+
def set_angles(self, angles: ArrayLike) -> None: ...
|
| 212 |
+
def get_widths(self) -> ArrayLike: ...
|
| 213 |
+
def get_heights(self) -> ArrayLike: ...
|
| 214 |
+
def get_angles(self) -> ArrayLike: ...
|
| 215 |
+
|
| 216 |
+
class PatchCollection(Collection):
|
| 217 |
+
def __init__(
|
| 218 |
+
self, patches: Iterable[Patch], *, match_original: bool = ..., **kwargs
|
| 219 |
+
) -> None: ...
|
| 220 |
+
def set_paths(self, patches: Iterable[Patch]) -> None: ... # type: ignore[override]
|
| 221 |
+
|
| 222 |
+
class TriMesh(Collection):
|
| 223 |
+
def __init__(self, triangulation: Triangulation, **kwargs) -> None: ...
|
| 224 |
+
def get_paths(self) -> list[Path]: ...
|
| 225 |
+
# Parent class has an argument, perhaps add a noop arg?
|
| 226 |
+
def set_paths(self) -> None: ... # type: ignore[override]
|
| 227 |
+
@staticmethod
|
| 228 |
+
def convert_mesh_to_paths(tri: Triangulation) -> list[Path]: ...
|
| 229 |
+
|
| 230 |
+
class _MeshData:
|
| 231 |
+
def __init__(
|
| 232 |
+
self,
|
| 233 |
+
coordinates: ArrayLike,
|
| 234 |
+
*,
|
| 235 |
+
shading: Literal["flat", "gouraud"] = ...,
|
| 236 |
+
) -> None: ...
|
| 237 |
+
def set_array(self, A: ArrayLike | None) -> None: ...
|
| 238 |
+
def get_coordinates(self) -> ArrayLike: ...
|
| 239 |
+
def get_facecolor(self) -> ColorType | Sequence[ColorType]: ...
|
| 240 |
+
def get_edgecolor(self) -> ColorType | Sequence[ColorType]: ...
|
| 241 |
+
|
| 242 |
+
class QuadMesh(_MeshData, Collection):
|
| 243 |
+
def __init__(
|
| 244 |
+
self,
|
| 245 |
+
coordinates: ArrayLike,
|
| 246 |
+
*,
|
| 247 |
+
antialiased: bool = ...,
|
| 248 |
+
shading: Literal["flat", "gouraud"] = ...,
|
| 249 |
+
**kwargs
|
| 250 |
+
) -> None: ...
|
| 251 |
+
def get_paths(self) -> list[Path]: ...
|
| 252 |
+
# Parent class has an argument, perhaps add a noop arg?
|
| 253 |
+
def set_paths(self) -> None: ... # type: ignore[override]
|
| 254 |
+
def get_datalim(self, transData: transforms.Transform) -> transforms.Bbox: ...
|
| 255 |
+
def get_cursor_data(self, event: MouseEvent) -> float: ...
|
| 256 |
+
|
| 257 |
+
class PolyQuadMesh(_MeshData, PolyCollection):
|
| 258 |
+
def __init__(
|
| 259 |
+
self,
|
| 260 |
+
coordinates: ArrayLike,
|
| 261 |
+
**kwargs
|
| 262 |
+
) -> None: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/colorbar.py
ADDED
|
@@ -0,0 +1,1568 @@
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Colorbars are a visualization of the mapping from scalar values to colors.
|
| 3 |
+
In Matplotlib they are drawn into a dedicated `~.axes.Axes`.
|
| 4 |
+
|
| 5 |
+
.. note::
|
| 6 |
+
Colorbars are typically created through `.Figure.colorbar` or its pyplot
|
| 7 |
+
wrapper `.pyplot.colorbar`, which internally use `.Colorbar` together with
|
| 8 |
+
`.make_axes_gridspec` (for `.GridSpec`-positioned Axes) or `.make_axes` (for
|
| 9 |
+
non-`.GridSpec`-positioned Axes).
|
| 10 |
+
|
| 11 |
+
End-users most likely won't need to directly use this module's API.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
import logging
|
| 15 |
+
|
| 16 |
+
import numpy as np
|
| 17 |
+
|
| 18 |
+
import matplotlib as mpl
|
| 19 |
+
from matplotlib import _api, cbook, collections, cm, colors, contour, ticker
|
| 20 |
+
import matplotlib.artist as martist
|
| 21 |
+
import matplotlib.patches as mpatches
|
| 22 |
+
import matplotlib.path as mpath
|
| 23 |
+
import matplotlib.spines as mspines
|
| 24 |
+
import matplotlib.transforms as mtransforms
|
| 25 |
+
from matplotlib import _docstring
|
| 26 |
+
|
| 27 |
+
_log = logging.getLogger(__name__)
|
| 28 |
+
|
| 29 |
+
_docstring.interpd.register(
|
| 30 |
+
_make_axes_kw_doc="""
|
| 31 |
+
location : None or {'left', 'right', 'top', 'bottom'}
|
| 32 |
+
The location, relative to the parent Axes, where the colorbar Axes
|
| 33 |
+
is created. It also determines the *orientation* of the colorbar
|
| 34 |
+
(colorbars on the left and right are vertical, colorbars at the top
|
| 35 |
+
and bottom are horizontal). If None, the location will come from the
|
| 36 |
+
*orientation* if it is set (vertical colorbars on the right, horizontal
|
| 37 |
+
ones at the bottom), or default to 'right' if *orientation* is unset.
|
| 38 |
+
|
| 39 |
+
orientation : None or {'vertical', 'horizontal'}
|
| 40 |
+
The orientation of the colorbar. It is preferable to set the *location*
|
| 41 |
+
of the colorbar, as that also determines the *orientation*; passing
|
| 42 |
+
incompatible values for *location* and *orientation* raises an exception.
|
| 43 |
+
|
| 44 |
+
fraction : float, default: 0.15
|
| 45 |
+
Fraction of original Axes to use for colorbar.
|
| 46 |
+
|
| 47 |
+
shrink : float, default: 1.0
|
| 48 |
+
Fraction by which to multiply the size of the colorbar.
|
| 49 |
+
|
| 50 |
+
aspect : float, default: 20
|
| 51 |
+
Ratio of long to short dimensions.
|
| 52 |
+
|
| 53 |
+
pad : float, default: 0.05 if vertical, 0.15 if horizontal
|
| 54 |
+
Fraction of original Axes between colorbar and new image Axes.
|
| 55 |
+
|
| 56 |
+
anchor : (float, float), optional
|
| 57 |
+
The anchor point of the colorbar Axes.
|
| 58 |
+
Defaults to (0.0, 0.5) if vertical; (0.5, 1.0) if horizontal.
|
| 59 |
+
|
| 60 |
+
panchor : (float, float), or *False*, optional
|
| 61 |
+
The anchor point of the colorbar parent Axes. If *False*, the parent
|
| 62 |
+
axes' anchor will be unchanged.
|
| 63 |
+
Defaults to (1.0, 0.5) if vertical; (0.5, 0.0) if horizontal.""",
|
| 64 |
+
_colormap_kw_doc="""
|
| 65 |
+
extend : {'neither', 'both', 'min', 'max'}
|
| 66 |
+
Make pointed end(s) for out-of-range values (unless 'neither'). These are
|
| 67 |
+
set for a given colormap using the colormap set_under and set_over methods.
|
| 68 |
+
|
| 69 |
+
extendfrac : {*None*, 'auto', length, lengths}
|
| 70 |
+
If set to *None*, both the minimum and maximum triangular colorbar
|
| 71 |
+
extensions will have a length of 5% of the interior colorbar length (this
|
| 72 |
+
is the default setting).
|
| 73 |
+
|
| 74 |
+
If set to 'auto', makes the triangular colorbar extensions the same lengths
|
| 75 |
+
as the interior boxes (when *spacing* is set to 'uniform') or the same
|
| 76 |
+
lengths as the respective adjacent interior boxes (when *spacing* is set to
|
| 77 |
+
'proportional').
|
| 78 |
+
|
| 79 |
+
If a scalar, indicates the length of both the minimum and maximum
|
| 80 |
+
triangular colorbar extensions as a fraction of the interior colorbar
|
| 81 |
+
length. A two-element sequence of fractions may also be given, indicating
|
| 82 |
+
the lengths of the minimum and maximum colorbar extensions respectively as
|
| 83 |
+
a fraction of the interior colorbar length.
|
| 84 |
+
|
| 85 |
+
extendrect : bool
|
| 86 |
+
If *False* the minimum and maximum colorbar extensions will be triangular
|
| 87 |
+
(the default). If *True* the extensions will be rectangular.
|
| 88 |
+
|
| 89 |
+
ticks : None or list of ticks or Locator
|
| 90 |
+
If None, ticks are determined automatically from the input.
|
| 91 |
+
|
| 92 |
+
format : None or str or Formatter
|
| 93 |
+
If None, `~.ticker.ScalarFormatter` is used.
|
| 94 |
+
Format strings, e.g., ``"%4.2e"`` or ``"{x:.2e}"``, are supported.
|
| 95 |
+
An alternative `~.ticker.Formatter` may be given instead.
|
| 96 |
+
|
| 97 |
+
drawedges : bool
|
| 98 |
+
Whether to draw lines at color boundaries.
|
| 99 |
+
|
| 100 |
+
label : str
|
| 101 |
+
The label on the colorbar's long axis.
|
| 102 |
+
|
| 103 |
+
boundaries, values : None or a sequence
|
| 104 |
+
If unset, the colormap will be displayed on a 0-1 scale.
|
| 105 |
+
If sequences, *values* must have a length 1 less than *boundaries*. For
|
| 106 |
+
each region delimited by adjacent entries in *boundaries*, the color mapped
|
| 107 |
+
to the corresponding value in *values* will be used. The size of each
|
| 108 |
+
region is determined by the *spacing* parameter.
|
| 109 |
+
Normally only useful for indexed colors (i.e. ``norm=NoNorm()``) or other
|
| 110 |
+
unusual circumstances.
|
| 111 |
+
|
| 112 |
+
spacing : {'uniform', 'proportional'}
|
| 113 |
+
For discrete colorbars (`.BoundaryNorm` or contours), 'uniform' gives each
|
| 114 |
+
color the same space; 'proportional' makes the space proportional to the
|
| 115 |
+
data interval.""")
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def _set_ticks_on_axis_warn(*args, **kwargs):
|
| 119 |
+
# a top level function which gets put in at the axes'
|
| 120 |
+
# set_xticks and set_yticks by Colorbar.__init__.
|
| 121 |
+
_api.warn_external("Use the colorbar set_ticks() method instead.")
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
class _ColorbarSpine(mspines.Spine):
|
| 125 |
+
def __init__(self, axes):
|
| 126 |
+
self._ax = axes
|
| 127 |
+
super().__init__(axes, 'colorbar', mpath.Path(np.empty((0, 2))))
|
| 128 |
+
mpatches.Patch.set_transform(self, axes.transAxes)
|
| 129 |
+
|
| 130 |
+
def get_window_extent(self, renderer=None):
|
| 131 |
+
# This Spine has no Axis associated with it, and doesn't need to adjust
|
| 132 |
+
# its location, so we can directly get the window extent from the
|
| 133 |
+
# super-super-class.
|
| 134 |
+
return mpatches.Patch.get_window_extent(self, renderer=renderer)
|
| 135 |
+
|
| 136 |
+
def set_xy(self, xy):
|
| 137 |
+
self._path = mpath.Path(xy, closed=True)
|
| 138 |
+
self._xy = xy
|
| 139 |
+
self.stale = True
|
| 140 |
+
|
| 141 |
+
def draw(self, renderer):
|
| 142 |
+
ret = mpatches.Patch.draw(self, renderer)
|
| 143 |
+
self.stale = False
|
| 144 |
+
return ret
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class _ColorbarAxesLocator:
|
| 148 |
+
"""
|
| 149 |
+
Shrink the Axes if there are triangular or rectangular extends.
|
| 150 |
+
"""
|
| 151 |
+
def __init__(self, cbar):
|
| 152 |
+
self._cbar = cbar
|
| 153 |
+
self._orig_locator = cbar.ax._axes_locator
|
| 154 |
+
|
| 155 |
+
def __call__(self, ax, renderer):
|
| 156 |
+
if self._orig_locator is not None:
|
| 157 |
+
pos = self._orig_locator(ax, renderer)
|
| 158 |
+
else:
|
| 159 |
+
pos = ax.get_position(original=True)
|
| 160 |
+
if self._cbar.extend == 'neither':
|
| 161 |
+
return pos
|
| 162 |
+
|
| 163 |
+
y, extendlen = self._cbar._proportional_y()
|
| 164 |
+
if not self._cbar._extend_lower():
|
| 165 |
+
extendlen[0] = 0
|
| 166 |
+
if not self._cbar._extend_upper():
|
| 167 |
+
extendlen[1] = 0
|
| 168 |
+
len = sum(extendlen) + 1
|
| 169 |
+
shrink = 1 / len
|
| 170 |
+
offset = extendlen[0] / len
|
| 171 |
+
# we need to reset the aspect ratio of the axes to account
|
| 172 |
+
# of the extends...
|
| 173 |
+
if hasattr(ax, '_colorbar_info'):
|
| 174 |
+
aspect = ax._colorbar_info['aspect']
|
| 175 |
+
else:
|
| 176 |
+
aspect = False
|
| 177 |
+
# now shrink and/or offset to take into account the
|
| 178 |
+
# extend tri/rectangles.
|
| 179 |
+
if self._cbar.orientation == 'vertical':
|
| 180 |
+
if aspect:
|
| 181 |
+
self._cbar.ax.set_box_aspect(aspect*shrink)
|
| 182 |
+
pos = pos.shrunk(1, shrink).translated(0, offset * pos.height)
|
| 183 |
+
else:
|
| 184 |
+
if aspect:
|
| 185 |
+
self._cbar.ax.set_box_aspect(1/(aspect * shrink))
|
| 186 |
+
pos = pos.shrunk(shrink, 1).translated(offset * pos.width, 0)
|
| 187 |
+
return pos
|
| 188 |
+
|
| 189 |
+
def get_subplotspec(self):
|
| 190 |
+
# make tight_layout happy..
|
| 191 |
+
return (
|
| 192 |
+
self._cbar.ax.get_subplotspec()
|
| 193 |
+
or getattr(self._orig_locator, "get_subplotspec", lambda: None)())
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
@_docstring.interpd
|
| 197 |
+
class Colorbar:
|
| 198 |
+
r"""
|
| 199 |
+
Draw a colorbar in an existing Axes.
|
| 200 |
+
|
| 201 |
+
Typically, colorbars are created using `.Figure.colorbar` or
|
| 202 |
+
`.pyplot.colorbar` and associated with `.ScalarMappable`\s (such as an
|
| 203 |
+
`.AxesImage` generated via `~.axes.Axes.imshow`).
|
| 204 |
+
|
| 205 |
+
In order to draw a colorbar not associated with other elements in the
|
| 206 |
+
figure, e.g. when showing a colormap by itself, one can create an empty
|
| 207 |
+
`.ScalarMappable`, or directly pass *cmap* and *norm* instead of *mappable*
|
| 208 |
+
to `Colorbar`.
|
| 209 |
+
|
| 210 |
+
Useful public methods are :meth:`set_label` and :meth:`add_lines`.
|
| 211 |
+
|
| 212 |
+
Attributes
|
| 213 |
+
----------
|
| 214 |
+
ax : `~matplotlib.axes.Axes`
|
| 215 |
+
The `~.axes.Axes` instance in which the colorbar is drawn.
|
| 216 |
+
lines : list
|
| 217 |
+
A list of `.LineCollection` (empty if no lines were drawn).
|
| 218 |
+
dividers : `.LineCollection`
|
| 219 |
+
A LineCollection (empty if *drawedges* is ``False``).
|
| 220 |
+
|
| 221 |
+
Parameters
|
| 222 |
+
----------
|
| 223 |
+
ax : `~matplotlib.axes.Axes`
|
| 224 |
+
The `~.axes.Axes` instance in which the colorbar is drawn.
|
| 225 |
+
|
| 226 |
+
mappable : `.ScalarMappable`
|
| 227 |
+
The mappable whose colormap and norm will be used.
|
| 228 |
+
|
| 229 |
+
To show the under- and over- value colors, the mappable's norm should
|
| 230 |
+
be specified as ::
|
| 231 |
+
|
| 232 |
+
norm = colors.Normalize(clip=False)
|
| 233 |
+
|
| 234 |
+
To show the colors versus index instead of on a 0-1 scale, use::
|
| 235 |
+
|
| 236 |
+
norm=colors.NoNorm()
|
| 237 |
+
|
| 238 |
+
cmap : `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
|
| 239 |
+
The colormap to use. This parameter is ignored, unless *mappable* is
|
| 240 |
+
None.
|
| 241 |
+
|
| 242 |
+
norm : `~matplotlib.colors.Normalize`
|
| 243 |
+
The normalization to use. This parameter is ignored, unless *mappable*
|
| 244 |
+
is None.
|
| 245 |
+
|
| 246 |
+
alpha : float
|
| 247 |
+
The colorbar transparency between 0 (transparent) and 1 (opaque).
|
| 248 |
+
|
| 249 |
+
orientation : None or {'vertical', 'horizontal'}
|
| 250 |
+
If None, use the value determined by *location*. If both
|
| 251 |
+
*orientation* and *location* are None then defaults to 'vertical'.
|
| 252 |
+
|
| 253 |
+
ticklocation : {'auto', 'left', 'right', 'top', 'bottom'}
|
| 254 |
+
The location of the colorbar ticks. The *ticklocation* must match
|
| 255 |
+
*orientation*. For example, a horizontal colorbar can only have ticks
|
| 256 |
+
at the top or the bottom. If 'auto', the ticks will be the same as
|
| 257 |
+
*location*, so a colorbar to the left will have ticks to the left. If
|
| 258 |
+
*location* is None, the ticks will be at the bottom for a horizontal
|
| 259 |
+
colorbar and at the right for a vertical.
|
| 260 |
+
|
| 261 |
+
%(_colormap_kw_doc)s
|
| 262 |
+
|
| 263 |
+
location : None or {'left', 'right', 'top', 'bottom'}
|
| 264 |
+
Set the *orientation* and *ticklocation* of the colorbar using a
|
| 265 |
+
single argument. Colorbars on the left and right are vertical,
|
| 266 |
+
colorbars at the top and bottom are horizontal. The *ticklocation* is
|
| 267 |
+
the same as *location*, so if *location* is 'top', the ticks are on
|
| 268 |
+
the top. *orientation* and/or *ticklocation* can be provided as well
|
| 269 |
+
and overrides the value set by *location*, but there will be an error
|
| 270 |
+
for incompatible combinations.
|
| 271 |
+
|
| 272 |
+
.. versionadded:: 3.7
|
| 273 |
+
"""
|
| 274 |
+
|
| 275 |
+
n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
|
| 276 |
+
|
| 277 |
+
def __init__(self, ax, mappable=None, *, cmap=None,
|
| 278 |
+
norm=None,
|
| 279 |
+
alpha=None,
|
| 280 |
+
values=None,
|
| 281 |
+
boundaries=None,
|
| 282 |
+
orientation=None,
|
| 283 |
+
ticklocation='auto',
|
| 284 |
+
extend=None,
|
| 285 |
+
spacing='uniform', # uniform or proportional
|
| 286 |
+
ticks=None,
|
| 287 |
+
format=None,
|
| 288 |
+
drawedges=False,
|
| 289 |
+
extendfrac=None,
|
| 290 |
+
extendrect=False,
|
| 291 |
+
label='',
|
| 292 |
+
location=None,
|
| 293 |
+
):
|
| 294 |
+
|
| 295 |
+
if mappable is None:
|
| 296 |
+
mappable = cm.ScalarMappable(norm=norm, cmap=cmap)
|
| 297 |
+
|
| 298 |
+
self.mappable = mappable
|
| 299 |
+
cmap = mappable.cmap
|
| 300 |
+
norm = mappable.norm
|
| 301 |
+
|
| 302 |
+
filled = True
|
| 303 |
+
if isinstance(mappable, contour.ContourSet):
|
| 304 |
+
cs = mappable
|
| 305 |
+
alpha = cs.get_alpha()
|
| 306 |
+
boundaries = cs._levels
|
| 307 |
+
values = cs.cvalues
|
| 308 |
+
extend = cs.extend
|
| 309 |
+
filled = cs.filled
|
| 310 |
+
if ticks is None:
|
| 311 |
+
ticks = ticker.FixedLocator(cs.levels, nbins=10)
|
| 312 |
+
elif isinstance(mappable, martist.Artist):
|
| 313 |
+
alpha = mappable.get_alpha()
|
| 314 |
+
|
| 315 |
+
mappable.colorbar = self
|
| 316 |
+
mappable.colorbar_cid = mappable.callbacks.connect(
|
| 317 |
+
'changed', self.update_normal)
|
| 318 |
+
|
| 319 |
+
location_orientation = _get_orientation_from_location(location)
|
| 320 |
+
|
| 321 |
+
_api.check_in_list(
|
| 322 |
+
[None, 'vertical', 'horizontal'], orientation=orientation)
|
| 323 |
+
_api.check_in_list(
|
| 324 |
+
['auto', 'left', 'right', 'top', 'bottom'],
|
| 325 |
+
ticklocation=ticklocation)
|
| 326 |
+
_api.check_in_list(
|
| 327 |
+
['uniform', 'proportional'], spacing=spacing)
|
| 328 |
+
|
| 329 |
+
if location_orientation is not None and orientation is not None:
|
| 330 |
+
if location_orientation != orientation:
|
| 331 |
+
raise TypeError(
|
| 332 |
+
"location and orientation are mutually exclusive")
|
| 333 |
+
else:
|
| 334 |
+
orientation = orientation or location_orientation or "vertical"
|
| 335 |
+
|
| 336 |
+
self.ax = ax
|
| 337 |
+
self.ax._axes_locator = _ColorbarAxesLocator(self)
|
| 338 |
+
|
| 339 |
+
if extend is None:
|
| 340 |
+
if (not isinstance(mappable, contour.ContourSet)
|
| 341 |
+
and getattr(cmap, 'colorbar_extend', False) is not False):
|
| 342 |
+
extend = cmap.colorbar_extend
|
| 343 |
+
elif hasattr(norm, 'extend'):
|
| 344 |
+
extend = norm.extend
|
| 345 |
+
else:
|
| 346 |
+
extend = 'neither'
|
| 347 |
+
self.alpha = None
|
| 348 |
+
# Call set_alpha to handle array-like alphas properly
|
| 349 |
+
self.set_alpha(alpha)
|
| 350 |
+
self.cmap = cmap
|
| 351 |
+
self.norm = norm
|
| 352 |
+
self.values = values
|
| 353 |
+
self.boundaries = boundaries
|
| 354 |
+
self.extend = extend
|
| 355 |
+
self._inside = _api.check_getitem(
|
| 356 |
+
{'neither': slice(0, None), 'both': slice(1, -1),
|
| 357 |
+
'min': slice(1, None), 'max': slice(0, -1)},
|
| 358 |
+
extend=extend)
|
| 359 |
+
self.spacing = spacing
|
| 360 |
+
self.orientation = orientation
|
| 361 |
+
self.drawedges = drawedges
|
| 362 |
+
self._filled = filled
|
| 363 |
+
self.extendfrac = extendfrac
|
| 364 |
+
self.extendrect = extendrect
|
| 365 |
+
self._extend_patches = []
|
| 366 |
+
self.solids = None
|
| 367 |
+
self.solids_patches = []
|
| 368 |
+
self.lines = []
|
| 369 |
+
|
| 370 |
+
for spine in self.ax.spines.values():
|
| 371 |
+
spine.set_visible(False)
|
| 372 |
+
self.outline = self.ax.spines['outline'] = _ColorbarSpine(self.ax)
|
| 373 |
+
|
| 374 |
+
self.dividers = collections.LineCollection(
|
| 375 |
+
[],
|
| 376 |
+
colors=[mpl.rcParams['axes.edgecolor']],
|
| 377 |
+
linewidths=[0.5 * mpl.rcParams['axes.linewidth']],
|
| 378 |
+
clip_on=False)
|
| 379 |
+
self.ax.add_collection(self.dividers)
|
| 380 |
+
|
| 381 |
+
self._locator = None
|
| 382 |
+
self._minorlocator = None
|
| 383 |
+
self._formatter = None
|
| 384 |
+
self._minorformatter = None
|
| 385 |
+
|
| 386 |
+
if ticklocation == 'auto':
|
| 387 |
+
ticklocation = _get_ticklocation_from_orientation(
|
| 388 |
+
orientation) if location is None else location
|
| 389 |
+
self.ticklocation = ticklocation
|
| 390 |
+
|
| 391 |
+
self.set_label(label)
|
| 392 |
+
self._reset_locator_formatter_scale()
|
| 393 |
+
|
| 394 |
+
if np.iterable(ticks):
|
| 395 |
+
self._locator = ticker.FixedLocator(ticks, nbins=len(ticks))
|
| 396 |
+
else:
|
| 397 |
+
self._locator = ticks
|
| 398 |
+
|
| 399 |
+
if isinstance(format, str):
|
| 400 |
+
# Check format between FormatStrFormatter and StrMethodFormatter
|
| 401 |
+
try:
|
| 402 |
+
self._formatter = ticker.FormatStrFormatter(format)
|
| 403 |
+
_ = self._formatter(0)
|
| 404 |
+
except (TypeError, ValueError):
|
| 405 |
+
self._formatter = ticker.StrMethodFormatter(format)
|
| 406 |
+
else:
|
| 407 |
+
self._formatter = format # Assume it is a Formatter or None
|
| 408 |
+
self._draw_all()
|
| 409 |
+
|
| 410 |
+
if isinstance(mappable, contour.ContourSet) and not mappable.filled:
|
| 411 |
+
self.add_lines(mappable)
|
| 412 |
+
|
| 413 |
+
# Link the Axes and Colorbar for interactive use
|
| 414 |
+
self.ax._colorbar = self
|
| 415 |
+
# Don't navigate on any of these types of mappables
|
| 416 |
+
if (isinstance(self.norm, (colors.BoundaryNorm, colors.NoNorm)) or
|
| 417 |
+
isinstance(self.mappable, contour.ContourSet)):
|
| 418 |
+
self.ax.set_navigate(False)
|
| 419 |
+
|
| 420 |
+
# These are the functions that set up interactivity on this colorbar
|
| 421 |
+
self._interactive_funcs = ["_get_view", "_set_view",
|
| 422 |
+
"_set_view_from_bbox", "drag_pan"]
|
| 423 |
+
for x in self._interactive_funcs:
|
| 424 |
+
setattr(self.ax, x, getattr(self, x))
|
| 425 |
+
# Set the cla function to the cbar's method to override it
|
| 426 |
+
self.ax.cla = self._cbar_cla
|
| 427 |
+
# Callbacks for the extend calculations to handle inverting the axis
|
| 428 |
+
self._extend_cid1 = self.ax.callbacks.connect(
|
| 429 |
+
"xlim_changed", self._do_extends)
|
| 430 |
+
self._extend_cid2 = self.ax.callbacks.connect(
|
| 431 |
+
"ylim_changed", self._do_extends)
|
| 432 |
+
|
| 433 |
+
@property
|
| 434 |
+
def long_axis(self):
|
| 435 |
+
"""Axis that has decorations (ticks, etc) on it."""
|
| 436 |
+
if self.orientation == 'vertical':
|
| 437 |
+
return self.ax.yaxis
|
| 438 |
+
return self.ax.xaxis
|
| 439 |
+
|
| 440 |
+
@property
|
| 441 |
+
def locator(self):
|
| 442 |
+
"""Major tick `.Locator` for the colorbar."""
|
| 443 |
+
return self.long_axis.get_major_locator()
|
| 444 |
+
|
| 445 |
+
@locator.setter
|
| 446 |
+
def locator(self, loc):
|
| 447 |
+
self.long_axis.set_major_locator(loc)
|
| 448 |
+
self._locator = loc
|
| 449 |
+
|
| 450 |
+
@property
|
| 451 |
+
def minorlocator(self):
|
| 452 |
+
"""Minor tick `.Locator` for the colorbar."""
|
| 453 |
+
return self.long_axis.get_minor_locator()
|
| 454 |
+
|
| 455 |
+
@minorlocator.setter
|
| 456 |
+
def minorlocator(self, loc):
|
| 457 |
+
self.long_axis.set_minor_locator(loc)
|
| 458 |
+
self._minorlocator = loc
|
| 459 |
+
|
| 460 |
+
@property
|
| 461 |
+
def formatter(self):
|
| 462 |
+
"""Major tick label `.Formatter` for the colorbar."""
|
| 463 |
+
return self.long_axis.get_major_formatter()
|
| 464 |
+
|
| 465 |
+
@formatter.setter
|
| 466 |
+
def formatter(self, fmt):
|
| 467 |
+
self.long_axis.set_major_formatter(fmt)
|
| 468 |
+
self._formatter = fmt
|
| 469 |
+
|
| 470 |
+
@property
|
| 471 |
+
def minorformatter(self):
|
| 472 |
+
"""Minor tick `.Formatter` for the colorbar."""
|
| 473 |
+
return self.long_axis.get_minor_formatter()
|
| 474 |
+
|
| 475 |
+
@minorformatter.setter
|
| 476 |
+
def minorformatter(self, fmt):
|
| 477 |
+
self.long_axis.set_minor_formatter(fmt)
|
| 478 |
+
self._minorformatter = fmt
|
| 479 |
+
|
| 480 |
+
def _cbar_cla(self):
|
| 481 |
+
"""Function to clear the interactive colorbar state."""
|
| 482 |
+
for x in self._interactive_funcs:
|
| 483 |
+
delattr(self.ax, x)
|
| 484 |
+
# We now restore the old cla() back and can call it directly
|
| 485 |
+
del self.ax.cla
|
| 486 |
+
self.ax.cla()
|
| 487 |
+
|
| 488 |
+
def update_normal(self, mappable=None):
|
| 489 |
+
"""
|
| 490 |
+
Update solid patches, lines, etc.
|
| 491 |
+
|
| 492 |
+
This is meant to be called when the norm of the image or contour plot
|
| 493 |
+
to which this colorbar belongs changes.
|
| 494 |
+
|
| 495 |
+
If the norm on the mappable is different than before, this resets the
|
| 496 |
+
locator and formatter for the axis, so if these have been customized,
|
| 497 |
+
they will need to be customized again. However, if the norm only
|
| 498 |
+
changes values of *vmin*, *vmax* or *cmap* then the old formatter
|
| 499 |
+
and locator will be preserved.
|
| 500 |
+
"""
|
| 501 |
+
if mappable:
|
| 502 |
+
# The mappable keyword argument exists because
|
| 503 |
+
# ScalarMappable.changed() emits self.callbacks.process('changed', self)
|
| 504 |
+
# in contrast, ColorizingArtist (and Colorizer) does not use this keyword.
|
| 505 |
+
# [ColorizingArtist.changed() emits self.callbacks.process('changed')]
|
| 506 |
+
# Also, there is no test where self.mappable == mappable is not True
|
| 507 |
+
# and possibly no use case.
|
| 508 |
+
# Therefore, the mappable keyword can be deprecated if cm.ScalarMappable
|
| 509 |
+
# is removed.
|
| 510 |
+
self.mappable = mappable
|
| 511 |
+
_log.debug('colorbar update normal %r %r', self.mappable.norm, self.norm)
|
| 512 |
+
self.set_alpha(self.mappable.get_alpha())
|
| 513 |
+
self.cmap = self.mappable.cmap
|
| 514 |
+
if self.mappable.norm != self.norm:
|
| 515 |
+
self.norm = self.mappable.norm
|
| 516 |
+
self._reset_locator_formatter_scale()
|
| 517 |
+
|
| 518 |
+
self._draw_all()
|
| 519 |
+
if isinstance(self.mappable, contour.ContourSet):
|
| 520 |
+
CS = self.mappable
|
| 521 |
+
if not CS.filled:
|
| 522 |
+
self.add_lines(CS)
|
| 523 |
+
self.stale = True
|
| 524 |
+
|
| 525 |
+
def _draw_all(self):
|
| 526 |
+
"""
|
| 527 |
+
Calculate any free parameters based on the current cmap and norm,
|
| 528 |
+
and do all the drawing.
|
| 529 |
+
"""
|
| 530 |
+
if self.orientation == 'vertical':
|
| 531 |
+
if mpl.rcParams['ytick.minor.visible']:
|
| 532 |
+
self.minorticks_on()
|
| 533 |
+
else:
|
| 534 |
+
if mpl.rcParams['xtick.minor.visible']:
|
| 535 |
+
self.minorticks_on()
|
| 536 |
+
self.long_axis.set(label_position=self.ticklocation,
|
| 537 |
+
ticks_position=self.ticklocation)
|
| 538 |
+
self._short_axis().set_ticks([])
|
| 539 |
+
self._short_axis().set_ticks([], minor=True)
|
| 540 |
+
|
| 541 |
+
# Set self._boundaries and self._values, including extensions.
|
| 542 |
+
# self._boundaries are the edges of each square of color, and
|
| 543 |
+
# self._values are the value to map into the norm to get the
|
| 544 |
+
# color:
|
| 545 |
+
self._process_values()
|
| 546 |
+
# Set self.vmin and self.vmax to first and last boundary, excluding
|
| 547 |
+
# extensions:
|
| 548 |
+
self.vmin, self.vmax = self._boundaries[self._inside][[0, -1]]
|
| 549 |
+
# Compute the X/Y mesh.
|
| 550 |
+
X, Y = self._mesh()
|
| 551 |
+
# draw the extend triangles, and shrink the inner Axes to accommodate.
|
| 552 |
+
# also adds the outline path to self.outline spine:
|
| 553 |
+
self._do_extends()
|
| 554 |
+
lower, upper = self.vmin, self.vmax
|
| 555 |
+
if self.long_axis.get_inverted():
|
| 556 |
+
# If the axis is inverted, we need to swap the vmin/vmax
|
| 557 |
+
lower, upper = upper, lower
|
| 558 |
+
if self.orientation == 'vertical':
|
| 559 |
+
self.ax.set_xlim(0, 1)
|
| 560 |
+
self.ax.set_ylim(lower, upper)
|
| 561 |
+
else:
|
| 562 |
+
self.ax.set_ylim(0, 1)
|
| 563 |
+
self.ax.set_xlim(lower, upper)
|
| 564 |
+
|
| 565 |
+
# set up the tick locators and formatters. A bit complicated because
|
| 566 |
+
# boundary norms + uniform spacing requires a manual locator.
|
| 567 |
+
self.update_ticks()
|
| 568 |
+
|
| 569 |
+
if self._filled:
|
| 570 |
+
ind = np.arange(len(self._values))
|
| 571 |
+
if self._extend_lower():
|
| 572 |
+
ind = ind[1:]
|
| 573 |
+
if self._extend_upper():
|
| 574 |
+
ind = ind[:-1]
|
| 575 |
+
self._add_solids(X, Y, self._values[ind, np.newaxis])
|
| 576 |
+
|
| 577 |
+
def _add_solids(self, X, Y, C):
|
| 578 |
+
"""Draw the colors; optionally add separators."""
|
| 579 |
+
# Cleanup previously set artists.
|
| 580 |
+
if self.solids is not None:
|
| 581 |
+
self.solids.remove()
|
| 582 |
+
for solid in self.solids_patches:
|
| 583 |
+
solid.remove()
|
| 584 |
+
# Add new artist(s), based on mappable type. Use individual patches if
|
| 585 |
+
# hatching is needed, pcolormesh otherwise.
|
| 586 |
+
mappable = getattr(self, 'mappable', None)
|
| 587 |
+
if (isinstance(mappable, contour.ContourSet)
|
| 588 |
+
and any(hatch is not None for hatch in mappable.hatches)):
|
| 589 |
+
self._add_solids_patches(X, Y, C, mappable)
|
| 590 |
+
else:
|
| 591 |
+
self.solids = self.ax.pcolormesh(
|
| 592 |
+
X, Y, C, cmap=self.cmap, norm=self.norm, alpha=self.alpha,
|
| 593 |
+
edgecolors='none', shading='flat')
|
| 594 |
+
if not self.drawedges:
|
| 595 |
+
if len(self._y) >= self.n_rasterize:
|
| 596 |
+
self.solids.set_rasterized(True)
|
| 597 |
+
self._update_dividers()
|
| 598 |
+
|
| 599 |
+
def _update_dividers(self):
|
| 600 |
+
if not self.drawedges:
|
| 601 |
+
self.dividers.set_segments([])
|
| 602 |
+
return
|
| 603 |
+
# Place all *internal* dividers.
|
| 604 |
+
if self.orientation == 'vertical':
|
| 605 |
+
lims = self.ax.get_ylim()
|
| 606 |
+
bounds = (lims[0] < self._y) & (self._y < lims[1])
|
| 607 |
+
else:
|
| 608 |
+
lims = self.ax.get_xlim()
|
| 609 |
+
bounds = (lims[0] < self._y) & (self._y < lims[1])
|
| 610 |
+
y = self._y[bounds]
|
| 611 |
+
# And then add outer dividers if extensions are on.
|
| 612 |
+
if self._extend_lower():
|
| 613 |
+
y = np.insert(y, 0, lims[0])
|
| 614 |
+
if self._extend_upper():
|
| 615 |
+
y = np.append(y, lims[1])
|
| 616 |
+
X, Y = np.meshgrid([0, 1], y)
|
| 617 |
+
if self.orientation == 'vertical':
|
| 618 |
+
segments = np.dstack([X, Y])
|
| 619 |
+
else:
|
| 620 |
+
segments = np.dstack([Y, X])
|
| 621 |
+
self.dividers.set_segments(segments)
|
| 622 |
+
|
| 623 |
+
def _add_solids_patches(self, X, Y, C, mappable):
|
| 624 |
+
hatches = mappable.hatches * (len(C) + 1) # Have enough hatches.
|
| 625 |
+
if self._extend_lower():
|
| 626 |
+
# remove first hatch that goes into the extend patch
|
| 627 |
+
hatches = hatches[1:]
|
| 628 |
+
patches = []
|
| 629 |
+
for i in range(len(X) - 1):
|
| 630 |
+
xy = np.array([[X[i, 0], Y[i, 1]],
|
| 631 |
+
[X[i, 1], Y[i, 0]],
|
| 632 |
+
[X[i + 1, 1], Y[i + 1, 0]],
|
| 633 |
+
[X[i + 1, 0], Y[i + 1, 1]]])
|
| 634 |
+
patch = mpatches.PathPatch(mpath.Path(xy),
|
| 635 |
+
facecolor=self.cmap(self.norm(C[i][0])),
|
| 636 |
+
hatch=hatches[i], linewidth=0,
|
| 637 |
+
antialiased=False, alpha=self.alpha)
|
| 638 |
+
self.ax.add_patch(patch)
|
| 639 |
+
patches.append(patch)
|
| 640 |
+
self.solids_patches = patches
|
| 641 |
+
|
| 642 |
+
def _do_extends(self, ax=None):
|
| 643 |
+
"""
|
| 644 |
+
Add the extend tri/rectangles on the outside of the Axes.
|
| 645 |
+
|
| 646 |
+
ax is unused, but required due to the callbacks on xlim/ylim changed
|
| 647 |
+
"""
|
| 648 |
+
# Clean up any previous extend patches
|
| 649 |
+
for patch in self._extend_patches:
|
| 650 |
+
patch.remove()
|
| 651 |
+
self._extend_patches = []
|
| 652 |
+
# extend lengths are fraction of the *inner* part of colorbar,
|
| 653 |
+
# not the total colorbar:
|
| 654 |
+
_, extendlen = self._proportional_y()
|
| 655 |
+
bot = 0 - (extendlen[0] if self._extend_lower() else 0)
|
| 656 |
+
top = 1 + (extendlen[1] if self._extend_upper() else 0)
|
| 657 |
+
|
| 658 |
+
# xyout is the outline of the colorbar including the extend patches:
|
| 659 |
+
if not self.extendrect:
|
| 660 |
+
# triangle:
|
| 661 |
+
xyout = np.array([[0, 0], [0.5, bot], [1, 0],
|
| 662 |
+
[1, 1], [0.5, top], [0, 1], [0, 0]])
|
| 663 |
+
else:
|
| 664 |
+
# rectangle:
|
| 665 |
+
xyout = np.array([[0, 0], [0, bot], [1, bot], [1, 0],
|
| 666 |
+
[1, 1], [1, top], [0, top], [0, 1],
|
| 667 |
+
[0, 0]])
|
| 668 |
+
|
| 669 |
+
if self.orientation == 'horizontal':
|
| 670 |
+
xyout = xyout[:, ::-1]
|
| 671 |
+
|
| 672 |
+
# xyout is the path for the spine:
|
| 673 |
+
self.outline.set_xy(xyout)
|
| 674 |
+
if not self._filled:
|
| 675 |
+
return
|
| 676 |
+
|
| 677 |
+
# Make extend triangles or rectangles filled patches. These are
|
| 678 |
+
# defined in the outer parent axes' coordinates:
|
| 679 |
+
mappable = getattr(self, 'mappable', None)
|
| 680 |
+
if (isinstance(mappable, contour.ContourSet)
|
| 681 |
+
and any(hatch is not None for hatch in mappable.hatches)):
|
| 682 |
+
hatches = mappable.hatches * (len(self._y) + 1)
|
| 683 |
+
else:
|
| 684 |
+
hatches = [None] * (len(self._y) + 1)
|
| 685 |
+
|
| 686 |
+
if self._extend_lower():
|
| 687 |
+
if not self.extendrect:
|
| 688 |
+
# triangle
|
| 689 |
+
xy = np.array([[0, 0], [0.5, bot], [1, 0]])
|
| 690 |
+
else:
|
| 691 |
+
# rectangle
|
| 692 |
+
xy = np.array([[0, 0], [0, bot], [1., bot], [1, 0]])
|
| 693 |
+
if self.orientation == 'horizontal':
|
| 694 |
+
xy = xy[:, ::-1]
|
| 695 |
+
# add the patch
|
| 696 |
+
val = -1 if self.long_axis.get_inverted() else 0
|
| 697 |
+
color = self.cmap(self.norm(self._values[val]))
|
| 698 |
+
patch = mpatches.PathPatch(
|
| 699 |
+
mpath.Path(xy), facecolor=color, alpha=self.alpha,
|
| 700 |
+
linewidth=0, antialiased=False,
|
| 701 |
+
transform=self.ax.transAxes,
|
| 702 |
+
hatch=hatches[0], clip_on=False,
|
| 703 |
+
# Place it right behind the standard patches, which is
|
| 704 |
+
# needed if we updated the extends
|
| 705 |
+
zorder=np.nextafter(self.ax.patch.zorder, -np.inf))
|
| 706 |
+
self.ax.add_patch(patch)
|
| 707 |
+
self._extend_patches.append(patch)
|
| 708 |
+
# remove first hatch that goes into the extend patch
|
| 709 |
+
hatches = hatches[1:]
|
| 710 |
+
if self._extend_upper():
|
| 711 |
+
if not self.extendrect:
|
| 712 |
+
# triangle
|
| 713 |
+
xy = np.array([[0, 1], [0.5, top], [1, 1]])
|
| 714 |
+
else:
|
| 715 |
+
# rectangle
|
| 716 |
+
xy = np.array([[0, 1], [0, top], [1, top], [1, 1]])
|
| 717 |
+
if self.orientation == 'horizontal':
|
| 718 |
+
xy = xy[:, ::-1]
|
| 719 |
+
# add the patch
|
| 720 |
+
val = 0 if self.long_axis.get_inverted() else -1
|
| 721 |
+
color = self.cmap(self.norm(self._values[val]))
|
| 722 |
+
hatch_idx = len(self._y) - 1
|
| 723 |
+
patch = mpatches.PathPatch(
|
| 724 |
+
mpath.Path(xy), facecolor=color, alpha=self.alpha,
|
| 725 |
+
linewidth=0, antialiased=False,
|
| 726 |
+
transform=self.ax.transAxes, hatch=hatches[hatch_idx],
|
| 727 |
+
clip_on=False,
|
| 728 |
+
# Place it right behind the standard patches, which is
|
| 729 |
+
# needed if we updated the extends
|
| 730 |
+
zorder=np.nextafter(self.ax.patch.zorder, -np.inf))
|
| 731 |
+
self.ax.add_patch(patch)
|
| 732 |
+
self._extend_patches.append(patch)
|
| 733 |
+
|
| 734 |
+
self._update_dividers()
|
| 735 |
+
|
| 736 |
+
def add_lines(self, *args, **kwargs):
|
| 737 |
+
"""
|
| 738 |
+
Draw lines on the colorbar.
|
| 739 |
+
|
| 740 |
+
The lines are appended to the list :attr:`lines`.
|
| 741 |
+
|
| 742 |
+
Parameters
|
| 743 |
+
----------
|
| 744 |
+
levels : array-like
|
| 745 |
+
The positions of the lines.
|
| 746 |
+
colors : :mpltype:`color` or list of :mpltype:`color`
|
| 747 |
+
Either a single color applying to all lines or one color value for
|
| 748 |
+
each line.
|
| 749 |
+
linewidths : float or array-like
|
| 750 |
+
Either a single linewidth applying to all lines or one linewidth
|
| 751 |
+
for each line.
|
| 752 |
+
erase : bool, default: True
|
| 753 |
+
Whether to remove any previously added lines.
|
| 754 |
+
|
| 755 |
+
Notes
|
| 756 |
+
-----
|
| 757 |
+
Alternatively, this method can also be called with the signature
|
| 758 |
+
``colorbar.add_lines(contour_set, erase=True)``, in which case
|
| 759 |
+
*levels*, *colors*, and *linewidths* are taken from *contour_set*.
|
| 760 |
+
"""
|
| 761 |
+
params = _api.select_matching_signature(
|
| 762 |
+
[lambda self, CS, erase=True: locals(),
|
| 763 |
+
lambda self, levels, colors, linewidths, erase=True: locals()],
|
| 764 |
+
self, *args, **kwargs)
|
| 765 |
+
if "CS" in params:
|
| 766 |
+
self, cs, erase = params.values()
|
| 767 |
+
if not isinstance(cs, contour.ContourSet) or cs.filled:
|
| 768 |
+
raise ValueError("If a single artist is passed to add_lines, "
|
| 769 |
+
"it must be a ContourSet of lines")
|
| 770 |
+
# TODO: Make colorbar lines auto-follow changes in contour lines.
|
| 771 |
+
return self.add_lines(
|
| 772 |
+
cs.levels,
|
| 773 |
+
cs.to_rgba(cs.cvalues, cs.alpha),
|
| 774 |
+
cs.get_linewidths(),
|
| 775 |
+
erase=erase)
|
| 776 |
+
else:
|
| 777 |
+
self, levels, colors, linewidths, erase = params.values()
|
| 778 |
+
|
| 779 |
+
y = self._locate(levels)
|
| 780 |
+
rtol = (self._y[-1] - self._y[0]) * 1e-10
|
| 781 |
+
igood = (y < self._y[-1] + rtol) & (y > self._y[0] - rtol)
|
| 782 |
+
y = y[igood]
|
| 783 |
+
if np.iterable(colors):
|
| 784 |
+
colors = np.asarray(colors)[igood]
|
| 785 |
+
if np.iterable(linewidths):
|
| 786 |
+
linewidths = np.asarray(linewidths)[igood]
|
| 787 |
+
X, Y = np.meshgrid([0, 1], y)
|
| 788 |
+
if self.orientation == 'vertical':
|
| 789 |
+
xy = np.stack([X, Y], axis=-1)
|
| 790 |
+
else:
|
| 791 |
+
xy = np.stack([Y, X], axis=-1)
|
| 792 |
+
col = collections.LineCollection(xy, linewidths=linewidths,
|
| 793 |
+
colors=colors)
|
| 794 |
+
|
| 795 |
+
if erase and self.lines:
|
| 796 |
+
for lc in self.lines:
|
| 797 |
+
lc.remove()
|
| 798 |
+
self.lines = []
|
| 799 |
+
self.lines.append(col)
|
| 800 |
+
|
| 801 |
+
# make a clip path that is just a linewidth bigger than the Axes...
|
| 802 |
+
fac = np.max(linewidths) / 72
|
| 803 |
+
xy = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]])
|
| 804 |
+
inches = self.ax.get_figure().dpi_scale_trans
|
| 805 |
+
# do in inches:
|
| 806 |
+
xy = inches.inverted().transform(self.ax.transAxes.transform(xy))
|
| 807 |
+
xy[[0, 1, 4], 1] -= fac
|
| 808 |
+
xy[[2, 3], 1] += fac
|
| 809 |
+
# back to axes units...
|
| 810 |
+
xy = self.ax.transAxes.inverted().transform(inches.transform(xy))
|
| 811 |
+
col.set_clip_path(mpath.Path(xy, closed=True),
|
| 812 |
+
self.ax.transAxes)
|
| 813 |
+
self.ax.add_collection(col)
|
| 814 |
+
self.stale = True
|
| 815 |
+
|
| 816 |
+
def update_ticks(self):
|
| 817 |
+
"""
|
| 818 |
+
Set up the ticks and ticklabels. This should not be needed by users.
|
| 819 |
+
"""
|
| 820 |
+
# Get the locator and formatter; defaults to self._locator if not None.
|
| 821 |
+
self._get_ticker_locator_formatter()
|
| 822 |
+
self.long_axis.set_major_locator(self._locator)
|
| 823 |
+
self.long_axis.set_minor_locator(self._minorlocator)
|
| 824 |
+
self.long_axis.set_major_formatter(self._formatter)
|
| 825 |
+
|
| 826 |
+
def _get_ticker_locator_formatter(self):
|
| 827 |
+
"""
|
| 828 |
+
Return the ``locator`` and ``formatter`` of the colorbar.
|
| 829 |
+
|
| 830 |
+
If they have not been defined (i.e. are *None*), the formatter and
|
| 831 |
+
locator are retrieved from the axis, or from the value of the
|
| 832 |
+
boundaries for a boundary norm.
|
| 833 |
+
|
| 834 |
+
Called by update_ticks...
|
| 835 |
+
"""
|
| 836 |
+
locator = self._locator
|
| 837 |
+
formatter = self._formatter
|
| 838 |
+
minorlocator = self._minorlocator
|
| 839 |
+
if isinstance(self.norm, colors.BoundaryNorm):
|
| 840 |
+
b = self.norm.boundaries
|
| 841 |
+
if locator is None:
|
| 842 |
+
locator = ticker.FixedLocator(b, nbins=10)
|
| 843 |
+
if minorlocator is None:
|
| 844 |
+
minorlocator = ticker.FixedLocator(b)
|
| 845 |
+
elif isinstance(self.norm, colors.NoNorm):
|
| 846 |
+
if locator is None:
|
| 847 |
+
# put ticks on integers between the boundaries of NoNorm
|
| 848 |
+
nv = len(self._values)
|
| 849 |
+
base = 1 + int(nv / 10)
|
| 850 |
+
locator = ticker.IndexLocator(base=base, offset=.5)
|
| 851 |
+
elif self.boundaries is not None:
|
| 852 |
+
b = self._boundaries[self._inside]
|
| 853 |
+
if locator is None:
|
| 854 |
+
locator = ticker.FixedLocator(b, nbins=10)
|
| 855 |
+
else: # most cases:
|
| 856 |
+
if locator is None:
|
| 857 |
+
# we haven't set the locator explicitly, so use the default
|
| 858 |
+
# for this axis:
|
| 859 |
+
locator = self.long_axis.get_major_locator()
|
| 860 |
+
if minorlocator is None:
|
| 861 |
+
minorlocator = self.long_axis.get_minor_locator()
|
| 862 |
+
|
| 863 |
+
if minorlocator is None:
|
| 864 |
+
minorlocator = ticker.NullLocator()
|
| 865 |
+
|
| 866 |
+
if formatter is None:
|
| 867 |
+
formatter = self.long_axis.get_major_formatter()
|
| 868 |
+
|
| 869 |
+
self._locator = locator
|
| 870 |
+
self._formatter = formatter
|
| 871 |
+
self._minorlocator = minorlocator
|
| 872 |
+
_log.debug('locator: %r', locator)
|
| 873 |
+
|
| 874 |
+
def set_ticks(self, ticks, *, labels=None, minor=False, **kwargs):
|
| 875 |
+
"""
|
| 876 |
+
Set tick locations.
|
| 877 |
+
|
| 878 |
+
Parameters
|
| 879 |
+
----------
|
| 880 |
+
ticks : 1D array-like
|
| 881 |
+
List of tick locations.
|
| 882 |
+
labels : list of str, optional
|
| 883 |
+
List of tick labels. If not set, the labels show the data value.
|
| 884 |
+
minor : bool, default: False
|
| 885 |
+
If ``False``, set the major ticks; if ``True``, the minor ticks.
|
| 886 |
+
**kwargs
|
| 887 |
+
`.Text` properties for the labels. These take effect only if you
|
| 888 |
+
pass *labels*. In other cases, please use `~.Axes.tick_params`.
|
| 889 |
+
"""
|
| 890 |
+
if np.iterable(ticks):
|
| 891 |
+
self.long_axis.set_ticks(ticks, labels=labels, minor=minor,
|
| 892 |
+
**kwargs)
|
| 893 |
+
self._locator = self.long_axis.get_major_locator()
|
| 894 |
+
else:
|
| 895 |
+
self._locator = ticks
|
| 896 |
+
self.long_axis.set_major_locator(self._locator)
|
| 897 |
+
self.stale = True
|
| 898 |
+
|
| 899 |
+
def get_ticks(self, minor=False):
|
| 900 |
+
"""
|
| 901 |
+
Return the ticks as a list of locations.
|
| 902 |
+
|
| 903 |
+
Parameters
|
| 904 |
+
----------
|
| 905 |
+
minor : boolean, default: False
|
| 906 |
+
if True return the minor ticks.
|
| 907 |
+
"""
|
| 908 |
+
if minor:
|
| 909 |
+
return self.long_axis.get_minorticklocs()
|
| 910 |
+
else:
|
| 911 |
+
return self.long_axis.get_majorticklocs()
|
| 912 |
+
|
| 913 |
+
def set_ticklabels(self, ticklabels, *, minor=False, **kwargs):
|
| 914 |
+
"""
|
| 915 |
+
[*Discouraged*] Set tick labels.
|
| 916 |
+
|
| 917 |
+
.. admonition:: Discouraged
|
| 918 |
+
|
| 919 |
+
The use of this method is discouraged, because of the dependency
|
| 920 |
+
on tick positions. In most cases, you'll want to use
|
| 921 |
+
``set_ticks(positions, labels=labels)`` instead.
|
| 922 |
+
|
| 923 |
+
If you are using this method, you should always fix the tick
|
| 924 |
+
positions before, e.g. by using `.Colorbar.set_ticks` or by
|
| 925 |
+
explicitly setting a `~.ticker.FixedLocator` on the long axis
|
| 926 |
+
of the colorbar. Otherwise, ticks are free to move and the
|
| 927 |
+
labels may end up in unexpected positions.
|
| 928 |
+
|
| 929 |
+
Parameters
|
| 930 |
+
----------
|
| 931 |
+
ticklabels : sequence of str or of `.Text`
|
| 932 |
+
Texts for labeling each tick location in the sequence set by
|
| 933 |
+
`.Colorbar.set_ticks`; the number of labels must match the number
|
| 934 |
+
of locations.
|
| 935 |
+
|
| 936 |
+
update_ticks : bool, default: True
|
| 937 |
+
This keyword argument is ignored and will be removed.
|
| 938 |
+
Deprecated
|
| 939 |
+
|
| 940 |
+
minor : bool
|
| 941 |
+
If True, set minor ticks instead of major ticks.
|
| 942 |
+
|
| 943 |
+
**kwargs
|
| 944 |
+
`.Text` properties for the labels.
|
| 945 |
+
"""
|
| 946 |
+
self.long_axis.set_ticklabels(ticklabels, minor=minor, **kwargs)
|
| 947 |
+
|
| 948 |
+
def minorticks_on(self):
|
| 949 |
+
"""
|
| 950 |
+
Turn on colorbar minor ticks.
|
| 951 |
+
"""
|
| 952 |
+
self.ax.minorticks_on()
|
| 953 |
+
self._short_axis().set_minor_locator(ticker.NullLocator())
|
| 954 |
+
|
| 955 |
+
def minorticks_off(self):
|
| 956 |
+
"""Turn the minor ticks of the colorbar off."""
|
| 957 |
+
self._minorlocator = ticker.NullLocator()
|
| 958 |
+
self.long_axis.set_minor_locator(self._minorlocator)
|
| 959 |
+
|
| 960 |
+
def set_label(self, label, *, loc=None, **kwargs):
|
| 961 |
+
"""
|
| 962 |
+
Add a label to the long axis of the colorbar.
|
| 963 |
+
|
| 964 |
+
Parameters
|
| 965 |
+
----------
|
| 966 |
+
label : str
|
| 967 |
+
The label text.
|
| 968 |
+
loc : str, optional
|
| 969 |
+
The location of the label.
|
| 970 |
+
|
| 971 |
+
- For horizontal orientation one of {'left', 'center', 'right'}
|
| 972 |
+
- For vertical orientation one of {'bottom', 'center', 'top'}
|
| 973 |
+
|
| 974 |
+
Defaults to :rc:`xaxis.labellocation` or :rc:`yaxis.labellocation`
|
| 975 |
+
depending on the orientation.
|
| 976 |
+
**kwargs
|
| 977 |
+
Keyword arguments are passed to `~.Axes.set_xlabel` /
|
| 978 |
+
`~.Axes.set_ylabel`.
|
| 979 |
+
Supported keywords are *labelpad* and `.Text` properties.
|
| 980 |
+
"""
|
| 981 |
+
if self.orientation == "vertical":
|
| 982 |
+
self.ax.set_ylabel(label, loc=loc, **kwargs)
|
| 983 |
+
else:
|
| 984 |
+
self.ax.set_xlabel(label, loc=loc, **kwargs)
|
| 985 |
+
self.stale = True
|
| 986 |
+
|
| 987 |
+
def set_alpha(self, alpha):
|
| 988 |
+
"""
|
| 989 |
+
Set the transparency between 0 (transparent) and 1 (opaque).
|
| 990 |
+
|
| 991 |
+
If an array is provided, *alpha* will be set to None to use the
|
| 992 |
+
transparency values associated with the colormap.
|
| 993 |
+
"""
|
| 994 |
+
self.alpha = None if isinstance(alpha, np.ndarray) else alpha
|
| 995 |
+
|
| 996 |
+
def _set_scale(self, scale, **kwargs):
|
| 997 |
+
"""
|
| 998 |
+
Set the colorbar long axis scale.
|
| 999 |
+
|
| 1000 |
+
Parameters
|
| 1001 |
+
----------
|
| 1002 |
+
scale : {"linear", "log", "symlog", "logit", ...} or `.ScaleBase`
|
| 1003 |
+
The axis scale type to apply.
|
| 1004 |
+
|
| 1005 |
+
**kwargs
|
| 1006 |
+
Different keyword arguments are accepted, depending on the scale.
|
| 1007 |
+
See the respective class keyword arguments:
|
| 1008 |
+
|
| 1009 |
+
- `matplotlib.scale.LinearScale`
|
| 1010 |
+
- `matplotlib.scale.LogScale`
|
| 1011 |
+
- `matplotlib.scale.SymmetricalLogScale`
|
| 1012 |
+
- `matplotlib.scale.LogitScale`
|
| 1013 |
+
- `matplotlib.scale.FuncScale`
|
| 1014 |
+
- `matplotlib.scale.AsinhScale`
|
| 1015 |
+
|
| 1016 |
+
Notes
|
| 1017 |
+
-----
|
| 1018 |
+
By default, Matplotlib supports the above-mentioned scales.
|
| 1019 |
+
Additionally, custom scales may be registered using
|
| 1020 |
+
`matplotlib.scale.register_scale`. These scales can then also
|
| 1021 |
+
be used here.
|
| 1022 |
+
"""
|
| 1023 |
+
self.long_axis._set_axes_scale(scale, **kwargs)
|
| 1024 |
+
|
| 1025 |
+
def remove(self):
|
| 1026 |
+
"""
|
| 1027 |
+
Remove this colorbar from the figure.
|
| 1028 |
+
|
| 1029 |
+
If the colorbar was created with ``use_gridspec=True`` the previous
|
| 1030 |
+
gridspec is restored.
|
| 1031 |
+
"""
|
| 1032 |
+
if hasattr(self.ax, '_colorbar_info'):
|
| 1033 |
+
parents = self.ax._colorbar_info['parents']
|
| 1034 |
+
for a in parents:
|
| 1035 |
+
if self.ax in a._colorbars:
|
| 1036 |
+
a._colorbars.remove(self.ax)
|
| 1037 |
+
|
| 1038 |
+
self.ax.remove()
|
| 1039 |
+
|
| 1040 |
+
self.mappable.callbacks.disconnect(self.mappable.colorbar_cid)
|
| 1041 |
+
self.mappable.colorbar = None
|
| 1042 |
+
self.mappable.colorbar_cid = None
|
| 1043 |
+
# Remove the extension callbacks
|
| 1044 |
+
self.ax.callbacks.disconnect(self._extend_cid1)
|
| 1045 |
+
self.ax.callbacks.disconnect(self._extend_cid2)
|
| 1046 |
+
|
| 1047 |
+
try:
|
| 1048 |
+
ax = self.mappable.axes
|
| 1049 |
+
except AttributeError:
|
| 1050 |
+
return
|
| 1051 |
+
try:
|
| 1052 |
+
subplotspec = self.ax.get_subplotspec().get_gridspec()._subplot_spec
|
| 1053 |
+
except AttributeError: # use_gridspec was False
|
| 1054 |
+
pos = ax.get_position(original=True)
|
| 1055 |
+
ax._set_position(pos)
|
| 1056 |
+
else: # use_gridspec was True
|
| 1057 |
+
ax.set_subplotspec(subplotspec)
|
| 1058 |
+
|
| 1059 |
+
def _process_values(self):
|
| 1060 |
+
"""
|
| 1061 |
+
Set `_boundaries` and `_values` based on the self.boundaries and
|
| 1062 |
+
self.values if not None, or based on the size of the colormap and
|
| 1063 |
+
the vmin/vmax of the norm.
|
| 1064 |
+
"""
|
| 1065 |
+
if self.values is not None:
|
| 1066 |
+
# set self._boundaries from the values...
|
| 1067 |
+
self._values = np.array(self.values)
|
| 1068 |
+
if self.boundaries is None:
|
| 1069 |
+
# bracket values by 1/2 dv:
|
| 1070 |
+
b = np.zeros(len(self.values) + 1)
|
| 1071 |
+
b[1:-1] = 0.5 * (self._values[:-1] + self._values[1:])
|
| 1072 |
+
b[0] = 2.0 * b[1] - b[2]
|
| 1073 |
+
b[-1] = 2.0 * b[-2] - b[-3]
|
| 1074 |
+
self._boundaries = b
|
| 1075 |
+
return
|
| 1076 |
+
self._boundaries = np.array(self.boundaries)
|
| 1077 |
+
return
|
| 1078 |
+
|
| 1079 |
+
# otherwise values are set from the boundaries
|
| 1080 |
+
if isinstance(self.norm, colors.BoundaryNorm):
|
| 1081 |
+
b = self.norm.boundaries
|
| 1082 |
+
elif isinstance(self.norm, colors.NoNorm):
|
| 1083 |
+
# NoNorm has N blocks, so N+1 boundaries, centered on integers:
|
| 1084 |
+
b = np.arange(self.cmap.N + 1) - .5
|
| 1085 |
+
elif self.boundaries is not None:
|
| 1086 |
+
b = self.boundaries
|
| 1087 |
+
else:
|
| 1088 |
+
# otherwise make the boundaries from the size of the cmap:
|
| 1089 |
+
N = self.cmap.N + 1
|
| 1090 |
+
b, _ = self._uniform_y(N)
|
| 1091 |
+
# add extra boundaries if needed:
|
| 1092 |
+
if self._extend_lower():
|
| 1093 |
+
b = np.hstack((b[0] - 1, b))
|
| 1094 |
+
if self._extend_upper():
|
| 1095 |
+
b = np.hstack((b, b[-1] + 1))
|
| 1096 |
+
|
| 1097 |
+
# transform from 0-1 to vmin-vmax:
|
| 1098 |
+
if self.mappable.get_array() is not None:
|
| 1099 |
+
self.mappable.autoscale_None()
|
| 1100 |
+
if not self.norm.scaled():
|
| 1101 |
+
# If we still aren't scaled after autoscaling, use 0, 1 as default
|
| 1102 |
+
self.norm.vmin = 0
|
| 1103 |
+
self.norm.vmax = 1
|
| 1104 |
+
self.norm.vmin, self.norm.vmax = mtransforms.nonsingular(
|
| 1105 |
+
self.norm.vmin, self.norm.vmax, expander=0.1)
|
| 1106 |
+
if (not isinstance(self.norm, colors.BoundaryNorm) and
|
| 1107 |
+
(self.boundaries is None)):
|
| 1108 |
+
b = self.norm.inverse(b)
|
| 1109 |
+
|
| 1110 |
+
self._boundaries = np.asarray(b, dtype=float)
|
| 1111 |
+
self._values = 0.5 * (self._boundaries[:-1] + self._boundaries[1:])
|
| 1112 |
+
if isinstance(self.norm, colors.NoNorm):
|
| 1113 |
+
self._values = (self._values + 0.00001).astype(np.int16)
|
| 1114 |
+
|
| 1115 |
+
def _mesh(self):
|
| 1116 |
+
"""
|
| 1117 |
+
Return the coordinate arrays for the colorbar pcolormesh/patches.
|
| 1118 |
+
|
| 1119 |
+
These are scaled between vmin and vmax, and already handle colorbar
|
| 1120 |
+
orientation.
|
| 1121 |
+
"""
|
| 1122 |
+
y, _ = self._proportional_y()
|
| 1123 |
+
# Use the vmin and vmax of the colorbar, which may not be the same
|
| 1124 |
+
# as the norm. There are situations where the colormap has a
|
| 1125 |
+
# narrower range than the colorbar and we want to accommodate the
|
| 1126 |
+
# extra contours.
|
| 1127 |
+
if (isinstance(self.norm, (colors.BoundaryNorm, colors.NoNorm))
|
| 1128 |
+
or self.boundaries is not None):
|
| 1129 |
+
# not using a norm.
|
| 1130 |
+
y = y * (self.vmax - self.vmin) + self.vmin
|
| 1131 |
+
else:
|
| 1132 |
+
# Update the norm values in a context manager as it is only
|
| 1133 |
+
# a temporary change and we don't want to propagate any signals
|
| 1134 |
+
# attached to the norm (callbacks.blocked).
|
| 1135 |
+
with (self.norm.callbacks.blocked(),
|
| 1136 |
+
cbook._setattr_cm(self.norm, vmin=self.vmin, vmax=self.vmax)):
|
| 1137 |
+
y = self.norm.inverse(y)
|
| 1138 |
+
self._y = y
|
| 1139 |
+
X, Y = np.meshgrid([0., 1.], y)
|
| 1140 |
+
if self.orientation == 'vertical':
|
| 1141 |
+
return (X, Y)
|
| 1142 |
+
else:
|
| 1143 |
+
return (Y, X)
|
| 1144 |
+
|
| 1145 |
+
def _forward_boundaries(self, x):
|
| 1146 |
+
# map boundaries equally between 0 and 1...
|
| 1147 |
+
b = self._boundaries
|
| 1148 |
+
y = np.interp(x, b, np.linspace(0, 1, len(b)))
|
| 1149 |
+
# the following avoids ticks in the extends:
|
| 1150 |
+
eps = (b[-1] - b[0]) * 1e-6
|
| 1151 |
+
# map these _well_ out of bounds to keep any ticks out
|
| 1152 |
+
# of the extends region...
|
| 1153 |
+
y[x < b[0]-eps] = -1
|
| 1154 |
+
y[x > b[-1]+eps] = 2
|
| 1155 |
+
return y
|
| 1156 |
+
|
| 1157 |
+
def _inverse_boundaries(self, x):
|
| 1158 |
+
# invert the above...
|
| 1159 |
+
b = self._boundaries
|
| 1160 |
+
return np.interp(x, np.linspace(0, 1, len(b)), b)
|
| 1161 |
+
|
| 1162 |
+
def _reset_locator_formatter_scale(self):
|
| 1163 |
+
"""
|
| 1164 |
+
Reset the locator et al to defaults. Any user-hardcoded changes
|
| 1165 |
+
need to be re-entered if this gets called (either at init, or when
|
| 1166 |
+
the mappable normal gets changed: Colorbar.update_normal)
|
| 1167 |
+
"""
|
| 1168 |
+
self._process_values()
|
| 1169 |
+
self._locator = None
|
| 1170 |
+
self._minorlocator = None
|
| 1171 |
+
self._formatter = None
|
| 1172 |
+
self._minorformatter = None
|
| 1173 |
+
if (isinstance(self.mappable, contour.ContourSet) and
|
| 1174 |
+
isinstance(self.norm, colors.LogNorm)):
|
| 1175 |
+
# if contours have lognorm, give them a log scale...
|
| 1176 |
+
self._set_scale('log')
|
| 1177 |
+
elif (self.boundaries is not None or
|
| 1178 |
+
isinstance(self.norm, colors.BoundaryNorm)):
|
| 1179 |
+
if self.spacing == 'uniform':
|
| 1180 |
+
funcs = (self._forward_boundaries, self._inverse_boundaries)
|
| 1181 |
+
self._set_scale('function', functions=funcs)
|
| 1182 |
+
elif self.spacing == 'proportional':
|
| 1183 |
+
self._set_scale('linear')
|
| 1184 |
+
elif getattr(self.norm, '_scale', None):
|
| 1185 |
+
# use the norm's scale (if it exists and is not None):
|
| 1186 |
+
self._set_scale(self.norm._scale)
|
| 1187 |
+
elif type(self.norm) is colors.Normalize:
|
| 1188 |
+
# plain Normalize:
|
| 1189 |
+
self._set_scale('linear')
|
| 1190 |
+
else:
|
| 1191 |
+
# norm._scale is None or not an attr: derive the scale from
|
| 1192 |
+
# the Norm:
|
| 1193 |
+
funcs = (self.norm, self.norm.inverse)
|
| 1194 |
+
self._set_scale('function', functions=funcs)
|
| 1195 |
+
|
| 1196 |
+
def _locate(self, x):
|
| 1197 |
+
"""
|
| 1198 |
+
Given a set of color data values, return their
|
| 1199 |
+
corresponding colorbar data coordinates.
|
| 1200 |
+
"""
|
| 1201 |
+
if isinstance(self.norm, (colors.NoNorm, colors.BoundaryNorm)):
|
| 1202 |
+
b = self._boundaries
|
| 1203 |
+
xn = x
|
| 1204 |
+
else:
|
| 1205 |
+
# Do calculations using normalized coordinates so
|
| 1206 |
+
# as to make the interpolation more accurate.
|
| 1207 |
+
b = self.norm(self._boundaries, clip=False).filled()
|
| 1208 |
+
xn = self.norm(x, clip=False).filled()
|
| 1209 |
+
|
| 1210 |
+
bunique = b[self._inside]
|
| 1211 |
+
yunique = self._y
|
| 1212 |
+
|
| 1213 |
+
z = np.interp(xn, bunique, yunique)
|
| 1214 |
+
return z
|
| 1215 |
+
|
| 1216 |
+
# trivial helpers
|
| 1217 |
+
|
| 1218 |
+
def _uniform_y(self, N):
|
| 1219 |
+
"""
|
| 1220 |
+
Return colorbar data coordinates for *N* uniformly
|
| 1221 |
+
spaced boundaries, plus extension lengths if required.
|
| 1222 |
+
"""
|
| 1223 |
+
automin = automax = 1. / (N - 1.)
|
| 1224 |
+
extendlength = self._get_extension_lengths(self.extendfrac,
|
| 1225 |
+
automin, automax,
|
| 1226 |
+
default=0.05)
|
| 1227 |
+
y = np.linspace(0, 1, N)
|
| 1228 |
+
return y, extendlength
|
| 1229 |
+
|
| 1230 |
+
def _proportional_y(self):
|
| 1231 |
+
"""
|
| 1232 |
+
Return colorbar data coordinates for the boundaries of
|
| 1233 |
+
a proportional colorbar, plus extension lengths if required:
|
| 1234 |
+
"""
|
| 1235 |
+
if (isinstance(self.norm, colors.BoundaryNorm) or
|
| 1236 |
+
self.boundaries is not None):
|
| 1237 |
+
y = (self._boundaries - self._boundaries[self._inside][0])
|
| 1238 |
+
y = y / (self._boundaries[self._inside][-1] -
|
| 1239 |
+
self._boundaries[self._inside][0])
|
| 1240 |
+
# need yscaled the same as the axes scale to get
|
| 1241 |
+
# the extend lengths.
|
| 1242 |
+
if self.spacing == 'uniform':
|
| 1243 |
+
yscaled = self._forward_boundaries(self._boundaries)
|
| 1244 |
+
else:
|
| 1245 |
+
yscaled = y
|
| 1246 |
+
else:
|
| 1247 |
+
y = self.norm(self._boundaries.copy())
|
| 1248 |
+
y = np.ma.filled(y, np.nan)
|
| 1249 |
+
# the norm and the scale should be the same...
|
| 1250 |
+
yscaled = y
|
| 1251 |
+
y = y[self._inside]
|
| 1252 |
+
yscaled = yscaled[self._inside]
|
| 1253 |
+
# normalize from 0..1:
|
| 1254 |
+
norm = colors.Normalize(y[0], y[-1])
|
| 1255 |
+
y = np.ma.filled(norm(y), np.nan)
|
| 1256 |
+
norm = colors.Normalize(yscaled[0], yscaled[-1])
|
| 1257 |
+
yscaled = np.ma.filled(norm(yscaled), np.nan)
|
| 1258 |
+
# make the lower and upper extend lengths proportional to the lengths
|
| 1259 |
+
# of the first and last boundary spacing (if extendfrac='auto'):
|
| 1260 |
+
automin = yscaled[1] - yscaled[0]
|
| 1261 |
+
automax = yscaled[-1] - yscaled[-2]
|
| 1262 |
+
extendlength = [0, 0]
|
| 1263 |
+
if self._extend_lower() or self._extend_upper():
|
| 1264 |
+
extendlength = self._get_extension_lengths(
|
| 1265 |
+
self.extendfrac, automin, automax, default=0.05)
|
| 1266 |
+
return y, extendlength
|
| 1267 |
+
|
| 1268 |
+
def _get_extension_lengths(self, frac, automin, automax, default=0.05):
|
| 1269 |
+
"""
|
| 1270 |
+
Return the lengths of colorbar extensions.
|
| 1271 |
+
|
| 1272 |
+
This is a helper method for _uniform_y and _proportional_y.
|
| 1273 |
+
"""
|
| 1274 |
+
# Set the default value.
|
| 1275 |
+
extendlength = np.array([default, default])
|
| 1276 |
+
if isinstance(frac, str):
|
| 1277 |
+
_api.check_in_list(['auto'], extendfrac=frac.lower())
|
| 1278 |
+
# Use the provided values when 'auto' is required.
|
| 1279 |
+
extendlength[:] = [automin, automax]
|
| 1280 |
+
elif frac is not None:
|
| 1281 |
+
try:
|
| 1282 |
+
# Try to set min and max extension fractions directly.
|
| 1283 |
+
extendlength[:] = frac
|
| 1284 |
+
# If frac is a sequence containing None then NaN may
|
| 1285 |
+
# be encountered. This is an error.
|
| 1286 |
+
if np.isnan(extendlength).any():
|
| 1287 |
+
raise ValueError()
|
| 1288 |
+
except (TypeError, ValueError) as err:
|
| 1289 |
+
# Raise an error on encountering an invalid value for frac.
|
| 1290 |
+
raise ValueError('invalid value for extendfrac') from err
|
| 1291 |
+
return extendlength
|
| 1292 |
+
|
| 1293 |
+
def _extend_lower(self):
|
| 1294 |
+
"""Return whether the lower limit is open ended."""
|
| 1295 |
+
minmax = "max" if self.long_axis.get_inverted() else "min"
|
| 1296 |
+
return self.extend in ('both', minmax)
|
| 1297 |
+
|
| 1298 |
+
def _extend_upper(self):
|
| 1299 |
+
"""Return whether the upper limit is open ended."""
|
| 1300 |
+
minmax = "min" if self.long_axis.get_inverted() else "max"
|
| 1301 |
+
return self.extend in ('both', minmax)
|
| 1302 |
+
|
| 1303 |
+
def _short_axis(self):
|
| 1304 |
+
"""Return the short axis"""
|
| 1305 |
+
if self.orientation == 'vertical':
|
| 1306 |
+
return self.ax.xaxis
|
| 1307 |
+
return self.ax.yaxis
|
| 1308 |
+
|
| 1309 |
+
def _get_view(self):
|
| 1310 |
+
# docstring inherited
|
| 1311 |
+
# An interactive view for a colorbar is the norm's vmin/vmax
|
| 1312 |
+
return self.norm.vmin, self.norm.vmax
|
| 1313 |
+
|
| 1314 |
+
def _set_view(self, view):
|
| 1315 |
+
# docstring inherited
|
| 1316 |
+
# An interactive view for a colorbar is the norm's vmin/vmax
|
| 1317 |
+
self.norm.vmin, self.norm.vmax = view
|
| 1318 |
+
|
| 1319 |
+
def _set_view_from_bbox(self, bbox, direction='in',
|
| 1320 |
+
mode=None, twinx=False, twiny=False):
|
| 1321 |
+
# docstring inherited
|
| 1322 |
+
# For colorbars, we use the zoom bbox to scale the norm's vmin/vmax
|
| 1323 |
+
new_xbound, new_ybound = self.ax._prepare_view_from_bbox(
|
| 1324 |
+
bbox, direction=direction, mode=mode, twinx=twinx, twiny=twiny)
|
| 1325 |
+
if self.orientation == 'horizontal':
|
| 1326 |
+
self.norm.vmin, self.norm.vmax = new_xbound
|
| 1327 |
+
elif self.orientation == 'vertical':
|
| 1328 |
+
self.norm.vmin, self.norm.vmax = new_ybound
|
| 1329 |
+
|
| 1330 |
+
def drag_pan(self, button, key, x, y):
|
| 1331 |
+
# docstring inherited
|
| 1332 |
+
points = self.ax._get_pan_points(button, key, x, y)
|
| 1333 |
+
if points is not None:
|
| 1334 |
+
if self.orientation == 'horizontal':
|
| 1335 |
+
self.norm.vmin, self.norm.vmax = points[:, 0]
|
| 1336 |
+
elif self.orientation == 'vertical':
|
| 1337 |
+
self.norm.vmin, self.norm.vmax = points[:, 1]
|
| 1338 |
+
|
| 1339 |
+
|
| 1340 |
+
ColorbarBase = Colorbar # Backcompat API
|
| 1341 |
+
|
| 1342 |
+
|
| 1343 |
+
def _normalize_location_orientation(location, orientation):
|
| 1344 |
+
if location is None:
|
| 1345 |
+
location = _get_ticklocation_from_orientation(orientation)
|
| 1346 |
+
loc_settings = _api.check_getitem({
|
| 1347 |
+
"left": {"location": "left", "anchor": (1.0, 0.5),
|
| 1348 |
+
"panchor": (0.0, 0.5), "pad": 0.10},
|
| 1349 |
+
"right": {"location": "right", "anchor": (0.0, 0.5),
|
| 1350 |
+
"panchor": (1.0, 0.5), "pad": 0.05},
|
| 1351 |
+
"top": {"location": "top", "anchor": (0.5, 0.0),
|
| 1352 |
+
"panchor": (0.5, 1.0), "pad": 0.05},
|
| 1353 |
+
"bottom": {"location": "bottom", "anchor": (0.5, 1.0),
|
| 1354 |
+
"panchor": (0.5, 0.0), "pad": 0.15},
|
| 1355 |
+
}, location=location)
|
| 1356 |
+
loc_settings["orientation"] = _get_orientation_from_location(location)
|
| 1357 |
+
if orientation is not None and orientation != loc_settings["orientation"]:
|
| 1358 |
+
# Allow the user to pass both if they are consistent.
|
| 1359 |
+
raise TypeError("location and orientation are mutually exclusive")
|
| 1360 |
+
return loc_settings
|
| 1361 |
+
|
| 1362 |
+
|
| 1363 |
+
def _get_orientation_from_location(location):
|
| 1364 |
+
return _api.check_getitem(
|
| 1365 |
+
{None: None, "left": "vertical", "right": "vertical",
|
| 1366 |
+
"top": "horizontal", "bottom": "horizontal"}, location=location)
|
| 1367 |
+
|
| 1368 |
+
|
| 1369 |
+
def _get_ticklocation_from_orientation(orientation):
|
| 1370 |
+
return _api.check_getitem(
|
| 1371 |
+
{None: "right", "vertical": "right", "horizontal": "bottom"},
|
| 1372 |
+
orientation=orientation)
|
| 1373 |
+
|
| 1374 |
+
|
| 1375 |
+
@_docstring.interpd
|
| 1376 |
+
def make_axes(parents, location=None, orientation=None, fraction=0.15,
|
| 1377 |
+
shrink=1.0, aspect=20, **kwargs):
|
| 1378 |
+
"""
|
| 1379 |
+
Create an `~.axes.Axes` suitable for a colorbar.
|
| 1380 |
+
|
| 1381 |
+
The Axes is placed in the figure of the *parents* Axes, by resizing and
|
| 1382 |
+
repositioning *parents*.
|
| 1383 |
+
|
| 1384 |
+
Parameters
|
| 1385 |
+
----------
|
| 1386 |
+
parents : `~matplotlib.axes.Axes` or iterable or `numpy.ndarray` of `~.axes.Axes`
|
| 1387 |
+
The Axes to use as parents for placing the colorbar.
|
| 1388 |
+
%(_make_axes_kw_doc)s
|
| 1389 |
+
|
| 1390 |
+
Returns
|
| 1391 |
+
-------
|
| 1392 |
+
cax : `~matplotlib.axes.Axes`
|
| 1393 |
+
The child Axes.
|
| 1394 |
+
kwargs : dict
|
| 1395 |
+
The reduced keyword dictionary to be passed when creating the colorbar
|
| 1396 |
+
instance.
|
| 1397 |
+
"""
|
| 1398 |
+
loc_settings = _normalize_location_orientation(location, orientation)
|
| 1399 |
+
# put appropriate values into the kwargs dict for passing back to
|
| 1400 |
+
# the Colorbar class
|
| 1401 |
+
kwargs['orientation'] = loc_settings['orientation']
|
| 1402 |
+
location = kwargs['ticklocation'] = loc_settings['location']
|
| 1403 |
+
|
| 1404 |
+
anchor = kwargs.pop('anchor', loc_settings['anchor'])
|
| 1405 |
+
panchor = kwargs.pop('panchor', loc_settings['panchor'])
|
| 1406 |
+
aspect0 = aspect
|
| 1407 |
+
# turn parents into a list if it is not already. Note we cannot
|
| 1408 |
+
# use .flatten or .ravel as these copy the references rather than
|
| 1409 |
+
# reuse them, leading to a memory leak
|
| 1410 |
+
if isinstance(parents, np.ndarray):
|
| 1411 |
+
parents = list(parents.flat)
|
| 1412 |
+
elif np.iterable(parents):
|
| 1413 |
+
parents = list(parents)
|
| 1414 |
+
else:
|
| 1415 |
+
parents = [parents]
|
| 1416 |
+
|
| 1417 |
+
fig = parents[0].get_figure()
|
| 1418 |
+
|
| 1419 |
+
pad0 = 0.05 if fig.get_constrained_layout() else loc_settings['pad']
|
| 1420 |
+
pad = kwargs.pop('pad', pad0)
|
| 1421 |
+
|
| 1422 |
+
if not all(fig is ax.get_figure() for ax in parents):
|
| 1423 |
+
raise ValueError('Unable to create a colorbar Axes as not all '
|
| 1424 |
+
'parents share the same figure.')
|
| 1425 |
+
|
| 1426 |
+
# take a bounding box around all of the given Axes
|
| 1427 |
+
parents_bbox = mtransforms.Bbox.union(
|
| 1428 |
+
[ax.get_position(original=True).frozen() for ax in parents])
|
| 1429 |
+
|
| 1430 |
+
pb = parents_bbox
|
| 1431 |
+
if location in ('left', 'right'):
|
| 1432 |
+
if location == 'left':
|
| 1433 |
+
pbcb, _, pb1 = pb.splitx(fraction, fraction + pad)
|
| 1434 |
+
else:
|
| 1435 |
+
pb1, _, pbcb = pb.splitx(1 - fraction - pad, 1 - fraction)
|
| 1436 |
+
pbcb = pbcb.shrunk(1.0, shrink).anchored(anchor, pbcb)
|
| 1437 |
+
else:
|
| 1438 |
+
if location == 'bottom':
|
| 1439 |
+
pbcb, _, pb1 = pb.splity(fraction, fraction + pad)
|
| 1440 |
+
else:
|
| 1441 |
+
pb1, _, pbcb = pb.splity(1 - fraction - pad, 1 - fraction)
|
| 1442 |
+
pbcb = pbcb.shrunk(shrink, 1.0).anchored(anchor, pbcb)
|
| 1443 |
+
|
| 1444 |
+
# define the aspect ratio in terms of y's per x rather than x's per y
|
| 1445 |
+
aspect = 1.0 / aspect
|
| 1446 |
+
|
| 1447 |
+
# define a transform which takes us from old axes coordinates to
|
| 1448 |
+
# new axes coordinates
|
| 1449 |
+
shrinking_trans = mtransforms.BboxTransform(parents_bbox, pb1)
|
| 1450 |
+
|
| 1451 |
+
# transform each of the Axes in parents using the new transform
|
| 1452 |
+
for ax in parents:
|
| 1453 |
+
new_posn = shrinking_trans.transform(ax.get_position(original=True))
|
| 1454 |
+
new_posn = mtransforms.Bbox(new_posn)
|
| 1455 |
+
ax._set_position(new_posn)
|
| 1456 |
+
if panchor is not False:
|
| 1457 |
+
ax.set_anchor(panchor)
|
| 1458 |
+
|
| 1459 |
+
cax = fig.add_axes(pbcb, label="<colorbar>")
|
| 1460 |
+
for a in parents:
|
| 1461 |
+
# tell the parent it has a colorbar
|
| 1462 |
+
a._colorbars += [cax]
|
| 1463 |
+
cax._colorbar_info = dict(
|
| 1464 |
+
parents=parents,
|
| 1465 |
+
location=location,
|
| 1466 |
+
shrink=shrink,
|
| 1467 |
+
anchor=anchor,
|
| 1468 |
+
panchor=panchor,
|
| 1469 |
+
fraction=fraction,
|
| 1470 |
+
aspect=aspect0,
|
| 1471 |
+
pad=pad)
|
| 1472 |
+
# and we need to set the aspect ratio by hand...
|
| 1473 |
+
cax.set_anchor(anchor)
|
| 1474 |
+
cax.set_box_aspect(aspect)
|
| 1475 |
+
cax.set_aspect('auto')
|
| 1476 |
+
|
| 1477 |
+
return cax, kwargs
|
| 1478 |
+
|
| 1479 |
+
|
| 1480 |
+
@_docstring.interpd
|
| 1481 |
+
def make_axes_gridspec(parent, *, location=None, orientation=None,
|
| 1482 |
+
fraction=0.15, shrink=1.0, aspect=20, **kwargs):
|
| 1483 |
+
"""
|
| 1484 |
+
Create an `~.axes.Axes` suitable for a colorbar.
|
| 1485 |
+
|
| 1486 |
+
The Axes is placed in the figure of the *parent* Axes, by resizing and
|
| 1487 |
+
repositioning *parent*.
|
| 1488 |
+
|
| 1489 |
+
This function is similar to `.make_axes` and mostly compatible with it.
|
| 1490 |
+
Primary differences are
|
| 1491 |
+
|
| 1492 |
+
- `.make_axes_gridspec` requires the *parent* to have a subplotspec.
|
| 1493 |
+
- `.make_axes` positions the Axes in figure coordinates;
|
| 1494 |
+
`.make_axes_gridspec` positions it using a subplotspec.
|
| 1495 |
+
- `.make_axes` updates the position of the parent. `.make_axes_gridspec`
|
| 1496 |
+
replaces the parent gridspec with a new one.
|
| 1497 |
+
|
| 1498 |
+
Parameters
|
| 1499 |
+
----------
|
| 1500 |
+
parent : `~matplotlib.axes.Axes`
|
| 1501 |
+
The Axes to use as parent for placing the colorbar.
|
| 1502 |
+
%(_make_axes_kw_doc)s
|
| 1503 |
+
|
| 1504 |
+
Returns
|
| 1505 |
+
-------
|
| 1506 |
+
cax : `~matplotlib.axes.Axes`
|
| 1507 |
+
The child Axes.
|
| 1508 |
+
kwargs : dict
|
| 1509 |
+
The reduced keyword dictionary to be passed when creating the colorbar
|
| 1510 |
+
instance.
|
| 1511 |
+
"""
|
| 1512 |
+
|
| 1513 |
+
loc_settings = _normalize_location_orientation(location, orientation)
|
| 1514 |
+
kwargs['orientation'] = loc_settings['orientation']
|
| 1515 |
+
location = kwargs['ticklocation'] = loc_settings['location']
|
| 1516 |
+
|
| 1517 |
+
aspect0 = aspect
|
| 1518 |
+
anchor = kwargs.pop('anchor', loc_settings['anchor'])
|
| 1519 |
+
panchor = kwargs.pop('panchor', loc_settings['panchor'])
|
| 1520 |
+
pad = kwargs.pop('pad', loc_settings["pad"])
|
| 1521 |
+
wh_space = 2 * pad / (1 - pad)
|
| 1522 |
+
|
| 1523 |
+
if location in ('left', 'right'):
|
| 1524 |
+
gs = parent.get_subplotspec().subgridspec(
|
| 1525 |
+
3, 2, wspace=wh_space, hspace=0,
|
| 1526 |
+
height_ratios=[(1-anchor[1])*(1-shrink), shrink, anchor[1]*(1-shrink)])
|
| 1527 |
+
if location == 'left':
|
| 1528 |
+
gs.set_width_ratios([fraction, 1 - fraction - pad])
|
| 1529 |
+
ss_main = gs[:, 1]
|
| 1530 |
+
ss_cb = gs[1, 0]
|
| 1531 |
+
else:
|
| 1532 |
+
gs.set_width_ratios([1 - fraction - pad, fraction])
|
| 1533 |
+
ss_main = gs[:, 0]
|
| 1534 |
+
ss_cb = gs[1, 1]
|
| 1535 |
+
else:
|
| 1536 |
+
gs = parent.get_subplotspec().subgridspec(
|
| 1537 |
+
2, 3, hspace=wh_space, wspace=0,
|
| 1538 |
+
width_ratios=[anchor[0]*(1-shrink), shrink, (1-anchor[0])*(1-shrink)])
|
| 1539 |
+
if location == 'top':
|
| 1540 |
+
gs.set_height_ratios([fraction, 1 - fraction - pad])
|
| 1541 |
+
ss_main = gs[1, :]
|
| 1542 |
+
ss_cb = gs[0, 1]
|
| 1543 |
+
else:
|
| 1544 |
+
gs.set_height_ratios([1 - fraction - pad, fraction])
|
| 1545 |
+
ss_main = gs[0, :]
|
| 1546 |
+
ss_cb = gs[1, 1]
|
| 1547 |
+
aspect = 1 / aspect
|
| 1548 |
+
|
| 1549 |
+
parent.set_subplotspec(ss_main)
|
| 1550 |
+
if panchor is not False:
|
| 1551 |
+
parent.set_anchor(panchor)
|
| 1552 |
+
|
| 1553 |
+
fig = parent.get_figure()
|
| 1554 |
+
cax = fig.add_subplot(ss_cb, label="<colorbar>")
|
| 1555 |
+
cax.set_anchor(anchor)
|
| 1556 |
+
cax.set_box_aspect(aspect)
|
| 1557 |
+
cax.set_aspect('auto')
|
| 1558 |
+
cax._colorbar_info = dict(
|
| 1559 |
+
location=location,
|
| 1560 |
+
parents=[parent],
|
| 1561 |
+
shrink=shrink,
|
| 1562 |
+
anchor=anchor,
|
| 1563 |
+
panchor=panchor,
|
| 1564 |
+
fraction=fraction,
|
| 1565 |
+
aspect=aspect0,
|
| 1566 |
+
pad=pad)
|
| 1567 |
+
|
| 1568 |
+
return cax, kwargs
|
llava_video/lib/python3.10/site-packages/matplotlib/colorizer.py
ADDED
|
@@ -0,0 +1,692 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
The Colorizer class which handles the data to color pipeline via a
|
| 3 |
+
normalization and a colormap.
|
| 4 |
+
|
| 5 |
+
.. admonition:: Provisional status of colorizer
|
| 6 |
+
|
| 7 |
+
The ``colorizer`` module and classes in this file are considered
|
| 8 |
+
provisional and may change at any time without a deprecation period.
|
| 9 |
+
|
| 10 |
+
.. seealso::
|
| 11 |
+
|
| 12 |
+
:doc:`/gallery/color/colormap_reference` for a list of builtin colormaps.
|
| 13 |
+
|
| 14 |
+
:ref:`colormap-manipulation` for examples of how to make colormaps.
|
| 15 |
+
|
| 16 |
+
:ref:`colormaps` for an in-depth discussion of choosing colormaps.
|
| 17 |
+
|
| 18 |
+
:ref:`colormapnorms` for more details about data normalization.
|
| 19 |
+
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
import functools
|
| 23 |
+
|
| 24 |
+
import numpy as np
|
| 25 |
+
from numpy import ma
|
| 26 |
+
|
| 27 |
+
from matplotlib import _api, colors, cbook, scale, artist
|
| 28 |
+
import matplotlib as mpl
|
| 29 |
+
|
| 30 |
+
mpl._docstring.interpd.register(
|
| 31 |
+
colorizer_doc="""\
|
| 32 |
+
colorizer : `~matplotlib.colorizer.Colorizer` or None, default: None
|
| 33 |
+
The Colorizer object used to map color to data. If None, a Colorizer
|
| 34 |
+
object is created from a *norm* and *cmap*.""",
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
class Colorizer:
|
| 39 |
+
"""
|
| 40 |
+
Data to color pipeline.
|
| 41 |
+
|
| 42 |
+
This pipeline is accessible via `.Colorizer.to_rgba` and executed via
|
| 43 |
+
the `.Colorizer.norm` and `.Colorizer.cmap` attributes.
|
| 44 |
+
|
| 45 |
+
Parameters
|
| 46 |
+
----------
|
| 47 |
+
cmap: colorbar.Colorbar or str or None, default: None
|
| 48 |
+
The colormap used to color data.
|
| 49 |
+
|
| 50 |
+
norm: colors.Normalize or str or None, default: None
|
| 51 |
+
The normalization used to normalize the data
|
| 52 |
+
"""
|
| 53 |
+
def __init__(self, cmap=None, norm=None):
|
| 54 |
+
|
| 55 |
+
self._cmap = None
|
| 56 |
+
self._set_cmap(cmap)
|
| 57 |
+
|
| 58 |
+
self._id_norm = None
|
| 59 |
+
self._norm = None
|
| 60 |
+
self.norm = norm
|
| 61 |
+
|
| 62 |
+
self.callbacks = cbook.CallbackRegistry(signals=["changed"])
|
| 63 |
+
self.colorbar = None
|
| 64 |
+
|
| 65 |
+
def _scale_norm(self, norm, vmin, vmax, A):
|
| 66 |
+
"""
|
| 67 |
+
Helper for initial scaling.
|
| 68 |
+
|
| 69 |
+
Used by public functions that create a ScalarMappable and support
|
| 70 |
+
parameters *vmin*, *vmax* and *norm*. This makes sure that a *norm*
|
| 71 |
+
will take precedence over *vmin*, *vmax*.
|
| 72 |
+
|
| 73 |
+
Note that this method does not set the norm.
|
| 74 |
+
"""
|
| 75 |
+
if vmin is not None or vmax is not None:
|
| 76 |
+
self.set_clim(vmin, vmax)
|
| 77 |
+
if isinstance(norm, colors.Normalize):
|
| 78 |
+
raise ValueError(
|
| 79 |
+
"Passing a Normalize instance simultaneously with "
|
| 80 |
+
"vmin/vmax is not supported. Please pass vmin/vmax "
|
| 81 |
+
"directly to the norm when creating it.")
|
| 82 |
+
|
| 83 |
+
# always resolve the autoscaling so we have concrete limits
|
| 84 |
+
# rather than deferring to draw time.
|
| 85 |
+
self.autoscale_None(A)
|
| 86 |
+
|
| 87 |
+
@property
|
| 88 |
+
def norm(self):
|
| 89 |
+
return self._norm
|
| 90 |
+
|
| 91 |
+
@norm.setter
|
| 92 |
+
def norm(self, norm):
|
| 93 |
+
_api.check_isinstance((colors.Normalize, str, None), norm=norm)
|
| 94 |
+
if norm is None:
|
| 95 |
+
norm = colors.Normalize()
|
| 96 |
+
elif isinstance(norm, str):
|
| 97 |
+
try:
|
| 98 |
+
scale_cls = scale._scale_mapping[norm]
|
| 99 |
+
except KeyError:
|
| 100 |
+
raise ValueError(
|
| 101 |
+
"Invalid norm str name; the following values are "
|
| 102 |
+
f"supported: {', '.join(scale._scale_mapping)}"
|
| 103 |
+
) from None
|
| 104 |
+
norm = _auto_norm_from_scale(scale_cls)()
|
| 105 |
+
|
| 106 |
+
if norm is self.norm:
|
| 107 |
+
# We aren't updating anything
|
| 108 |
+
return
|
| 109 |
+
|
| 110 |
+
in_init = self.norm is None
|
| 111 |
+
# Remove the current callback and connect to the new one
|
| 112 |
+
if not in_init:
|
| 113 |
+
self.norm.callbacks.disconnect(self._id_norm)
|
| 114 |
+
self._norm = norm
|
| 115 |
+
self._id_norm = self.norm.callbacks.connect('changed',
|
| 116 |
+
self.changed)
|
| 117 |
+
if not in_init:
|
| 118 |
+
self.changed()
|
| 119 |
+
|
| 120 |
+
def to_rgba(self, x, alpha=None, bytes=False, norm=True):
|
| 121 |
+
"""
|
| 122 |
+
Return a normalized RGBA array corresponding to *x*.
|
| 123 |
+
|
| 124 |
+
In the normal case, *x* is a 1D or 2D sequence of scalars, and
|
| 125 |
+
the corresponding `~numpy.ndarray` of RGBA values will be returned,
|
| 126 |
+
based on the norm and colormap set for this Colorizer.
|
| 127 |
+
|
| 128 |
+
There is one special case, for handling images that are already
|
| 129 |
+
RGB or RGBA, such as might have been read from an image file.
|
| 130 |
+
If *x* is an `~numpy.ndarray` with 3 dimensions,
|
| 131 |
+
and the last dimension is either 3 or 4, then it will be
|
| 132 |
+
treated as an RGB or RGBA array, and no mapping will be done.
|
| 133 |
+
The array can be `~numpy.uint8`, or it can be floats with
|
| 134 |
+
values in the 0-1 range; otherwise a ValueError will be raised.
|
| 135 |
+
Any NaNs or masked elements will be set to 0 alpha.
|
| 136 |
+
If the last dimension is 3, the *alpha* kwarg (defaulting to 1)
|
| 137 |
+
will be used to fill in the transparency. If the last dimension
|
| 138 |
+
is 4, the *alpha* kwarg is ignored; it does not
|
| 139 |
+
replace the preexisting alpha. A ValueError will be raised
|
| 140 |
+
if the third dimension is other than 3 or 4.
|
| 141 |
+
|
| 142 |
+
In either case, if *bytes* is *False* (default), the RGBA
|
| 143 |
+
array will be floats in the 0-1 range; if it is *True*,
|
| 144 |
+
the returned RGBA array will be `~numpy.uint8` in the 0 to 255 range.
|
| 145 |
+
|
| 146 |
+
If norm is False, no normalization of the input data is
|
| 147 |
+
performed, and it is assumed to be in the range (0-1).
|
| 148 |
+
|
| 149 |
+
"""
|
| 150 |
+
# First check for special case, image input:
|
| 151 |
+
if isinstance(x, np.ndarray) and x.ndim == 3:
|
| 152 |
+
return self._pass_image_data(x, alpha, bytes, norm)
|
| 153 |
+
|
| 154 |
+
# Otherwise run norm -> colormap pipeline
|
| 155 |
+
x = ma.asarray(x)
|
| 156 |
+
if norm:
|
| 157 |
+
x = self.norm(x)
|
| 158 |
+
rgba = self.cmap(x, alpha=alpha, bytes=bytes)
|
| 159 |
+
return rgba
|
| 160 |
+
|
| 161 |
+
@staticmethod
|
| 162 |
+
def _pass_image_data(x, alpha=None, bytes=False, norm=True):
|
| 163 |
+
"""
|
| 164 |
+
Helper function to pass ndarray of shape (...,3) or (..., 4)
|
| 165 |
+
through `to_rgba()`, see `to_rgba()` for docstring.
|
| 166 |
+
"""
|
| 167 |
+
if x.shape[2] == 3:
|
| 168 |
+
if alpha is None:
|
| 169 |
+
alpha = 1
|
| 170 |
+
if x.dtype == np.uint8:
|
| 171 |
+
alpha = np.uint8(alpha * 255)
|
| 172 |
+
m, n = x.shape[:2]
|
| 173 |
+
xx = np.empty(shape=(m, n, 4), dtype=x.dtype)
|
| 174 |
+
xx[:, :, :3] = x
|
| 175 |
+
xx[:, :, 3] = alpha
|
| 176 |
+
elif x.shape[2] == 4:
|
| 177 |
+
xx = x
|
| 178 |
+
else:
|
| 179 |
+
raise ValueError("Third dimension must be 3 or 4")
|
| 180 |
+
if xx.dtype.kind == 'f':
|
| 181 |
+
# If any of R, G, B, or A is nan, set to 0
|
| 182 |
+
if np.any(nans := np.isnan(x)):
|
| 183 |
+
if x.shape[2] == 4:
|
| 184 |
+
xx = xx.copy()
|
| 185 |
+
xx[np.any(nans, axis=2), :] = 0
|
| 186 |
+
|
| 187 |
+
if norm and (xx.max() > 1 or xx.min() < 0):
|
| 188 |
+
raise ValueError("Floating point image RGB values "
|
| 189 |
+
"must be in the 0..1 range.")
|
| 190 |
+
if bytes:
|
| 191 |
+
xx = (xx * 255).astype(np.uint8)
|
| 192 |
+
elif xx.dtype == np.uint8:
|
| 193 |
+
if not bytes:
|
| 194 |
+
xx = xx.astype(np.float32) / 255
|
| 195 |
+
else:
|
| 196 |
+
raise ValueError("Image RGB array must be uint8 or "
|
| 197 |
+
"floating point; found %s" % xx.dtype)
|
| 198 |
+
# Account for any masked entries in the original array
|
| 199 |
+
# If any of R, G, B, or A are masked for an entry, we set alpha to 0
|
| 200 |
+
if np.ma.is_masked(x):
|
| 201 |
+
xx[np.any(np.ma.getmaskarray(x), axis=2), 3] = 0
|
| 202 |
+
return xx
|
| 203 |
+
|
| 204 |
+
def autoscale(self, A):
|
| 205 |
+
"""
|
| 206 |
+
Autoscale the scalar limits on the norm instance using the
|
| 207 |
+
current array
|
| 208 |
+
"""
|
| 209 |
+
if A is None:
|
| 210 |
+
raise TypeError('You must first set_array for mappable')
|
| 211 |
+
# If the norm's limits are updated self.changed() will be called
|
| 212 |
+
# through the callbacks attached to the norm
|
| 213 |
+
self.norm.autoscale(A)
|
| 214 |
+
|
| 215 |
+
def autoscale_None(self, A):
|
| 216 |
+
"""
|
| 217 |
+
Autoscale the scalar limits on the norm instance using the
|
| 218 |
+
current array, changing only limits that are None
|
| 219 |
+
"""
|
| 220 |
+
if A is None:
|
| 221 |
+
raise TypeError('You must first set_array for mappable')
|
| 222 |
+
# If the norm's limits are updated self.changed() will be called
|
| 223 |
+
# through the callbacks attached to the norm
|
| 224 |
+
self.norm.autoscale_None(A)
|
| 225 |
+
|
| 226 |
+
def _set_cmap(self, cmap):
|
| 227 |
+
"""
|
| 228 |
+
Set the colormap for luminance data.
|
| 229 |
+
|
| 230 |
+
Parameters
|
| 231 |
+
----------
|
| 232 |
+
cmap : `.Colormap` or str or None
|
| 233 |
+
"""
|
| 234 |
+
# bury import to avoid circular imports
|
| 235 |
+
from matplotlib import cm
|
| 236 |
+
in_init = self._cmap is None
|
| 237 |
+
self._cmap = cm._ensure_cmap(cmap)
|
| 238 |
+
if not in_init:
|
| 239 |
+
self.changed() # Things are not set up properly yet.
|
| 240 |
+
|
| 241 |
+
@property
|
| 242 |
+
def cmap(self):
|
| 243 |
+
return self._cmap
|
| 244 |
+
|
| 245 |
+
@cmap.setter
|
| 246 |
+
def cmap(self, cmap):
|
| 247 |
+
self._set_cmap(cmap)
|
| 248 |
+
|
| 249 |
+
def set_clim(self, vmin=None, vmax=None):
|
| 250 |
+
"""
|
| 251 |
+
Set the norm limits for image scaling.
|
| 252 |
+
|
| 253 |
+
Parameters
|
| 254 |
+
----------
|
| 255 |
+
vmin, vmax : float
|
| 256 |
+
The limits.
|
| 257 |
+
|
| 258 |
+
The limits may also be passed as a tuple (*vmin*, *vmax*) as a
|
| 259 |
+
single positional argument.
|
| 260 |
+
|
| 261 |
+
.. ACCEPTS: (vmin: float, vmax: float)
|
| 262 |
+
"""
|
| 263 |
+
# If the norm's limits are updated self.changed() will be called
|
| 264 |
+
# through the callbacks attached to the norm
|
| 265 |
+
if vmax is None:
|
| 266 |
+
try:
|
| 267 |
+
vmin, vmax = vmin
|
| 268 |
+
except (TypeError, ValueError):
|
| 269 |
+
pass
|
| 270 |
+
if vmin is not None:
|
| 271 |
+
self.norm.vmin = colors._sanitize_extrema(vmin)
|
| 272 |
+
if vmax is not None:
|
| 273 |
+
self.norm.vmax = colors._sanitize_extrema(vmax)
|
| 274 |
+
|
| 275 |
+
def get_clim(self):
|
| 276 |
+
"""
|
| 277 |
+
Return the values (min, max) that are mapped to the colormap limits.
|
| 278 |
+
"""
|
| 279 |
+
return self.norm.vmin, self.norm.vmax
|
| 280 |
+
|
| 281 |
+
def changed(self):
|
| 282 |
+
"""
|
| 283 |
+
Call this whenever the mappable is changed to notify all the
|
| 284 |
+
callbackSM listeners to the 'changed' signal.
|
| 285 |
+
"""
|
| 286 |
+
self.callbacks.process('changed')
|
| 287 |
+
self.stale = True
|
| 288 |
+
|
| 289 |
+
@property
|
| 290 |
+
def vmin(self):
|
| 291 |
+
return self.get_clim()[0]
|
| 292 |
+
|
| 293 |
+
@vmin.setter
|
| 294 |
+
def vmin(self, vmin):
|
| 295 |
+
self.set_clim(vmin=vmin)
|
| 296 |
+
|
| 297 |
+
@property
|
| 298 |
+
def vmax(self):
|
| 299 |
+
return self.get_clim()[1]
|
| 300 |
+
|
| 301 |
+
@vmax.setter
|
| 302 |
+
def vmax(self, vmax):
|
| 303 |
+
self.set_clim(vmax=vmax)
|
| 304 |
+
|
| 305 |
+
@property
|
| 306 |
+
def clip(self):
|
| 307 |
+
return self.norm.clip
|
| 308 |
+
|
| 309 |
+
@clip.setter
|
| 310 |
+
def clip(self, clip):
|
| 311 |
+
self.norm.clip = clip
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
class _ColorizerInterface:
|
| 315 |
+
"""
|
| 316 |
+
Base class that contains the interface to `Colorizer` objects from
|
| 317 |
+
a `ColorizingArtist` or `.cm.ScalarMappable`.
|
| 318 |
+
|
| 319 |
+
Note: This class only contain functions that interface the .colorizer
|
| 320 |
+
attribute. Other functions that as shared between `.ColorizingArtist`
|
| 321 |
+
and `.cm.ScalarMappable` are not included.
|
| 322 |
+
"""
|
| 323 |
+
def _scale_norm(self, norm, vmin, vmax):
|
| 324 |
+
self._colorizer._scale_norm(norm, vmin, vmax, self._A)
|
| 325 |
+
|
| 326 |
+
def to_rgba(self, x, alpha=None, bytes=False, norm=True):
|
| 327 |
+
"""
|
| 328 |
+
Return a normalized RGBA array corresponding to *x*.
|
| 329 |
+
|
| 330 |
+
In the normal case, *x* is a 1D or 2D sequence of scalars, and
|
| 331 |
+
the corresponding `~numpy.ndarray` of RGBA values will be returned,
|
| 332 |
+
based on the norm and colormap set for this Colorizer.
|
| 333 |
+
|
| 334 |
+
There is one special case, for handling images that are already
|
| 335 |
+
RGB or RGBA, such as might have been read from an image file.
|
| 336 |
+
If *x* is an `~numpy.ndarray` with 3 dimensions,
|
| 337 |
+
and the last dimension is either 3 or 4, then it will be
|
| 338 |
+
treated as an RGB or RGBA array, and no mapping will be done.
|
| 339 |
+
The array can be `~numpy.uint8`, or it can be floats with
|
| 340 |
+
values in the 0-1 range; otherwise a ValueError will be raised.
|
| 341 |
+
Any NaNs or masked elements will be set to 0 alpha.
|
| 342 |
+
If the last dimension is 3, the *alpha* kwarg (defaulting to 1)
|
| 343 |
+
will be used to fill in the transparency. If the last dimension
|
| 344 |
+
is 4, the *alpha* kwarg is ignored; it does not
|
| 345 |
+
replace the preexisting alpha. A ValueError will be raised
|
| 346 |
+
if the third dimension is other than 3 or 4.
|
| 347 |
+
|
| 348 |
+
In either case, if *bytes* is *False* (default), the RGBA
|
| 349 |
+
array will be floats in the 0-1 range; if it is *True*,
|
| 350 |
+
the returned RGBA array will be `~numpy.uint8` in the 0 to 255 range.
|
| 351 |
+
|
| 352 |
+
If norm is False, no normalization of the input data is
|
| 353 |
+
performed, and it is assumed to be in the range (0-1).
|
| 354 |
+
|
| 355 |
+
"""
|
| 356 |
+
return self._colorizer.to_rgba(x, alpha=alpha, bytes=bytes, norm=norm)
|
| 357 |
+
|
| 358 |
+
def get_clim(self):
|
| 359 |
+
"""
|
| 360 |
+
Return the values (min, max) that are mapped to the colormap limits.
|
| 361 |
+
"""
|
| 362 |
+
return self._colorizer.get_clim()
|
| 363 |
+
|
| 364 |
+
def set_clim(self, vmin=None, vmax=None):
|
| 365 |
+
"""
|
| 366 |
+
Set the norm limits for image scaling.
|
| 367 |
+
|
| 368 |
+
Parameters
|
| 369 |
+
----------
|
| 370 |
+
vmin, vmax : float
|
| 371 |
+
The limits.
|
| 372 |
+
|
| 373 |
+
For scalar data, the limits may also be passed as a
|
| 374 |
+
tuple (*vmin*, *vmax*) as a single positional argument.
|
| 375 |
+
|
| 376 |
+
.. ACCEPTS: (vmin: float, vmax: float)
|
| 377 |
+
"""
|
| 378 |
+
# If the norm's limits are updated self.changed() will be called
|
| 379 |
+
# through the callbacks attached to the norm
|
| 380 |
+
self._colorizer.set_clim(vmin, vmax)
|
| 381 |
+
|
| 382 |
+
def get_alpha(self):
|
| 383 |
+
try:
|
| 384 |
+
return super().get_alpha()
|
| 385 |
+
except AttributeError:
|
| 386 |
+
return 1
|
| 387 |
+
|
| 388 |
+
@property
|
| 389 |
+
def cmap(self):
|
| 390 |
+
return self._colorizer.cmap
|
| 391 |
+
|
| 392 |
+
@cmap.setter
|
| 393 |
+
def cmap(self, cmap):
|
| 394 |
+
self._colorizer.cmap = cmap
|
| 395 |
+
|
| 396 |
+
def get_cmap(self):
|
| 397 |
+
"""Return the `.Colormap` instance."""
|
| 398 |
+
return self._colorizer.cmap
|
| 399 |
+
|
| 400 |
+
def set_cmap(self, cmap):
|
| 401 |
+
"""
|
| 402 |
+
Set the colormap for luminance data.
|
| 403 |
+
|
| 404 |
+
Parameters
|
| 405 |
+
----------
|
| 406 |
+
cmap : `.Colormap` or str or None
|
| 407 |
+
"""
|
| 408 |
+
self.cmap = cmap
|
| 409 |
+
|
| 410 |
+
@property
|
| 411 |
+
def norm(self):
|
| 412 |
+
return self._colorizer.norm
|
| 413 |
+
|
| 414 |
+
@norm.setter
|
| 415 |
+
def norm(self, norm):
|
| 416 |
+
self._colorizer.norm = norm
|
| 417 |
+
|
| 418 |
+
def set_norm(self, norm):
|
| 419 |
+
"""
|
| 420 |
+
Set the normalization instance.
|
| 421 |
+
|
| 422 |
+
Parameters
|
| 423 |
+
----------
|
| 424 |
+
norm : `.Normalize` or str or None
|
| 425 |
+
|
| 426 |
+
Notes
|
| 427 |
+
-----
|
| 428 |
+
If there are any colorbars using the mappable for this norm, setting
|
| 429 |
+
the norm of the mappable will reset the norm, locator, and formatters
|
| 430 |
+
on the colorbar to default.
|
| 431 |
+
"""
|
| 432 |
+
self.norm = norm
|
| 433 |
+
|
| 434 |
+
def autoscale(self):
|
| 435 |
+
"""
|
| 436 |
+
Autoscale the scalar limits on the norm instance using the
|
| 437 |
+
current array
|
| 438 |
+
"""
|
| 439 |
+
self._colorizer.autoscale(self._A)
|
| 440 |
+
|
| 441 |
+
def autoscale_None(self):
|
| 442 |
+
"""
|
| 443 |
+
Autoscale the scalar limits on the norm instance using the
|
| 444 |
+
current array, changing only limits that are None
|
| 445 |
+
"""
|
| 446 |
+
self._colorizer.autoscale_None(self._A)
|
| 447 |
+
|
| 448 |
+
@property
|
| 449 |
+
def colorbar(self):
|
| 450 |
+
"""
|
| 451 |
+
The last colorbar associated with this object. May be None
|
| 452 |
+
"""
|
| 453 |
+
return self._colorizer.colorbar
|
| 454 |
+
|
| 455 |
+
@colorbar.setter
|
| 456 |
+
def colorbar(self, colorbar):
|
| 457 |
+
self._colorizer.colorbar = colorbar
|
| 458 |
+
|
| 459 |
+
def _format_cursor_data_override(self, data):
|
| 460 |
+
# This function overwrites Artist.format_cursor_data(). We cannot
|
| 461 |
+
# implement cm.ScalarMappable.format_cursor_data() directly, because
|
| 462 |
+
# most cm.ScalarMappable subclasses inherit from Artist first and from
|
| 463 |
+
# cm.ScalarMappable second, so Artist.format_cursor_data would always
|
| 464 |
+
# have precedence over cm.ScalarMappable.format_cursor_data.
|
| 465 |
+
|
| 466 |
+
# Note if cm.ScalarMappable is depreciated, this functionality should be
|
| 467 |
+
# implemented as format_cursor_data() on ColorizingArtist.
|
| 468 |
+
n = self.cmap.N
|
| 469 |
+
if np.ma.getmask(data):
|
| 470 |
+
return "[]"
|
| 471 |
+
normed = self.norm(data)
|
| 472 |
+
if np.isfinite(normed):
|
| 473 |
+
if isinstance(self.norm, colors.BoundaryNorm):
|
| 474 |
+
# not an invertible normalization mapping
|
| 475 |
+
cur_idx = np.argmin(np.abs(self.norm.boundaries - data))
|
| 476 |
+
neigh_idx = max(0, cur_idx - 1)
|
| 477 |
+
# use max diff to prevent delta == 0
|
| 478 |
+
delta = np.diff(
|
| 479 |
+
self.norm.boundaries[neigh_idx:cur_idx + 2]
|
| 480 |
+
).max()
|
| 481 |
+
elif self.norm.vmin == self.norm.vmax:
|
| 482 |
+
# singular norms, use delta of 10% of only value
|
| 483 |
+
delta = np.abs(self.norm.vmin * .1)
|
| 484 |
+
else:
|
| 485 |
+
# Midpoints of neighboring color intervals.
|
| 486 |
+
neighbors = self.norm.inverse(
|
| 487 |
+
(int(normed * n) + np.array([0, 1])) / n)
|
| 488 |
+
delta = abs(neighbors - data).max()
|
| 489 |
+
g_sig_digits = cbook._g_sig_digits(data, delta)
|
| 490 |
+
else:
|
| 491 |
+
g_sig_digits = 3 # Consistent with default below.
|
| 492 |
+
return f"[{data:-#.{g_sig_digits}g}]"
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
class _ScalarMappable(_ColorizerInterface):
|
| 496 |
+
"""
|
| 497 |
+
A mixin class to map one or multiple sets of scalar data to RGBA.
|
| 498 |
+
|
| 499 |
+
The ScalarMappable applies data normalization before returning RGBA colors from
|
| 500 |
+
the given `~matplotlib.colors.Colormap`.
|
| 501 |
+
"""
|
| 502 |
+
|
| 503 |
+
# _ScalarMappable exists for compatibility with
|
| 504 |
+
# code written before the introduction of the Colorizer
|
| 505 |
+
# and ColorizingArtist classes.
|
| 506 |
+
|
| 507 |
+
# _ScalarMappable can be depreciated so that ColorizingArtist
|
| 508 |
+
# inherits directly from _ColorizerInterface.
|
| 509 |
+
# in this case, the following changes should occur:
|
| 510 |
+
# __init__() has its functionality moved to ColorizingArtist.
|
| 511 |
+
# set_array(), get_array(), _get_colorizer() and
|
| 512 |
+
# _check_exclusionary_keywords() are moved to ColorizingArtist.
|
| 513 |
+
# changed() can be removed so long as colorbar.Colorbar
|
| 514 |
+
# is changed to connect to the colorizer instead of the
|
| 515 |
+
# ScalarMappable/ColorizingArtist,
|
| 516 |
+
# otherwise changed() can be moved to ColorizingArtist.
|
| 517 |
+
def __init__(self, norm=None, cmap=None, *, colorizer=None, **kwargs):
|
| 518 |
+
"""
|
| 519 |
+
Parameters
|
| 520 |
+
----------
|
| 521 |
+
norm : `.Normalize` (or subclass thereof) or str or None
|
| 522 |
+
The normalizing object which scales data, typically into the
|
| 523 |
+
interval ``[0, 1]``.
|
| 524 |
+
If a `str`, a `.Normalize` subclass is dynamically generated based
|
| 525 |
+
on the scale with the corresponding name.
|
| 526 |
+
If *None*, *norm* defaults to a *colors.Normalize* object which
|
| 527 |
+
initializes its scaling based on the first data processed.
|
| 528 |
+
cmap : str or `~matplotlib.colors.Colormap`
|
| 529 |
+
The colormap used to map normalized data values to RGBA colors.
|
| 530 |
+
"""
|
| 531 |
+
super().__init__(**kwargs)
|
| 532 |
+
self._A = None
|
| 533 |
+
self._colorizer = self._get_colorizer(colorizer=colorizer, norm=norm, cmap=cmap)
|
| 534 |
+
|
| 535 |
+
self.colorbar = None
|
| 536 |
+
self._id_colorizer = self._colorizer.callbacks.connect('changed', self.changed)
|
| 537 |
+
self.callbacks = cbook.CallbackRegistry(signals=["changed"])
|
| 538 |
+
|
| 539 |
+
def set_array(self, A):
|
| 540 |
+
"""
|
| 541 |
+
Set the value array from array-like *A*.
|
| 542 |
+
|
| 543 |
+
Parameters
|
| 544 |
+
----------
|
| 545 |
+
A : array-like or None
|
| 546 |
+
The values that are mapped to colors.
|
| 547 |
+
|
| 548 |
+
The base class `.ScalarMappable` does not make any assumptions on
|
| 549 |
+
the dimensionality and shape of the value array *A*.
|
| 550 |
+
"""
|
| 551 |
+
if A is None:
|
| 552 |
+
self._A = None
|
| 553 |
+
return
|
| 554 |
+
|
| 555 |
+
A = cbook.safe_masked_invalid(A, copy=True)
|
| 556 |
+
if not np.can_cast(A.dtype, float, "same_kind"):
|
| 557 |
+
raise TypeError(f"Image data of dtype {A.dtype} cannot be "
|
| 558 |
+
"converted to float")
|
| 559 |
+
|
| 560 |
+
self._A = A
|
| 561 |
+
if not self.norm.scaled():
|
| 562 |
+
self._colorizer.autoscale_None(A)
|
| 563 |
+
|
| 564 |
+
def get_array(self):
|
| 565 |
+
"""
|
| 566 |
+
Return the array of values, that are mapped to colors.
|
| 567 |
+
|
| 568 |
+
The base class `.ScalarMappable` does not make any assumptions on
|
| 569 |
+
the dimensionality and shape of the array.
|
| 570 |
+
"""
|
| 571 |
+
return self._A
|
| 572 |
+
|
| 573 |
+
def changed(self):
|
| 574 |
+
"""
|
| 575 |
+
Call this whenever the mappable is changed to notify all the
|
| 576 |
+
callbackSM listeners to the 'changed' signal.
|
| 577 |
+
"""
|
| 578 |
+
self.callbacks.process('changed', self)
|
| 579 |
+
self.stale = True
|
| 580 |
+
|
| 581 |
+
@staticmethod
|
| 582 |
+
def _check_exclusionary_keywords(colorizer, **kwargs):
|
| 583 |
+
"""
|
| 584 |
+
Raises a ValueError if any kwarg is not None while colorizer is not None
|
| 585 |
+
"""
|
| 586 |
+
if colorizer is not None:
|
| 587 |
+
if any([val is not None for val in kwargs.values()]):
|
| 588 |
+
raise ValueError("The `colorizer` keyword cannot be used simultaneously"
|
| 589 |
+
" with any of the following keywords: "
|
| 590 |
+
+ ", ".join(f'`{key}`' for key in kwargs.keys()))
|
| 591 |
+
|
| 592 |
+
@staticmethod
|
| 593 |
+
def _get_colorizer(cmap, norm, colorizer):
|
| 594 |
+
if isinstance(colorizer, Colorizer):
|
| 595 |
+
_ScalarMappable._check_exclusionary_keywords(
|
| 596 |
+
Colorizer, cmap=cmap, norm=norm
|
| 597 |
+
)
|
| 598 |
+
return colorizer
|
| 599 |
+
return Colorizer(cmap, norm)
|
| 600 |
+
|
| 601 |
+
# The docstrings here must be generic enough to apply to all relevant methods.
|
| 602 |
+
mpl._docstring.interpd.register(
|
| 603 |
+
cmap_doc="""\
|
| 604 |
+
cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
|
| 605 |
+
The Colormap instance or registered colormap name used to map scalar data
|
| 606 |
+
to colors.""",
|
| 607 |
+
norm_doc="""\
|
| 608 |
+
norm : str or `~matplotlib.colors.Normalize`, optional
|
| 609 |
+
The normalization method used to scale scalar data to the [0, 1] range
|
| 610 |
+
before mapping to colors using *cmap*. By default, a linear scaling is
|
| 611 |
+
used, mapping the lowest value to 0 and the highest to 1.
|
| 612 |
+
|
| 613 |
+
If given, this can be one of the following:
|
| 614 |
+
|
| 615 |
+
- An instance of `.Normalize` or one of its subclasses
|
| 616 |
+
(see :ref:`colormapnorms`).
|
| 617 |
+
- A scale name, i.e. one of "linear", "log", "symlog", "logit", etc. For a
|
| 618 |
+
list of available scales, call `matplotlib.scale.get_scale_names()`.
|
| 619 |
+
In that case, a suitable `.Normalize` subclass is dynamically generated
|
| 620 |
+
and instantiated.""",
|
| 621 |
+
vmin_vmax_doc="""\
|
| 622 |
+
vmin, vmax : float, optional
|
| 623 |
+
When using scalar data and no explicit *norm*, *vmin* and *vmax* define
|
| 624 |
+
the data range that the colormap covers. By default, the colormap covers
|
| 625 |
+
the complete value range of the supplied data. It is an error to use
|
| 626 |
+
*vmin*/*vmax* when a *norm* instance is given (but using a `str` *norm*
|
| 627 |
+
name together with *vmin*/*vmax* is acceptable).""",
|
| 628 |
+
)
|
| 629 |
+
|
| 630 |
+
|
| 631 |
+
class ColorizingArtist(_ScalarMappable, artist.Artist):
|
| 632 |
+
"""
|
| 633 |
+
Base class for artists that make map data to color using a `.colorizer.Colorizer`.
|
| 634 |
+
|
| 635 |
+
The `.colorizer.Colorizer` applies data normalization before
|
| 636 |
+
returning RGBA colors from a `~matplotlib.colors.Colormap`.
|
| 637 |
+
|
| 638 |
+
"""
|
| 639 |
+
def __init__(self, colorizer, **kwargs):
|
| 640 |
+
"""
|
| 641 |
+
Parameters
|
| 642 |
+
----------
|
| 643 |
+
colorizer : `.colorizer.Colorizer`
|
| 644 |
+
"""
|
| 645 |
+
_api.check_isinstance(Colorizer, colorizer=colorizer)
|
| 646 |
+
super().__init__(colorizer=colorizer, **kwargs)
|
| 647 |
+
|
| 648 |
+
@property
|
| 649 |
+
def colorizer(self):
|
| 650 |
+
return self._colorizer
|
| 651 |
+
|
| 652 |
+
@colorizer.setter
|
| 653 |
+
def colorizer(self, cl):
|
| 654 |
+
_api.check_isinstance(Colorizer, colorizer=cl)
|
| 655 |
+
self._colorizer.callbacks.disconnect(self._id_colorizer)
|
| 656 |
+
self._colorizer = cl
|
| 657 |
+
self._id_colorizer = cl.callbacks.connect('changed', self.changed)
|
| 658 |
+
|
| 659 |
+
def _set_colorizer_check_keywords(self, colorizer, **kwargs):
|
| 660 |
+
"""
|
| 661 |
+
Raises a ValueError if any kwarg is not None while colorizer is not None.
|
| 662 |
+
"""
|
| 663 |
+
self._check_exclusionary_keywords(colorizer, **kwargs)
|
| 664 |
+
self.colorizer = colorizer
|
| 665 |
+
|
| 666 |
+
|
| 667 |
+
def _auto_norm_from_scale(scale_cls):
|
| 668 |
+
"""
|
| 669 |
+
Automatically generate a norm class from *scale_cls*.
|
| 670 |
+
|
| 671 |
+
This differs from `.colors.make_norm_from_scale` in the following points:
|
| 672 |
+
|
| 673 |
+
- This function is not a class decorator, but directly returns a norm class
|
| 674 |
+
(as if decorating `.Normalize`).
|
| 675 |
+
- The scale is automatically constructed with ``nonpositive="mask"``, if it
|
| 676 |
+
supports such a parameter, to work around the difference in defaults
|
| 677 |
+
between standard scales (which use "clip") and norms (which use "mask").
|
| 678 |
+
|
| 679 |
+
Note that ``make_norm_from_scale`` caches the generated norm classes
|
| 680 |
+
(not the instances) and reuses them for later calls. For example,
|
| 681 |
+
``type(_auto_norm_from_scale("log")) == LogNorm``.
|
| 682 |
+
"""
|
| 683 |
+
# Actually try to construct an instance, to verify whether
|
| 684 |
+
# ``nonpositive="mask"`` is supported.
|
| 685 |
+
try:
|
| 686 |
+
norm = colors.make_norm_from_scale(
|
| 687 |
+
functools.partial(scale_cls, nonpositive="mask"))(
|
| 688 |
+
colors.Normalize)()
|
| 689 |
+
except TypeError:
|
| 690 |
+
norm = colors.make_norm_from_scale(scale_cls)(
|
| 691 |
+
colors.Normalize)()
|
| 692 |
+
return type(norm)
|
llava_video/lib/python3.10/site-packages/matplotlib/colorizer.pyi
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from matplotlib import cbook, colorbar, colors, artist
|
| 2 |
+
|
| 3 |
+
from typing import overload
|
| 4 |
+
import numpy as np
|
| 5 |
+
from numpy.typing import ArrayLike
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class Colorizer:
|
| 9 |
+
colorbar: colorbar.Colorbar | None
|
| 10 |
+
callbacks: cbook.CallbackRegistry
|
| 11 |
+
def __init__(
|
| 12 |
+
self,
|
| 13 |
+
cmap: str | colors.Colormap | None = ...,
|
| 14 |
+
norm: str | colors.Normalize | None = ...,
|
| 15 |
+
) -> None: ...
|
| 16 |
+
@property
|
| 17 |
+
def norm(self) -> colors.Normalize: ...
|
| 18 |
+
@norm.setter
|
| 19 |
+
def norm(self, norm: colors.Normalize | str | None) -> None: ...
|
| 20 |
+
def to_rgba(
|
| 21 |
+
self,
|
| 22 |
+
x: np.ndarray,
|
| 23 |
+
alpha: float | ArrayLike | None = ...,
|
| 24 |
+
bytes: bool = ...,
|
| 25 |
+
norm: bool = ...,
|
| 26 |
+
) -> np.ndarray: ...
|
| 27 |
+
def autoscale(self, A: ArrayLike) -> None: ...
|
| 28 |
+
def autoscale_None(self, A: ArrayLike) -> None: ...
|
| 29 |
+
@property
|
| 30 |
+
def cmap(self) -> colors.Colormap: ...
|
| 31 |
+
@cmap.setter
|
| 32 |
+
def cmap(self, cmap: colors.Colormap | str | None) -> None: ...
|
| 33 |
+
def get_clim(self) -> tuple[float, float]: ...
|
| 34 |
+
def set_clim(self, vmin: float | tuple[float, float] | None = ..., vmax: float | None = ...) -> None: ...
|
| 35 |
+
def changed(self) -> None: ...
|
| 36 |
+
@property
|
| 37 |
+
def vmin(self) -> float | None: ...
|
| 38 |
+
@vmin.setter
|
| 39 |
+
def vmin(self, value: float | None) -> None: ...
|
| 40 |
+
@property
|
| 41 |
+
def vmax(self) -> float | None: ...
|
| 42 |
+
@vmax.setter
|
| 43 |
+
def vmax(self, value: float | None) -> None: ...
|
| 44 |
+
@property
|
| 45 |
+
def clip(self) -> bool: ...
|
| 46 |
+
@clip.setter
|
| 47 |
+
def clip(self, value: bool) -> None: ...
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
class _ColorizerInterface:
|
| 51 |
+
cmap: colors.Colormap
|
| 52 |
+
colorbar: colorbar.Colorbar | None
|
| 53 |
+
callbacks: cbook.CallbackRegistry
|
| 54 |
+
def to_rgba(
|
| 55 |
+
self,
|
| 56 |
+
x: np.ndarray,
|
| 57 |
+
alpha: float | ArrayLike | None = ...,
|
| 58 |
+
bytes: bool = ...,
|
| 59 |
+
norm: bool = ...,
|
| 60 |
+
) -> np.ndarray: ...
|
| 61 |
+
def get_clim(self) -> tuple[float, float]: ...
|
| 62 |
+
def set_clim(self, vmin: float | tuple[float, float] | None = ..., vmax: float | None = ...) -> None: ...
|
| 63 |
+
def get_alpha(self) -> float | None: ...
|
| 64 |
+
def get_cmap(self) -> colors.Colormap: ...
|
| 65 |
+
def set_cmap(self, cmap: str | colors.Colormap) -> None: ...
|
| 66 |
+
@property
|
| 67 |
+
def norm(self) -> colors.Normalize: ...
|
| 68 |
+
@norm.setter
|
| 69 |
+
def norm(self, norm: colors.Normalize | str | None) -> None: ...
|
| 70 |
+
def set_norm(self, norm: colors.Normalize | str | None) -> None: ...
|
| 71 |
+
def autoscale(self) -> None: ...
|
| 72 |
+
def autoscale_None(self) -> None: ...
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
class _ScalarMappable(_ColorizerInterface):
|
| 76 |
+
def __init__(
|
| 77 |
+
self,
|
| 78 |
+
norm: colors.Normalize | None = ...,
|
| 79 |
+
cmap: str | colors.Colormap | None = ...,
|
| 80 |
+
*,
|
| 81 |
+
colorizer: Colorizer | None = ...,
|
| 82 |
+
**kwargs
|
| 83 |
+
) -> None: ...
|
| 84 |
+
def set_array(self, A: ArrayLike | None) -> None: ...
|
| 85 |
+
def get_array(self) -> np.ndarray | None: ...
|
| 86 |
+
def changed(self) -> None: ...
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
class ColorizingArtist(_ScalarMappable, artist.Artist):
|
| 90 |
+
callbacks: cbook.CallbackRegistry
|
| 91 |
+
def __init__(
|
| 92 |
+
self,
|
| 93 |
+
colorizer: Colorizer,
|
| 94 |
+
**kwargs
|
| 95 |
+
) -> None: ...
|
| 96 |
+
def set_array(self, A: ArrayLike | None) -> None: ...
|
| 97 |
+
def get_array(self) -> np.ndarray | None: ...
|
| 98 |
+
def changed(self) -> None: ...
|
| 99 |
+
@property
|
| 100 |
+
def colorizer(self) -> Colorizer: ...
|
| 101 |
+
@colorizer.setter
|
| 102 |
+
def colorizer(self, cl: Colorizer) -> None: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/colors.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llava_video/lib/python3.10/site-packages/matplotlib/colors.pyi
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
|
| 2 |
+
from matplotlib import cbook, scale
|
| 3 |
+
import re
|
| 4 |
+
|
| 5 |
+
from typing import Any, Literal, overload
|
| 6 |
+
from .typing import ColorType
|
| 7 |
+
|
| 8 |
+
import numpy as np
|
| 9 |
+
from numpy.typing import ArrayLike
|
| 10 |
+
|
| 11 |
+
# Explicitly export colors dictionaries which are imported in the impl
|
| 12 |
+
BASE_COLORS: dict[str, ColorType]
|
| 13 |
+
CSS4_COLORS: dict[str, ColorType]
|
| 14 |
+
TABLEAU_COLORS: dict[str, ColorType]
|
| 15 |
+
XKCD_COLORS: dict[str, ColorType]
|
| 16 |
+
|
| 17 |
+
class _ColorMapping(dict[str, ColorType]):
|
| 18 |
+
cache: dict[tuple[ColorType, float | None], tuple[float, float, float, float]]
|
| 19 |
+
def __init__(self, mapping) -> None: ...
|
| 20 |
+
def __setitem__(self, key, value) -> None: ...
|
| 21 |
+
def __delitem__(self, key) -> None: ...
|
| 22 |
+
|
| 23 |
+
def get_named_colors_mapping() -> _ColorMapping: ...
|
| 24 |
+
|
| 25 |
+
class ColorSequenceRegistry(Mapping):
|
| 26 |
+
def __init__(self) -> None: ...
|
| 27 |
+
def __getitem__(self, item: str) -> list[ColorType]: ...
|
| 28 |
+
def __iter__(self) -> Iterator[str]: ...
|
| 29 |
+
def __len__(self) -> int: ...
|
| 30 |
+
def register(self, name: str, color_list: Iterable[ColorType]) -> None: ...
|
| 31 |
+
def unregister(self, name: str) -> None: ...
|
| 32 |
+
|
| 33 |
+
_color_sequences: ColorSequenceRegistry = ...
|
| 34 |
+
|
| 35 |
+
def is_color_like(c: Any) -> bool: ...
|
| 36 |
+
def same_color(c1: ColorType, c2: ColorType) -> bool: ...
|
| 37 |
+
def to_rgba(
|
| 38 |
+
c: ColorType, alpha: float | None = ...
|
| 39 |
+
) -> tuple[float, float, float, float]: ...
|
| 40 |
+
def to_rgba_array(
|
| 41 |
+
c: ColorType | ArrayLike, alpha: float | ArrayLike | None = ...
|
| 42 |
+
) -> np.ndarray: ...
|
| 43 |
+
def to_rgb(c: ColorType) -> tuple[float, float, float]: ...
|
| 44 |
+
def to_hex(c: ColorType, keep_alpha: bool = ...) -> str: ...
|
| 45 |
+
|
| 46 |
+
cnames: dict[str, ColorType]
|
| 47 |
+
hexColorPattern: re.Pattern
|
| 48 |
+
rgb2hex = to_hex
|
| 49 |
+
hex2color = to_rgb
|
| 50 |
+
|
| 51 |
+
class ColorConverter:
|
| 52 |
+
colors: _ColorMapping
|
| 53 |
+
cache: dict[tuple[ColorType, float | None], tuple[float, float, float, float]]
|
| 54 |
+
@staticmethod
|
| 55 |
+
def to_rgb(c: ColorType) -> tuple[float, float, float]: ...
|
| 56 |
+
@staticmethod
|
| 57 |
+
def to_rgba(
|
| 58 |
+
c: ColorType, alpha: float | None = ...
|
| 59 |
+
) -> tuple[float, float, float, float]: ...
|
| 60 |
+
@staticmethod
|
| 61 |
+
def to_rgba_array(
|
| 62 |
+
c: ColorType | ArrayLike, alpha: float | ArrayLike | None = ...
|
| 63 |
+
) -> np.ndarray: ...
|
| 64 |
+
|
| 65 |
+
colorConverter: ColorConverter
|
| 66 |
+
|
| 67 |
+
class Colormap:
|
| 68 |
+
name: str
|
| 69 |
+
N: int
|
| 70 |
+
colorbar_extend: bool
|
| 71 |
+
def __init__(self, name: str, N: int = ...) -> None: ...
|
| 72 |
+
@overload
|
| 73 |
+
def __call__(
|
| 74 |
+
self, X: Sequence[float] | np.ndarray, alpha: ArrayLike | None = ..., bytes: bool = ...
|
| 75 |
+
) -> np.ndarray: ...
|
| 76 |
+
@overload
|
| 77 |
+
def __call__(
|
| 78 |
+
self, X: float, alpha: float | None = ..., bytes: bool = ...
|
| 79 |
+
) -> tuple[float, float, float, float]: ...
|
| 80 |
+
@overload
|
| 81 |
+
def __call__(
|
| 82 |
+
self, X: ArrayLike, alpha: ArrayLike | None = ..., bytes: bool = ...
|
| 83 |
+
) -> tuple[float, float, float, float] | np.ndarray: ...
|
| 84 |
+
def __copy__(self) -> Colormap: ...
|
| 85 |
+
def __eq__(self, other: object) -> bool: ...
|
| 86 |
+
def get_bad(self) -> np.ndarray: ...
|
| 87 |
+
def set_bad(self, color: ColorType = ..., alpha: float | None = ...) -> None: ...
|
| 88 |
+
def get_under(self) -> np.ndarray: ...
|
| 89 |
+
def set_under(self, color: ColorType = ..., alpha: float | None = ...) -> None: ...
|
| 90 |
+
def get_over(self) -> np.ndarray: ...
|
| 91 |
+
def set_over(self, color: ColorType = ..., alpha: float | None = ...) -> None: ...
|
| 92 |
+
def set_extremes(
|
| 93 |
+
self,
|
| 94 |
+
*,
|
| 95 |
+
bad: ColorType | None = ...,
|
| 96 |
+
under: ColorType | None = ...,
|
| 97 |
+
over: ColorType | None = ...
|
| 98 |
+
) -> None: ...
|
| 99 |
+
def with_extremes(
|
| 100 |
+
self,
|
| 101 |
+
*,
|
| 102 |
+
bad: ColorType | None = ...,
|
| 103 |
+
under: ColorType | None = ...,
|
| 104 |
+
over: ColorType | None = ...
|
| 105 |
+
) -> Colormap: ...
|
| 106 |
+
def is_gray(self) -> bool: ...
|
| 107 |
+
def resampled(self, lutsize: int) -> Colormap: ...
|
| 108 |
+
def reversed(self, name: str | None = ...) -> Colormap: ...
|
| 109 |
+
def _repr_html_(self) -> str: ...
|
| 110 |
+
def _repr_png_(self) -> bytes: ...
|
| 111 |
+
def copy(self) -> Colormap: ...
|
| 112 |
+
|
| 113 |
+
class LinearSegmentedColormap(Colormap):
|
| 114 |
+
monochrome: bool
|
| 115 |
+
def __init__(
|
| 116 |
+
self,
|
| 117 |
+
name: str,
|
| 118 |
+
segmentdata: dict[
|
| 119 |
+
Literal["red", "green", "blue", "alpha"], Sequence[tuple[float, ...]]
|
| 120 |
+
],
|
| 121 |
+
N: int = ...,
|
| 122 |
+
gamma: float = ...,
|
| 123 |
+
) -> None: ...
|
| 124 |
+
def set_gamma(self, gamma: float) -> None: ...
|
| 125 |
+
@staticmethod
|
| 126 |
+
def from_list(
|
| 127 |
+
name: str, colors: ArrayLike | Sequence[tuple[float, ColorType]], N: int = ..., gamma: float = ...
|
| 128 |
+
) -> LinearSegmentedColormap: ...
|
| 129 |
+
def resampled(self, lutsize: int) -> LinearSegmentedColormap: ...
|
| 130 |
+
def reversed(self, name: str | None = ...) -> LinearSegmentedColormap: ...
|
| 131 |
+
|
| 132 |
+
class ListedColormap(Colormap):
|
| 133 |
+
monochrome: bool
|
| 134 |
+
colors: ArrayLike | ColorType
|
| 135 |
+
def __init__(
|
| 136 |
+
self, colors: ArrayLike | ColorType, name: str = ..., N: int | None = ...
|
| 137 |
+
) -> None: ...
|
| 138 |
+
def resampled(self, lutsize: int) -> ListedColormap: ...
|
| 139 |
+
def reversed(self, name: str | None = ...) -> ListedColormap: ...
|
| 140 |
+
|
| 141 |
+
class MultivarColormap:
|
| 142 |
+
name: str
|
| 143 |
+
n_variates: int
|
| 144 |
+
def __init__(self, colormaps: list[Colormap], combination_mode: Literal['sRGB_add', 'sRGB_sub'], name: str = ...) -> None: ...
|
| 145 |
+
@overload
|
| 146 |
+
def __call__(
|
| 147 |
+
self, X: Sequence[Sequence[float]] | np.ndarray, alpha: ArrayLike | None = ..., bytes: bool = ..., clip: bool = ...
|
| 148 |
+
) -> np.ndarray: ...
|
| 149 |
+
@overload
|
| 150 |
+
def __call__(
|
| 151 |
+
self, X: Sequence[float], alpha: float | None = ..., bytes: bool = ..., clip: bool = ...
|
| 152 |
+
) -> tuple[float, float, float, float]: ...
|
| 153 |
+
@overload
|
| 154 |
+
def __call__(
|
| 155 |
+
self, X: ArrayLike, alpha: ArrayLike | None = ..., bytes: bool = ..., clip: bool = ...
|
| 156 |
+
) -> tuple[float, float, float, float] | np.ndarray: ...
|
| 157 |
+
def copy(self) -> MultivarColormap: ...
|
| 158 |
+
def __copy__(self) -> MultivarColormap: ...
|
| 159 |
+
def __eq__(self, other: Any) -> bool: ...
|
| 160 |
+
def __getitem__(self, item: int) -> Colormap: ...
|
| 161 |
+
def __iter__(self) -> Iterator[Colormap]: ...
|
| 162 |
+
def __len__(self) -> int: ...
|
| 163 |
+
def get_bad(self) -> np.ndarray: ...
|
| 164 |
+
def resampled(self, lutshape: Sequence[int | None]) -> MultivarColormap: ...
|
| 165 |
+
def with_extremes(
|
| 166 |
+
self,
|
| 167 |
+
*,
|
| 168 |
+
bad: ColorType | None = ...,
|
| 169 |
+
under: Sequence[ColorType] | None = ...,
|
| 170 |
+
over: Sequence[ColorType] | None = ...
|
| 171 |
+
) -> MultivarColormap: ...
|
| 172 |
+
@property
|
| 173 |
+
def combination_mode(self) -> str: ...
|
| 174 |
+
def _repr_html_(self) -> str: ...
|
| 175 |
+
def _repr_png_(self) -> bytes: ...
|
| 176 |
+
|
| 177 |
+
class BivarColormap:
|
| 178 |
+
name: str
|
| 179 |
+
N: int
|
| 180 |
+
M: int
|
| 181 |
+
n_variates: int
|
| 182 |
+
def __init__(
|
| 183 |
+
self, N: int = ..., M: int | None = ..., shape: Literal['square', 'circle', 'ignore', 'circleignore'] = ...,
|
| 184 |
+
origin: Sequence[float] = ..., name: str = ...
|
| 185 |
+
) -> None: ...
|
| 186 |
+
@overload
|
| 187 |
+
def __call__(
|
| 188 |
+
self, X: Sequence[Sequence[float]] | np.ndarray, alpha: ArrayLike | None = ..., bytes: bool = ...
|
| 189 |
+
) -> np.ndarray: ...
|
| 190 |
+
@overload
|
| 191 |
+
def __call__(
|
| 192 |
+
self, X: Sequence[float], alpha: float | None = ..., bytes: bool = ...
|
| 193 |
+
) -> tuple[float, float, float, float]: ...
|
| 194 |
+
@overload
|
| 195 |
+
def __call__(
|
| 196 |
+
self, X: ArrayLike, alpha: ArrayLike | None = ..., bytes: bool = ...
|
| 197 |
+
) -> tuple[float, float, float, float] | np.ndarray: ...
|
| 198 |
+
@property
|
| 199 |
+
def lut(self) -> np.ndarray: ...
|
| 200 |
+
@property
|
| 201 |
+
def shape(self) -> str: ...
|
| 202 |
+
@property
|
| 203 |
+
def origin(self) -> tuple[float, float]: ...
|
| 204 |
+
def copy(self) -> BivarColormap: ...
|
| 205 |
+
def __copy__(self) -> BivarColormap: ...
|
| 206 |
+
def __getitem__(self, item: int) -> Colormap: ...
|
| 207 |
+
def __eq__(self, other: Any) -> bool: ...
|
| 208 |
+
def get_bad(self) -> np.ndarray: ...
|
| 209 |
+
def get_outside(self) -> np.ndarray: ...
|
| 210 |
+
def resampled(self, lutshape: Sequence[int | None], transposed: bool = ...) -> BivarColormap: ...
|
| 211 |
+
def transposed(self) -> BivarColormap: ...
|
| 212 |
+
def reversed(self, axis_0: bool = ..., axis_1: bool = ...) -> BivarColormap: ...
|
| 213 |
+
def with_extremes(
|
| 214 |
+
self,
|
| 215 |
+
*,
|
| 216 |
+
bad: ColorType | None = ...,
|
| 217 |
+
outside: ColorType | None = ...,
|
| 218 |
+
shape: str | None = ...,
|
| 219 |
+
origin: None | Sequence[float] = ...,
|
| 220 |
+
) -> MultivarColormap: ...
|
| 221 |
+
def _repr_html_(self) -> str: ...
|
| 222 |
+
def _repr_png_(self) -> bytes: ...
|
| 223 |
+
|
| 224 |
+
class SegmentedBivarColormap(BivarColormap):
|
| 225 |
+
def __init__(
|
| 226 |
+
self, patch: np.ndarray, N: int = ..., shape: Literal['square', 'circle', 'ignore', 'circleignore'] = ...,
|
| 227 |
+
origin: Sequence[float] = ..., name: str = ...
|
| 228 |
+
) -> None: ...
|
| 229 |
+
|
| 230 |
+
class BivarColormapFromImage(BivarColormap):
|
| 231 |
+
def __init__(
|
| 232 |
+
self, lut: np.ndarray, shape: Literal['square', 'circle', 'ignore', 'circleignore'] = ...,
|
| 233 |
+
origin: Sequence[float] = ..., name: str = ...
|
| 234 |
+
) -> None: ...
|
| 235 |
+
|
| 236 |
+
class Normalize:
|
| 237 |
+
callbacks: cbook.CallbackRegistry
|
| 238 |
+
def __init__(
|
| 239 |
+
self, vmin: float | None = ..., vmax: float | None = ..., clip: bool = ...
|
| 240 |
+
) -> None: ...
|
| 241 |
+
@property
|
| 242 |
+
def vmin(self) -> float | None: ...
|
| 243 |
+
@vmin.setter
|
| 244 |
+
def vmin(self, value: float | None) -> None: ...
|
| 245 |
+
@property
|
| 246 |
+
def vmax(self) -> float | None: ...
|
| 247 |
+
@vmax.setter
|
| 248 |
+
def vmax(self, value: float | None) -> None: ...
|
| 249 |
+
@property
|
| 250 |
+
def clip(self) -> bool: ...
|
| 251 |
+
@clip.setter
|
| 252 |
+
def clip(self, value: bool) -> None: ...
|
| 253 |
+
@staticmethod
|
| 254 |
+
def process_value(value: ArrayLike) -> tuple[np.ma.MaskedArray, bool]: ...
|
| 255 |
+
@overload
|
| 256 |
+
def __call__(self, value: float, clip: bool | None = ...) -> float: ...
|
| 257 |
+
@overload
|
| 258 |
+
def __call__(self, value: np.ndarray, clip: bool | None = ...) -> np.ma.MaskedArray: ...
|
| 259 |
+
@overload
|
| 260 |
+
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
|
| 261 |
+
@overload
|
| 262 |
+
def inverse(self, value: float) -> float: ...
|
| 263 |
+
@overload
|
| 264 |
+
def inverse(self, value: np.ndarray) -> np.ma.MaskedArray: ...
|
| 265 |
+
@overload
|
| 266 |
+
def inverse(self, value: ArrayLike) -> ArrayLike: ...
|
| 267 |
+
def autoscale(self, A: ArrayLike) -> None: ...
|
| 268 |
+
def autoscale_None(self, A: ArrayLike) -> None: ...
|
| 269 |
+
def scaled(self) -> bool: ...
|
| 270 |
+
|
| 271 |
+
class TwoSlopeNorm(Normalize):
|
| 272 |
+
def __init__(
|
| 273 |
+
self, vcenter: float, vmin: float | None = ..., vmax: float | None = ...
|
| 274 |
+
) -> None: ...
|
| 275 |
+
@property
|
| 276 |
+
def vcenter(self) -> float: ...
|
| 277 |
+
@vcenter.setter
|
| 278 |
+
def vcenter(self, value: float) -> None: ...
|
| 279 |
+
def autoscale_None(self, A: ArrayLike) -> None: ...
|
| 280 |
+
|
| 281 |
+
class CenteredNorm(Normalize):
|
| 282 |
+
def __init__(
|
| 283 |
+
self, vcenter: float = ..., halfrange: float | None = ..., clip: bool = ...
|
| 284 |
+
) -> None: ...
|
| 285 |
+
@property
|
| 286 |
+
def vcenter(self) -> float: ...
|
| 287 |
+
@vcenter.setter
|
| 288 |
+
def vcenter(self, vcenter: float) -> None: ...
|
| 289 |
+
@property
|
| 290 |
+
def halfrange(self) -> float: ...
|
| 291 |
+
@halfrange.setter
|
| 292 |
+
def halfrange(self, halfrange: float) -> None: ...
|
| 293 |
+
|
| 294 |
+
@overload
|
| 295 |
+
def make_norm_from_scale(
|
| 296 |
+
scale_cls: type[scale.ScaleBase],
|
| 297 |
+
base_norm_cls: type[Normalize],
|
| 298 |
+
*,
|
| 299 |
+
init: Callable | None = ...
|
| 300 |
+
) -> type[Normalize]: ...
|
| 301 |
+
@overload
|
| 302 |
+
def make_norm_from_scale(
|
| 303 |
+
scale_cls: type[scale.ScaleBase],
|
| 304 |
+
base_norm_cls: None = ...,
|
| 305 |
+
*,
|
| 306 |
+
init: Callable | None = ...
|
| 307 |
+
) -> Callable[[type[Normalize]], type[Normalize]]: ...
|
| 308 |
+
|
| 309 |
+
class FuncNorm(Normalize):
|
| 310 |
+
def __init__(
|
| 311 |
+
self,
|
| 312 |
+
functions: tuple[Callable, Callable],
|
| 313 |
+
vmin: float | None = ...,
|
| 314 |
+
vmax: float | None = ...,
|
| 315 |
+
clip: bool = ...,
|
| 316 |
+
) -> None: ...
|
| 317 |
+
class LogNorm(Normalize): ...
|
| 318 |
+
|
| 319 |
+
class SymLogNorm(Normalize):
|
| 320 |
+
def __init__(
|
| 321 |
+
self,
|
| 322 |
+
linthresh: float,
|
| 323 |
+
linscale: float = ...,
|
| 324 |
+
vmin: float | None = ...,
|
| 325 |
+
vmax: float | None = ...,
|
| 326 |
+
clip: bool = ...,
|
| 327 |
+
*,
|
| 328 |
+
base: float = ...,
|
| 329 |
+
) -> None: ...
|
| 330 |
+
@property
|
| 331 |
+
def linthresh(self) -> float: ...
|
| 332 |
+
@linthresh.setter
|
| 333 |
+
def linthresh(self, value: float) -> None: ...
|
| 334 |
+
|
| 335 |
+
class AsinhNorm(Normalize):
|
| 336 |
+
def __init__(
|
| 337 |
+
self,
|
| 338 |
+
linear_width: float = ...,
|
| 339 |
+
vmin: float | None = ...,
|
| 340 |
+
vmax: float | None = ...,
|
| 341 |
+
clip: bool = ...,
|
| 342 |
+
) -> None: ...
|
| 343 |
+
@property
|
| 344 |
+
def linear_width(self) -> float: ...
|
| 345 |
+
@linear_width.setter
|
| 346 |
+
def linear_width(self, value: float) -> None: ...
|
| 347 |
+
|
| 348 |
+
class PowerNorm(Normalize):
|
| 349 |
+
gamma: float
|
| 350 |
+
def __init__(
|
| 351 |
+
self,
|
| 352 |
+
gamma: float,
|
| 353 |
+
vmin: float | None = ...,
|
| 354 |
+
vmax: float | None = ...,
|
| 355 |
+
clip: bool = ...,
|
| 356 |
+
) -> None: ...
|
| 357 |
+
|
| 358 |
+
class BoundaryNorm(Normalize):
|
| 359 |
+
boundaries: np.ndarray
|
| 360 |
+
N: int
|
| 361 |
+
Ncmap: int
|
| 362 |
+
extend: Literal["neither", "both", "min", "max"]
|
| 363 |
+
def __init__(
|
| 364 |
+
self,
|
| 365 |
+
boundaries: ArrayLike,
|
| 366 |
+
ncolors: int,
|
| 367 |
+
clip: bool = ...,
|
| 368 |
+
*,
|
| 369 |
+
extend: Literal["neither", "both", "min", "max"] = ...
|
| 370 |
+
) -> None: ...
|
| 371 |
+
|
| 372 |
+
class NoNorm(Normalize): ...
|
| 373 |
+
|
| 374 |
+
def rgb_to_hsv(arr: ArrayLike) -> np.ndarray: ...
|
| 375 |
+
def hsv_to_rgb(hsv: ArrayLike) -> np.ndarray: ...
|
| 376 |
+
|
| 377 |
+
class LightSource:
|
| 378 |
+
azdeg: float
|
| 379 |
+
altdeg: float
|
| 380 |
+
hsv_min_val: float
|
| 381 |
+
hsv_max_val: float
|
| 382 |
+
hsv_min_sat: float
|
| 383 |
+
hsv_max_sat: float
|
| 384 |
+
def __init__(
|
| 385 |
+
self,
|
| 386 |
+
azdeg: float = ...,
|
| 387 |
+
altdeg: float = ...,
|
| 388 |
+
hsv_min_val: float = ...,
|
| 389 |
+
hsv_max_val: float = ...,
|
| 390 |
+
hsv_min_sat: float = ...,
|
| 391 |
+
hsv_max_sat: float = ...,
|
| 392 |
+
) -> None: ...
|
| 393 |
+
@property
|
| 394 |
+
def direction(self) -> np.ndarray: ...
|
| 395 |
+
def hillshade(
|
| 396 |
+
self,
|
| 397 |
+
elevation: ArrayLike,
|
| 398 |
+
vert_exag: float = ...,
|
| 399 |
+
dx: float = ...,
|
| 400 |
+
dy: float = ...,
|
| 401 |
+
fraction: float = ...,
|
| 402 |
+
) -> np.ndarray: ...
|
| 403 |
+
def shade_normals(
|
| 404 |
+
self, normals: np.ndarray, fraction: float = ...
|
| 405 |
+
) -> np.ndarray: ...
|
| 406 |
+
def shade(
|
| 407 |
+
self,
|
| 408 |
+
data: ArrayLike,
|
| 409 |
+
cmap: Colormap,
|
| 410 |
+
norm: Normalize | None = ...,
|
| 411 |
+
blend_mode: Literal["hsv", "overlay", "soft"] | Callable = ...,
|
| 412 |
+
vmin: float | None = ...,
|
| 413 |
+
vmax: float | None = ...,
|
| 414 |
+
vert_exag: float = ...,
|
| 415 |
+
dx: float = ...,
|
| 416 |
+
dy: float = ...,
|
| 417 |
+
fraction: float = ...,
|
| 418 |
+
**kwargs
|
| 419 |
+
) -> np.ndarray: ...
|
| 420 |
+
def shade_rgb(
|
| 421 |
+
self,
|
| 422 |
+
rgb: ArrayLike,
|
| 423 |
+
elevation: ArrayLike,
|
| 424 |
+
fraction: float = ...,
|
| 425 |
+
blend_mode: Literal["hsv", "overlay", "soft"] | Callable = ...,
|
| 426 |
+
vert_exag: float = ...,
|
| 427 |
+
dx: float = ...,
|
| 428 |
+
dy: float = ...,
|
| 429 |
+
**kwargs
|
| 430 |
+
) -> np.ndarray: ...
|
| 431 |
+
def blend_hsv(
|
| 432 |
+
self,
|
| 433 |
+
rgb: ArrayLike,
|
| 434 |
+
intensity: ArrayLike,
|
| 435 |
+
hsv_max_sat: float | None = ...,
|
| 436 |
+
hsv_max_val: float | None = ...,
|
| 437 |
+
hsv_min_val: float | None = ...,
|
| 438 |
+
hsv_min_sat: float | None = ...,
|
| 439 |
+
) -> ArrayLike: ...
|
| 440 |
+
def blend_soft_light(
|
| 441 |
+
self, rgb: np.ndarray, intensity: np.ndarray
|
| 442 |
+
) -> np.ndarray: ...
|
| 443 |
+
def blend_overlay(self, rgb: np.ndarray, intensity: np.ndarray) -> np.ndarray: ...
|
| 444 |
+
|
| 445 |
+
def from_levels_and_colors(
|
| 446 |
+
levels: Sequence[float],
|
| 447 |
+
colors: Sequence[ColorType],
|
| 448 |
+
extend: Literal["neither", "min", "max", "both"] = ...,
|
| 449 |
+
) -> tuple[ListedColormap, BoundaryNorm]: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/container.py
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from matplotlib import cbook
|
| 2 |
+
from matplotlib.artist import Artist
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class Container(tuple):
|
| 6 |
+
"""
|
| 7 |
+
Base class for containers.
|
| 8 |
+
|
| 9 |
+
Containers are classes that collect semantically related Artists such as
|
| 10 |
+
the bars of a bar plot.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
def __repr__(self):
|
| 14 |
+
return f"<{type(self).__name__} object of {len(self)} artists>"
|
| 15 |
+
|
| 16 |
+
def __new__(cls, *args, **kwargs):
|
| 17 |
+
return tuple.__new__(cls, args[0])
|
| 18 |
+
|
| 19 |
+
def __init__(self, kl, label=None):
|
| 20 |
+
self._callbacks = cbook.CallbackRegistry(signals=["pchanged"])
|
| 21 |
+
self._remove_method = None
|
| 22 |
+
self._label = str(label) if label is not None else None
|
| 23 |
+
|
| 24 |
+
def remove(self):
|
| 25 |
+
for c in cbook.flatten(
|
| 26 |
+
self, scalarp=lambda x: isinstance(x, Artist)):
|
| 27 |
+
if c is not None:
|
| 28 |
+
c.remove()
|
| 29 |
+
if self._remove_method:
|
| 30 |
+
self._remove_method(self)
|
| 31 |
+
|
| 32 |
+
def get_children(self):
|
| 33 |
+
return [child for child in cbook.flatten(self) if child is not None]
|
| 34 |
+
|
| 35 |
+
get_label = Artist.get_label
|
| 36 |
+
set_label = Artist.set_label
|
| 37 |
+
add_callback = Artist.add_callback
|
| 38 |
+
remove_callback = Artist.remove_callback
|
| 39 |
+
pchanged = Artist.pchanged
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class BarContainer(Container):
|
| 43 |
+
"""
|
| 44 |
+
Container for the artists of bar plots (e.g. created by `.Axes.bar`).
|
| 45 |
+
|
| 46 |
+
The container can be treated as a tuple of the *patches* themselves.
|
| 47 |
+
Additionally, you can access these and further parameters by the
|
| 48 |
+
attributes.
|
| 49 |
+
|
| 50 |
+
Attributes
|
| 51 |
+
----------
|
| 52 |
+
patches : list of :class:`~matplotlib.patches.Rectangle`
|
| 53 |
+
The artists of the bars.
|
| 54 |
+
|
| 55 |
+
errorbar : None or :class:`~matplotlib.container.ErrorbarContainer`
|
| 56 |
+
A container for the error bar artists if error bars are present.
|
| 57 |
+
*None* otherwise.
|
| 58 |
+
|
| 59 |
+
datavalues : None or array-like
|
| 60 |
+
The underlying data values corresponding to the bars.
|
| 61 |
+
|
| 62 |
+
orientation : {'vertical', 'horizontal'}, default: None
|
| 63 |
+
If 'vertical', the bars are assumed to be vertical.
|
| 64 |
+
If 'horizontal', the bars are assumed to be horizontal.
|
| 65 |
+
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
def __init__(self, patches, errorbar=None, *, datavalues=None,
|
| 69 |
+
orientation=None, **kwargs):
|
| 70 |
+
self.patches = patches
|
| 71 |
+
self.errorbar = errorbar
|
| 72 |
+
self.datavalues = datavalues
|
| 73 |
+
self.orientation = orientation
|
| 74 |
+
super().__init__(patches, **kwargs)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class ErrorbarContainer(Container):
|
| 78 |
+
"""
|
| 79 |
+
Container for the artists of error bars (e.g. created by `.Axes.errorbar`).
|
| 80 |
+
|
| 81 |
+
The container can be treated as the *lines* tuple itself.
|
| 82 |
+
Additionally, you can access these and further parameters by the
|
| 83 |
+
attributes.
|
| 84 |
+
|
| 85 |
+
Attributes
|
| 86 |
+
----------
|
| 87 |
+
lines : tuple
|
| 88 |
+
Tuple of ``(data_line, caplines, barlinecols)``.
|
| 89 |
+
|
| 90 |
+
- data_line : A `~matplotlib.lines.Line2D` instance of x, y plot markers
|
| 91 |
+
and/or line.
|
| 92 |
+
- caplines : A tuple of `~matplotlib.lines.Line2D` instances of the error
|
| 93 |
+
bar caps.
|
| 94 |
+
- barlinecols : A tuple of `~matplotlib.collections.LineCollection` with the
|
| 95 |
+
horizontal and vertical error ranges.
|
| 96 |
+
|
| 97 |
+
has_xerr, has_yerr : bool
|
| 98 |
+
``True`` if the errorbar has x/y errors.
|
| 99 |
+
|
| 100 |
+
"""
|
| 101 |
+
|
| 102 |
+
def __init__(self, lines, has_xerr=False, has_yerr=False, **kwargs):
|
| 103 |
+
self.lines = lines
|
| 104 |
+
self.has_xerr = has_xerr
|
| 105 |
+
self.has_yerr = has_yerr
|
| 106 |
+
super().__init__(lines, **kwargs)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class StemContainer(Container):
|
| 110 |
+
"""
|
| 111 |
+
Container for the artists created in a :meth:`.Axes.stem` plot.
|
| 112 |
+
|
| 113 |
+
The container can be treated like a namedtuple ``(markerline, stemlines,
|
| 114 |
+
baseline)``.
|
| 115 |
+
|
| 116 |
+
Attributes
|
| 117 |
+
----------
|
| 118 |
+
markerline : `~matplotlib.lines.Line2D`
|
| 119 |
+
The artist of the markers at the stem heads.
|
| 120 |
+
|
| 121 |
+
stemlines : `~matplotlib.collections.LineCollection`
|
| 122 |
+
The artists of the vertical lines for all stems.
|
| 123 |
+
|
| 124 |
+
baseline : `~matplotlib.lines.Line2D`
|
| 125 |
+
The artist of the horizontal baseline.
|
| 126 |
+
"""
|
| 127 |
+
def __init__(self, markerline_stemlines_baseline, **kwargs):
|
| 128 |
+
"""
|
| 129 |
+
Parameters
|
| 130 |
+
----------
|
| 131 |
+
markerline_stemlines_baseline : tuple
|
| 132 |
+
Tuple of ``(markerline, stemlines, baseline)``.
|
| 133 |
+
``markerline`` contains the `.Line2D` of the markers,
|
| 134 |
+
``stemlines`` is a `.LineCollection` of the main lines,
|
| 135 |
+
``baseline`` is the `.Line2D` of the baseline.
|
| 136 |
+
"""
|
| 137 |
+
markerline, stemlines, baseline = markerline_stemlines_baseline
|
| 138 |
+
self.markerline = markerline
|
| 139 |
+
self.stemlines = stemlines
|
| 140 |
+
self.baseline = baseline
|
| 141 |
+
super().__init__(markerline_stemlines_baseline, **kwargs)
|
llava_video/lib/python3.10/site-packages/matplotlib/dviread.py
ADDED
|
@@ -0,0 +1,1139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A module for reading dvi files output by TeX. Several limitations make
|
| 3 |
+
this not (currently) useful as a general-purpose dvi preprocessor, but
|
| 4 |
+
it is currently used by the pdf backend for processing usetex text.
|
| 5 |
+
|
| 6 |
+
Interface::
|
| 7 |
+
|
| 8 |
+
with Dvi(filename, 72) as dvi:
|
| 9 |
+
# iterate over pages:
|
| 10 |
+
for page in dvi:
|
| 11 |
+
w, h, d = page.width, page.height, page.descent
|
| 12 |
+
for x, y, font, glyph, width in page.text:
|
| 13 |
+
fontname = font.texname
|
| 14 |
+
pointsize = font.size
|
| 15 |
+
...
|
| 16 |
+
for x, y, height, width in page.boxes:
|
| 17 |
+
...
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
from collections import namedtuple
|
| 21 |
+
import enum
|
| 22 |
+
from functools import lru_cache, partial, wraps
|
| 23 |
+
import logging
|
| 24 |
+
import os
|
| 25 |
+
from pathlib import Path
|
| 26 |
+
import re
|
| 27 |
+
import struct
|
| 28 |
+
import subprocess
|
| 29 |
+
import sys
|
| 30 |
+
|
| 31 |
+
import numpy as np
|
| 32 |
+
|
| 33 |
+
from matplotlib import _api, cbook
|
| 34 |
+
|
| 35 |
+
_log = logging.getLogger(__name__)
|
| 36 |
+
|
| 37 |
+
# Many dvi related files are looked for by external processes, require
|
| 38 |
+
# additional parsing, and are used many times per rendering, which is why they
|
| 39 |
+
# are cached using lru_cache().
|
| 40 |
+
|
| 41 |
+
# Dvi is a bytecode format documented in
|
| 42 |
+
# https://ctan.org/pkg/dvitype
|
| 43 |
+
# https://texdoc.org/serve/dvitype.pdf/0
|
| 44 |
+
#
|
| 45 |
+
# The file consists of a preamble, some number of pages, a postamble,
|
| 46 |
+
# and a finale. Different opcodes are allowed in different contexts,
|
| 47 |
+
# so the Dvi object has a parser state:
|
| 48 |
+
#
|
| 49 |
+
# pre: expecting the preamble
|
| 50 |
+
# outer: between pages (followed by a page or the postamble,
|
| 51 |
+
# also e.g. font definitions are allowed)
|
| 52 |
+
# page: processing a page
|
| 53 |
+
# post_post: state after the postamble (our current implementation
|
| 54 |
+
# just stops reading)
|
| 55 |
+
# finale: the finale (unimplemented in our current implementation)
|
| 56 |
+
|
| 57 |
+
_dvistate = enum.Enum('DviState', 'pre outer inpage post_post finale')
|
| 58 |
+
|
| 59 |
+
# The marks on a page consist of text and boxes. A page also has dimensions.
|
| 60 |
+
Page = namedtuple('Page', 'text boxes height width descent')
|
| 61 |
+
Box = namedtuple('Box', 'x y height width')
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
# Also a namedtuple, for backcompat.
|
| 65 |
+
class Text(namedtuple('Text', 'x y font glyph width')):
|
| 66 |
+
"""
|
| 67 |
+
A glyph in the dvi file.
|
| 68 |
+
|
| 69 |
+
The *x* and *y* attributes directly position the glyph. The *font*,
|
| 70 |
+
*glyph*, and *width* attributes are kept public for back-compatibility,
|
| 71 |
+
but users wanting to draw the glyph themselves are encouraged to instead
|
| 72 |
+
load the font specified by `font_path` at `font_size`, warp it with the
|
| 73 |
+
effects specified by `font_effects`, and load the glyph specified by
|
| 74 |
+
`glyph_name_or_index`.
|
| 75 |
+
"""
|
| 76 |
+
|
| 77 |
+
def _get_pdftexmap_entry(self):
|
| 78 |
+
return PsfontsMap(find_tex_file("pdftex.map"))[self.font.texname]
|
| 79 |
+
|
| 80 |
+
@property
|
| 81 |
+
def font_path(self):
|
| 82 |
+
"""The `~pathlib.Path` to the font for this glyph."""
|
| 83 |
+
psfont = self._get_pdftexmap_entry()
|
| 84 |
+
if psfont.filename is None:
|
| 85 |
+
raise ValueError("No usable font file found for {} ({}); "
|
| 86 |
+
"the font may lack a Type-1 version"
|
| 87 |
+
.format(psfont.psname.decode("ascii"),
|
| 88 |
+
psfont.texname.decode("ascii")))
|
| 89 |
+
return Path(psfont.filename)
|
| 90 |
+
|
| 91 |
+
@property
|
| 92 |
+
def font_size(self):
|
| 93 |
+
"""The font size."""
|
| 94 |
+
return self.font.size
|
| 95 |
+
|
| 96 |
+
@property
|
| 97 |
+
def font_effects(self):
|
| 98 |
+
"""
|
| 99 |
+
The "font effects" dict for this glyph.
|
| 100 |
+
|
| 101 |
+
This dict contains the values for this glyph of SlantFont and
|
| 102 |
+
ExtendFont (if any), read off :file:`pdftex.map`.
|
| 103 |
+
"""
|
| 104 |
+
return self._get_pdftexmap_entry().effects
|
| 105 |
+
|
| 106 |
+
@property
|
| 107 |
+
def glyph_name_or_index(self):
|
| 108 |
+
"""
|
| 109 |
+
Either the glyph name or the native charmap glyph index.
|
| 110 |
+
|
| 111 |
+
If :file:`pdftex.map` specifies an encoding for this glyph's font, that
|
| 112 |
+
is a mapping of glyph indices to Adobe glyph names; use it to convert
|
| 113 |
+
dvi indices to glyph names. Callers can then convert glyph names to
|
| 114 |
+
glyph indices (with FT_Get_Name_Index/get_name_index), and load the
|
| 115 |
+
glyph using FT_Load_Glyph/load_glyph.
|
| 116 |
+
|
| 117 |
+
If :file:`pdftex.map` specifies no encoding, the indices directly map
|
| 118 |
+
to the font's "native" charmap; glyphs should directly load using
|
| 119 |
+
FT_Load_Char/load_char after selecting the native charmap.
|
| 120 |
+
"""
|
| 121 |
+
entry = self._get_pdftexmap_entry()
|
| 122 |
+
return (_parse_enc(entry.encoding)[self.glyph]
|
| 123 |
+
if entry.encoding is not None else self.glyph)
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
# Opcode argument parsing
|
| 127 |
+
#
|
| 128 |
+
# Each of the following functions takes a Dvi object and delta, which is the
|
| 129 |
+
# difference between the opcode and the minimum opcode with the same meaning.
|
| 130 |
+
# Dvi opcodes often encode the number of argument bytes in this delta.
|
| 131 |
+
_arg_mapping = dict(
|
| 132 |
+
# raw: Return delta as is.
|
| 133 |
+
raw=lambda dvi, delta: delta,
|
| 134 |
+
# u1: Read 1 byte as an unsigned number.
|
| 135 |
+
u1=lambda dvi, delta: dvi._read_arg(1, signed=False),
|
| 136 |
+
# u4: Read 4 bytes as an unsigned number.
|
| 137 |
+
u4=lambda dvi, delta: dvi._read_arg(4, signed=False),
|
| 138 |
+
# s4: Read 4 bytes as a signed number.
|
| 139 |
+
s4=lambda dvi, delta: dvi._read_arg(4, signed=True),
|
| 140 |
+
# slen: Read delta bytes as a signed number, or None if delta is None.
|
| 141 |
+
slen=lambda dvi, delta: dvi._read_arg(delta, signed=True) if delta else None,
|
| 142 |
+
# slen1: Read (delta + 1) bytes as a signed number.
|
| 143 |
+
slen1=lambda dvi, delta: dvi._read_arg(delta + 1, signed=True),
|
| 144 |
+
# ulen1: Read (delta + 1) bytes as an unsigned number.
|
| 145 |
+
ulen1=lambda dvi, delta: dvi._read_arg(delta + 1, signed=False),
|
| 146 |
+
# olen1: Read (delta + 1) bytes as an unsigned number if less than 4 bytes,
|
| 147 |
+
# as a signed number if 4 bytes.
|
| 148 |
+
olen1=lambda dvi, delta: dvi._read_arg(delta + 1, signed=(delta == 3)),
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
def _dispatch(table, min, max=None, state=None, args=('raw',)):
|
| 153 |
+
"""
|
| 154 |
+
Decorator for dispatch by opcode. Sets the values in *table*
|
| 155 |
+
from *min* to *max* to this method, adds a check that the Dvi state
|
| 156 |
+
matches *state* if not None, reads arguments from the file according
|
| 157 |
+
to *args*.
|
| 158 |
+
|
| 159 |
+
Parameters
|
| 160 |
+
----------
|
| 161 |
+
table : dict[int, callable]
|
| 162 |
+
The dispatch table to be filled in.
|
| 163 |
+
|
| 164 |
+
min, max : int
|
| 165 |
+
Range of opcodes that calls the registered function; *max* defaults to
|
| 166 |
+
*min*.
|
| 167 |
+
|
| 168 |
+
state : _dvistate, optional
|
| 169 |
+
State of the Dvi object in which these opcodes are allowed.
|
| 170 |
+
|
| 171 |
+
args : list[str], default: ['raw']
|
| 172 |
+
Sequence of argument specifications:
|
| 173 |
+
|
| 174 |
+
- 'raw': opcode minus minimum
|
| 175 |
+
- 'u1': read one unsigned byte
|
| 176 |
+
- 'u4': read four bytes, treat as an unsigned number
|
| 177 |
+
- 's4': read four bytes, treat as a signed number
|
| 178 |
+
- 'slen': read (opcode - minimum) bytes, treat as signed
|
| 179 |
+
- 'slen1': read (opcode - minimum + 1) bytes, treat as signed
|
| 180 |
+
- 'ulen1': read (opcode - minimum + 1) bytes, treat as unsigned
|
| 181 |
+
- 'olen1': read (opcode - minimum + 1) bytes, treat as unsigned
|
| 182 |
+
if under four bytes, signed if four bytes
|
| 183 |
+
"""
|
| 184 |
+
def decorate(method):
|
| 185 |
+
get_args = [_arg_mapping[x] for x in args]
|
| 186 |
+
|
| 187 |
+
@wraps(method)
|
| 188 |
+
def wrapper(self, byte):
|
| 189 |
+
if state is not None and self.state != state:
|
| 190 |
+
raise ValueError("state precondition failed")
|
| 191 |
+
return method(self, *[f(self, byte-min) for f in get_args])
|
| 192 |
+
if max is None:
|
| 193 |
+
table[min] = wrapper
|
| 194 |
+
else:
|
| 195 |
+
for i in range(min, max+1):
|
| 196 |
+
assert table[i] is None
|
| 197 |
+
table[i] = wrapper
|
| 198 |
+
return wrapper
|
| 199 |
+
return decorate
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class Dvi:
|
| 203 |
+
"""
|
| 204 |
+
A reader for a dvi ("device-independent") file, as produced by TeX.
|
| 205 |
+
|
| 206 |
+
The current implementation can only iterate through pages in order,
|
| 207 |
+
and does not even attempt to verify the postamble.
|
| 208 |
+
|
| 209 |
+
This class can be used as a context manager to close the underlying
|
| 210 |
+
file upon exit. Pages can be read via iteration. Here is an overly
|
| 211 |
+
simple way to extract text without trying to detect whitespace::
|
| 212 |
+
|
| 213 |
+
>>> with matplotlib.dviread.Dvi('input.dvi', 72) as dvi:
|
| 214 |
+
... for page in dvi:
|
| 215 |
+
... print(''.join(chr(t.glyph) for t in page.text))
|
| 216 |
+
"""
|
| 217 |
+
# dispatch table
|
| 218 |
+
_dtable = [None] * 256
|
| 219 |
+
_dispatch = partial(_dispatch, _dtable)
|
| 220 |
+
|
| 221 |
+
def __init__(self, filename, dpi):
|
| 222 |
+
"""
|
| 223 |
+
Read the data from the file named *filename* and convert
|
| 224 |
+
TeX's internal units to units of *dpi* per inch.
|
| 225 |
+
*dpi* only sets the units and does not limit the resolution.
|
| 226 |
+
Use None to return TeX's internal units.
|
| 227 |
+
"""
|
| 228 |
+
_log.debug('Dvi: %s', filename)
|
| 229 |
+
self.file = open(filename, 'rb')
|
| 230 |
+
self.dpi = dpi
|
| 231 |
+
self.fonts = {}
|
| 232 |
+
self.state = _dvistate.pre
|
| 233 |
+
self._missing_font = None
|
| 234 |
+
|
| 235 |
+
def __enter__(self):
|
| 236 |
+
"""Context manager enter method, does nothing."""
|
| 237 |
+
return self
|
| 238 |
+
|
| 239 |
+
def __exit__(self, etype, evalue, etrace):
|
| 240 |
+
"""
|
| 241 |
+
Context manager exit method, closes the underlying file if it is open.
|
| 242 |
+
"""
|
| 243 |
+
self.close()
|
| 244 |
+
|
| 245 |
+
def __iter__(self):
|
| 246 |
+
"""
|
| 247 |
+
Iterate through the pages of the file.
|
| 248 |
+
|
| 249 |
+
Yields
|
| 250 |
+
------
|
| 251 |
+
Page
|
| 252 |
+
Details of all the text and box objects on the page.
|
| 253 |
+
The Page tuple contains lists of Text and Box tuples and
|
| 254 |
+
the page dimensions, and the Text and Box tuples contain
|
| 255 |
+
coordinates transformed into a standard Cartesian
|
| 256 |
+
coordinate system at the dpi value given when initializing.
|
| 257 |
+
The coordinates are floating point numbers, but otherwise
|
| 258 |
+
precision is not lost and coordinate values are not clipped to
|
| 259 |
+
integers.
|
| 260 |
+
"""
|
| 261 |
+
while self._read():
|
| 262 |
+
yield self._output()
|
| 263 |
+
|
| 264 |
+
def close(self):
|
| 265 |
+
"""Close the underlying file if it is open."""
|
| 266 |
+
if not self.file.closed:
|
| 267 |
+
self.file.close()
|
| 268 |
+
|
| 269 |
+
def _output(self):
|
| 270 |
+
"""
|
| 271 |
+
Output the text and boxes belonging to the most recent page.
|
| 272 |
+
page = dvi._output()
|
| 273 |
+
"""
|
| 274 |
+
minx = miny = np.inf
|
| 275 |
+
maxx = maxy = -np.inf
|
| 276 |
+
maxy_pure = -np.inf
|
| 277 |
+
for elt in self.text + self.boxes:
|
| 278 |
+
if isinstance(elt, Box):
|
| 279 |
+
x, y, h, w = elt
|
| 280 |
+
e = 0 # zero depth
|
| 281 |
+
else: # glyph
|
| 282 |
+
x, y, font, g, w = elt
|
| 283 |
+
h, e = font._height_depth_of(g)
|
| 284 |
+
minx = min(minx, x)
|
| 285 |
+
miny = min(miny, y - h)
|
| 286 |
+
maxx = max(maxx, x + w)
|
| 287 |
+
maxy = max(maxy, y + e)
|
| 288 |
+
maxy_pure = max(maxy_pure, y)
|
| 289 |
+
if self._baseline_v is not None:
|
| 290 |
+
maxy_pure = self._baseline_v # This should normally be the case.
|
| 291 |
+
self._baseline_v = None
|
| 292 |
+
|
| 293 |
+
if not self.text and not self.boxes: # Avoid infs/nans from inf+/-inf.
|
| 294 |
+
return Page(text=[], boxes=[], width=0, height=0, descent=0)
|
| 295 |
+
|
| 296 |
+
if self.dpi is None:
|
| 297 |
+
# special case for ease of debugging: output raw dvi coordinates
|
| 298 |
+
return Page(text=self.text, boxes=self.boxes,
|
| 299 |
+
width=maxx-minx, height=maxy_pure-miny,
|
| 300 |
+
descent=maxy-maxy_pure)
|
| 301 |
+
|
| 302 |
+
# convert from TeX's "scaled points" to dpi units
|
| 303 |
+
d = self.dpi / (72.27 * 2**16)
|
| 304 |
+
descent = (maxy - maxy_pure) * d
|
| 305 |
+
|
| 306 |
+
text = [Text((x-minx)*d, (maxy-y)*d - descent, f, g, w*d)
|
| 307 |
+
for (x, y, f, g, w) in self.text]
|
| 308 |
+
boxes = [Box((x-minx)*d, (maxy-y)*d - descent, h*d, w*d)
|
| 309 |
+
for (x, y, h, w) in self.boxes]
|
| 310 |
+
|
| 311 |
+
return Page(text=text, boxes=boxes, width=(maxx-minx)*d,
|
| 312 |
+
height=(maxy_pure-miny)*d, descent=descent)
|
| 313 |
+
|
| 314 |
+
def _read(self):
|
| 315 |
+
"""
|
| 316 |
+
Read one page from the file. Return True if successful,
|
| 317 |
+
False if there were no more pages.
|
| 318 |
+
"""
|
| 319 |
+
# Pages appear to start with the sequence
|
| 320 |
+
# bop (begin of page)
|
| 321 |
+
# xxx comment
|
| 322 |
+
# <push, ..., pop> # if using chemformula
|
| 323 |
+
# down
|
| 324 |
+
# push
|
| 325 |
+
# down
|
| 326 |
+
# <push, push, xxx, right, xxx, pop, pop> # if using xcolor
|
| 327 |
+
# down
|
| 328 |
+
# push
|
| 329 |
+
# down (possibly multiple)
|
| 330 |
+
# push <= here, v is the baseline position.
|
| 331 |
+
# etc.
|
| 332 |
+
# (dviasm is useful to explore this structure.)
|
| 333 |
+
# Thus, we use the vertical position at the first time the stack depth
|
| 334 |
+
# reaches 3, while at least three "downs" have been executed (excluding
|
| 335 |
+
# those popped out (corresponding to the chemformula preamble)), as the
|
| 336 |
+
# baseline (the "down" count is necessary to handle xcolor).
|
| 337 |
+
down_stack = [0]
|
| 338 |
+
self._baseline_v = None
|
| 339 |
+
while True:
|
| 340 |
+
byte = self.file.read(1)[0]
|
| 341 |
+
self._dtable[byte](self, byte)
|
| 342 |
+
if self._missing_font:
|
| 343 |
+
raise self._missing_font.to_exception()
|
| 344 |
+
name = self._dtable[byte].__name__
|
| 345 |
+
if name == "_push":
|
| 346 |
+
down_stack.append(down_stack[-1])
|
| 347 |
+
elif name == "_pop":
|
| 348 |
+
down_stack.pop()
|
| 349 |
+
elif name == "_down":
|
| 350 |
+
down_stack[-1] += 1
|
| 351 |
+
if (self._baseline_v is None
|
| 352 |
+
and len(getattr(self, "stack", [])) == 3
|
| 353 |
+
and down_stack[-1] >= 4):
|
| 354 |
+
self._baseline_v = self.v
|
| 355 |
+
if byte == 140: # end of page
|
| 356 |
+
return True
|
| 357 |
+
if self.state is _dvistate.post_post: # end of file
|
| 358 |
+
self.close()
|
| 359 |
+
return False
|
| 360 |
+
|
| 361 |
+
def _read_arg(self, nbytes, signed=False):
|
| 362 |
+
"""
|
| 363 |
+
Read and return a big-endian integer *nbytes* long.
|
| 364 |
+
Signedness is determined by the *signed* keyword.
|
| 365 |
+
"""
|
| 366 |
+
return int.from_bytes(self.file.read(nbytes), "big", signed=signed)
|
| 367 |
+
|
| 368 |
+
@_dispatch(min=0, max=127, state=_dvistate.inpage)
|
| 369 |
+
def _set_char_immediate(self, char):
|
| 370 |
+
self._put_char_real(char)
|
| 371 |
+
if isinstance(self.fonts[self.f], cbook._ExceptionInfo):
|
| 372 |
+
return
|
| 373 |
+
self.h += self.fonts[self.f]._width_of(char)
|
| 374 |
+
|
| 375 |
+
@_dispatch(min=128, max=131, state=_dvistate.inpage, args=('olen1',))
|
| 376 |
+
def _set_char(self, char):
|
| 377 |
+
self._put_char_real(char)
|
| 378 |
+
if isinstance(self.fonts[self.f], cbook._ExceptionInfo):
|
| 379 |
+
return
|
| 380 |
+
self.h += self.fonts[self.f]._width_of(char)
|
| 381 |
+
|
| 382 |
+
@_dispatch(132, state=_dvistate.inpage, args=('s4', 's4'))
|
| 383 |
+
def _set_rule(self, a, b):
|
| 384 |
+
self._put_rule_real(a, b)
|
| 385 |
+
self.h += b
|
| 386 |
+
|
| 387 |
+
@_dispatch(min=133, max=136, state=_dvistate.inpage, args=('olen1',))
|
| 388 |
+
def _put_char(self, char):
|
| 389 |
+
self._put_char_real(char)
|
| 390 |
+
|
| 391 |
+
def _put_char_real(self, char):
|
| 392 |
+
font = self.fonts[self.f]
|
| 393 |
+
if isinstance(font, cbook._ExceptionInfo):
|
| 394 |
+
self._missing_font = font
|
| 395 |
+
elif font._vf is None:
|
| 396 |
+
self.text.append(Text(self.h, self.v, font, char,
|
| 397 |
+
font._width_of(char)))
|
| 398 |
+
else:
|
| 399 |
+
scale = font._scale
|
| 400 |
+
for x, y, f, g, w in font._vf[char].text:
|
| 401 |
+
newf = DviFont(scale=_mul2012(scale, f._scale),
|
| 402 |
+
tfm=f._tfm, texname=f.texname, vf=f._vf)
|
| 403 |
+
self.text.append(Text(self.h + _mul2012(x, scale),
|
| 404 |
+
self.v + _mul2012(y, scale),
|
| 405 |
+
newf, g, newf._width_of(g)))
|
| 406 |
+
self.boxes.extend([Box(self.h + _mul2012(x, scale),
|
| 407 |
+
self.v + _mul2012(y, scale),
|
| 408 |
+
_mul2012(a, scale), _mul2012(b, scale))
|
| 409 |
+
for x, y, a, b in font._vf[char].boxes])
|
| 410 |
+
|
| 411 |
+
@_dispatch(137, state=_dvistate.inpage, args=('s4', 's4'))
|
| 412 |
+
def _put_rule(self, a, b):
|
| 413 |
+
self._put_rule_real(a, b)
|
| 414 |
+
|
| 415 |
+
def _put_rule_real(self, a, b):
|
| 416 |
+
if a > 0 and b > 0:
|
| 417 |
+
self.boxes.append(Box(self.h, self.v, a, b))
|
| 418 |
+
|
| 419 |
+
@_dispatch(138)
|
| 420 |
+
def _nop(self, _):
|
| 421 |
+
pass
|
| 422 |
+
|
| 423 |
+
@_dispatch(139, state=_dvistate.outer, args=('s4',)*11)
|
| 424 |
+
def _bop(self, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, p):
|
| 425 |
+
self.state = _dvistate.inpage
|
| 426 |
+
self.h = self.v = self.w = self.x = self.y = self.z = 0
|
| 427 |
+
self.stack = []
|
| 428 |
+
self.text = [] # list of Text objects
|
| 429 |
+
self.boxes = [] # list of Box objects
|
| 430 |
+
|
| 431 |
+
@_dispatch(140, state=_dvistate.inpage)
|
| 432 |
+
def _eop(self, _):
|
| 433 |
+
self.state = _dvistate.outer
|
| 434 |
+
del self.h, self.v, self.w, self.x, self.y, self.z, self.stack
|
| 435 |
+
|
| 436 |
+
@_dispatch(141, state=_dvistate.inpage)
|
| 437 |
+
def _push(self, _):
|
| 438 |
+
self.stack.append((self.h, self.v, self.w, self.x, self.y, self.z))
|
| 439 |
+
|
| 440 |
+
@_dispatch(142, state=_dvistate.inpage)
|
| 441 |
+
def _pop(self, _):
|
| 442 |
+
self.h, self.v, self.w, self.x, self.y, self.z = self.stack.pop()
|
| 443 |
+
|
| 444 |
+
@_dispatch(min=143, max=146, state=_dvistate.inpage, args=('slen1',))
|
| 445 |
+
def _right(self, b):
|
| 446 |
+
self.h += b
|
| 447 |
+
|
| 448 |
+
@_dispatch(min=147, max=151, state=_dvistate.inpage, args=('slen',))
|
| 449 |
+
def _right_w(self, new_w):
|
| 450 |
+
if new_w is not None:
|
| 451 |
+
self.w = new_w
|
| 452 |
+
self.h += self.w
|
| 453 |
+
|
| 454 |
+
@_dispatch(min=152, max=156, state=_dvistate.inpage, args=('slen',))
|
| 455 |
+
def _right_x(self, new_x):
|
| 456 |
+
if new_x is not None:
|
| 457 |
+
self.x = new_x
|
| 458 |
+
self.h += self.x
|
| 459 |
+
|
| 460 |
+
@_dispatch(min=157, max=160, state=_dvistate.inpage, args=('slen1',))
|
| 461 |
+
def _down(self, a):
|
| 462 |
+
self.v += a
|
| 463 |
+
|
| 464 |
+
@_dispatch(min=161, max=165, state=_dvistate.inpage, args=('slen',))
|
| 465 |
+
def _down_y(self, new_y):
|
| 466 |
+
if new_y is not None:
|
| 467 |
+
self.y = new_y
|
| 468 |
+
self.v += self.y
|
| 469 |
+
|
| 470 |
+
@_dispatch(min=166, max=170, state=_dvistate.inpage, args=('slen',))
|
| 471 |
+
def _down_z(self, new_z):
|
| 472 |
+
if new_z is not None:
|
| 473 |
+
self.z = new_z
|
| 474 |
+
self.v += self.z
|
| 475 |
+
|
| 476 |
+
@_dispatch(min=171, max=234, state=_dvistate.inpage)
|
| 477 |
+
def _fnt_num_immediate(self, k):
|
| 478 |
+
self.f = k
|
| 479 |
+
|
| 480 |
+
@_dispatch(min=235, max=238, state=_dvistate.inpage, args=('olen1',))
|
| 481 |
+
def _fnt_num(self, new_f):
|
| 482 |
+
self.f = new_f
|
| 483 |
+
|
| 484 |
+
@_dispatch(min=239, max=242, args=('ulen1',))
|
| 485 |
+
def _xxx(self, datalen):
|
| 486 |
+
special = self.file.read(datalen)
|
| 487 |
+
_log.debug(
|
| 488 |
+
'Dvi._xxx: encountered special: %s',
|
| 489 |
+
''.join([chr(ch) if 32 <= ch < 127 else '<%02x>' % ch
|
| 490 |
+
for ch in special]))
|
| 491 |
+
|
| 492 |
+
@_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
|
| 493 |
+
def _fnt_def(self, k, c, s, d, a, l):
|
| 494 |
+
self._fnt_def_real(k, c, s, d, a, l)
|
| 495 |
+
|
| 496 |
+
def _fnt_def_real(self, k, c, s, d, a, l):
|
| 497 |
+
n = self.file.read(a + l)
|
| 498 |
+
fontname = n[-l:].decode('ascii')
|
| 499 |
+
try:
|
| 500 |
+
tfm = _tfmfile(fontname)
|
| 501 |
+
except FileNotFoundError as exc:
|
| 502 |
+
# Explicitly allow defining missing fonts for Vf support; we only
|
| 503 |
+
# register an error when trying to load a glyph from a missing font
|
| 504 |
+
# and throw that error in Dvi._read. For Vf, _finalize_packet
|
| 505 |
+
# checks whether a missing glyph has been used, and in that case
|
| 506 |
+
# skips the glyph definition.
|
| 507 |
+
self.fonts[k] = cbook._ExceptionInfo.from_exception(exc)
|
| 508 |
+
return
|
| 509 |
+
if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
|
| 510 |
+
raise ValueError(f'tfm checksum mismatch: {n}')
|
| 511 |
+
try:
|
| 512 |
+
vf = _vffile(fontname)
|
| 513 |
+
except FileNotFoundError:
|
| 514 |
+
vf = None
|
| 515 |
+
self.fonts[k] = DviFont(scale=s, tfm=tfm, texname=n, vf=vf)
|
| 516 |
+
|
| 517 |
+
@_dispatch(247, state=_dvistate.pre, args=('u1', 'u4', 'u4', 'u4', 'u1'))
|
| 518 |
+
def _pre(self, i, num, den, mag, k):
|
| 519 |
+
self.file.read(k) # comment in the dvi file
|
| 520 |
+
if i != 2:
|
| 521 |
+
raise ValueError(f"Unknown dvi format {i}")
|
| 522 |
+
if num != 25400000 or den != 7227 * 2**16:
|
| 523 |
+
raise ValueError("Nonstandard units in dvi file")
|
| 524 |
+
# meaning: TeX always uses those exact values, so it
|
| 525 |
+
# should be enough for us to support those
|
| 526 |
+
# (There are 72.27 pt to an inch so 7227 pt =
|
| 527 |
+
# 7227 * 2**16 sp to 100 in. The numerator is multiplied
|
| 528 |
+
# by 10^5 to get units of 10**-7 meters.)
|
| 529 |
+
if mag != 1000:
|
| 530 |
+
raise ValueError("Nonstandard magnification in dvi file")
|
| 531 |
+
# meaning: LaTeX seems to frown on setting \mag, so
|
| 532 |
+
# I think we can assume this is constant
|
| 533 |
+
self.state = _dvistate.outer
|
| 534 |
+
|
| 535 |
+
@_dispatch(248, state=_dvistate.outer)
|
| 536 |
+
def _post(self, _):
|
| 537 |
+
self.state = _dvistate.post_post
|
| 538 |
+
# TODO: actually read the postamble and finale?
|
| 539 |
+
# currently post_post just triggers closing the file
|
| 540 |
+
|
| 541 |
+
@_dispatch(249)
|
| 542 |
+
def _post_post(self, _):
|
| 543 |
+
raise NotImplementedError
|
| 544 |
+
|
| 545 |
+
@_dispatch(min=250, max=255)
|
| 546 |
+
def _malformed(self, offset):
|
| 547 |
+
raise ValueError(f"unknown command: byte {250 + offset}")
|
| 548 |
+
|
| 549 |
+
|
| 550 |
+
class DviFont:
|
| 551 |
+
"""
|
| 552 |
+
Encapsulation of a font that a DVI file can refer to.
|
| 553 |
+
|
| 554 |
+
This class holds a font's texname and size, supports comparison,
|
| 555 |
+
and knows the widths of glyphs in the same units as the AFM file.
|
| 556 |
+
There are also internal attributes (for use by dviread.py) that
|
| 557 |
+
are *not* used for comparison.
|
| 558 |
+
|
| 559 |
+
The size is in Adobe points (converted from TeX points).
|
| 560 |
+
|
| 561 |
+
Parameters
|
| 562 |
+
----------
|
| 563 |
+
scale : float
|
| 564 |
+
Factor by which the font is scaled from its natural size.
|
| 565 |
+
tfm : Tfm
|
| 566 |
+
TeX font metrics for this font
|
| 567 |
+
texname : bytes
|
| 568 |
+
Name of the font as used internally by TeX and friends, as an ASCII
|
| 569 |
+
bytestring. This is usually very different from any external font
|
| 570 |
+
names; `PsfontsMap` can be used to find the external name of the font.
|
| 571 |
+
vf : Vf
|
| 572 |
+
A TeX "virtual font" file, or None if this font is not virtual.
|
| 573 |
+
|
| 574 |
+
Attributes
|
| 575 |
+
----------
|
| 576 |
+
texname : bytes
|
| 577 |
+
size : float
|
| 578 |
+
Size of the font in Adobe points, converted from the slightly
|
| 579 |
+
smaller TeX points.
|
| 580 |
+
widths : list
|
| 581 |
+
Widths of glyphs in glyph-space units, typically 1/1000ths of
|
| 582 |
+
the point size.
|
| 583 |
+
|
| 584 |
+
"""
|
| 585 |
+
__slots__ = ('texname', 'size', 'widths', '_scale', '_vf', '_tfm')
|
| 586 |
+
|
| 587 |
+
def __init__(self, scale, tfm, texname, vf):
|
| 588 |
+
_api.check_isinstance(bytes, texname=texname)
|
| 589 |
+
self._scale = scale
|
| 590 |
+
self._tfm = tfm
|
| 591 |
+
self.texname = texname
|
| 592 |
+
self._vf = vf
|
| 593 |
+
self.size = scale * (72.0 / (72.27 * 2**16))
|
| 594 |
+
try:
|
| 595 |
+
nchars = max(tfm.width) + 1
|
| 596 |
+
except ValueError:
|
| 597 |
+
nchars = 0
|
| 598 |
+
self.widths = [(1000*tfm.width.get(char, 0)) >> 20
|
| 599 |
+
for char in range(nchars)]
|
| 600 |
+
|
| 601 |
+
def __eq__(self, other):
|
| 602 |
+
return (type(self) is type(other)
|
| 603 |
+
and self.texname == other.texname and self.size == other.size)
|
| 604 |
+
|
| 605 |
+
def __ne__(self, other):
|
| 606 |
+
return not self.__eq__(other)
|
| 607 |
+
|
| 608 |
+
def __repr__(self):
|
| 609 |
+
return f"<{type(self).__name__}: {self.texname}>"
|
| 610 |
+
|
| 611 |
+
def _width_of(self, char):
|
| 612 |
+
"""Width of char in dvi units."""
|
| 613 |
+
width = self._tfm.width.get(char, None)
|
| 614 |
+
if width is not None:
|
| 615 |
+
return _mul2012(width, self._scale)
|
| 616 |
+
_log.debug('No width for char %d in font %s.', char, self.texname)
|
| 617 |
+
return 0
|
| 618 |
+
|
| 619 |
+
def _height_depth_of(self, char):
|
| 620 |
+
"""Height and depth of char in dvi units."""
|
| 621 |
+
result = []
|
| 622 |
+
for metric, name in ((self._tfm.height, "height"),
|
| 623 |
+
(self._tfm.depth, "depth")):
|
| 624 |
+
value = metric.get(char, None)
|
| 625 |
+
if value is None:
|
| 626 |
+
_log.debug('No %s for char %d in font %s',
|
| 627 |
+
name, char, self.texname)
|
| 628 |
+
result.append(0)
|
| 629 |
+
else:
|
| 630 |
+
result.append(_mul2012(value, self._scale))
|
| 631 |
+
# cmsyXX (symbols font) glyph 0 ("minus") has a nonzero descent
|
| 632 |
+
# so that TeX aligns equations properly
|
| 633 |
+
# (https://tex.stackexchange.com/q/526103/)
|
| 634 |
+
# but we actually care about the rasterization depth to align
|
| 635 |
+
# the dvipng-generated images.
|
| 636 |
+
if re.match(br'^cmsy\d+$', self.texname) and char == 0:
|
| 637 |
+
result[-1] = 0
|
| 638 |
+
return result
|
| 639 |
+
|
| 640 |
+
|
| 641 |
+
class Vf(Dvi):
|
| 642 |
+
r"""
|
| 643 |
+
A virtual font (\*.vf file) containing subroutines for dvi files.
|
| 644 |
+
|
| 645 |
+
Parameters
|
| 646 |
+
----------
|
| 647 |
+
filename : str or path-like
|
| 648 |
+
|
| 649 |
+
Notes
|
| 650 |
+
-----
|
| 651 |
+
The virtual font format is a derivative of dvi:
|
| 652 |
+
http://mirrors.ctan.org/info/knuth/virtual-fonts
|
| 653 |
+
This class reuses some of the machinery of `Dvi`
|
| 654 |
+
but replaces the `_read` loop and dispatch mechanism.
|
| 655 |
+
|
| 656 |
+
Examples
|
| 657 |
+
--------
|
| 658 |
+
::
|
| 659 |
+
|
| 660 |
+
vf = Vf(filename)
|
| 661 |
+
glyph = vf[code]
|
| 662 |
+
glyph.text, glyph.boxes, glyph.width
|
| 663 |
+
"""
|
| 664 |
+
|
| 665 |
+
def __init__(self, filename):
|
| 666 |
+
super().__init__(filename, 0)
|
| 667 |
+
try:
|
| 668 |
+
self._first_font = None
|
| 669 |
+
self._chars = {}
|
| 670 |
+
self._read()
|
| 671 |
+
finally:
|
| 672 |
+
self.close()
|
| 673 |
+
|
| 674 |
+
def __getitem__(self, code):
|
| 675 |
+
return self._chars[code]
|
| 676 |
+
|
| 677 |
+
def _read(self):
|
| 678 |
+
"""
|
| 679 |
+
Read one page from the file. Return True if successful,
|
| 680 |
+
False if there were no more pages.
|
| 681 |
+
"""
|
| 682 |
+
packet_char = packet_ends = None
|
| 683 |
+
packet_len = packet_width = None
|
| 684 |
+
while True:
|
| 685 |
+
byte = self.file.read(1)[0]
|
| 686 |
+
# If we are in a packet, execute the dvi instructions
|
| 687 |
+
if self.state is _dvistate.inpage:
|
| 688 |
+
byte_at = self.file.tell()-1
|
| 689 |
+
if byte_at == packet_ends:
|
| 690 |
+
self._finalize_packet(packet_char, packet_width)
|
| 691 |
+
packet_len = packet_char = packet_width = None
|
| 692 |
+
# fall through to out-of-packet code
|
| 693 |
+
elif byte_at > packet_ends:
|
| 694 |
+
raise ValueError("Packet length mismatch in vf file")
|
| 695 |
+
else:
|
| 696 |
+
if byte in (139, 140) or byte >= 243:
|
| 697 |
+
raise ValueError(f"Inappropriate opcode {byte} in vf file")
|
| 698 |
+
Dvi._dtable[byte](self, byte)
|
| 699 |
+
continue
|
| 700 |
+
|
| 701 |
+
# We are outside a packet
|
| 702 |
+
if byte < 242: # a short packet (length given by byte)
|
| 703 |
+
packet_len = byte
|
| 704 |
+
packet_char = self._read_arg(1)
|
| 705 |
+
packet_width = self._read_arg(3)
|
| 706 |
+
packet_ends = self._init_packet(byte)
|
| 707 |
+
self.state = _dvistate.inpage
|
| 708 |
+
elif byte == 242: # a long packet
|
| 709 |
+
packet_len = self._read_arg(4)
|
| 710 |
+
packet_char = self._read_arg(4)
|
| 711 |
+
packet_width = self._read_arg(4)
|
| 712 |
+
self._init_packet(packet_len)
|
| 713 |
+
elif 243 <= byte <= 246:
|
| 714 |
+
k = self._read_arg(byte - 242, byte == 246)
|
| 715 |
+
c = self._read_arg(4)
|
| 716 |
+
s = self._read_arg(4)
|
| 717 |
+
d = self._read_arg(4)
|
| 718 |
+
a = self._read_arg(1)
|
| 719 |
+
l = self._read_arg(1)
|
| 720 |
+
self._fnt_def_real(k, c, s, d, a, l)
|
| 721 |
+
if self._first_font is None:
|
| 722 |
+
self._first_font = k
|
| 723 |
+
elif byte == 247: # preamble
|
| 724 |
+
i = self._read_arg(1)
|
| 725 |
+
k = self._read_arg(1)
|
| 726 |
+
x = self.file.read(k)
|
| 727 |
+
cs = self._read_arg(4)
|
| 728 |
+
ds = self._read_arg(4)
|
| 729 |
+
self._pre(i, x, cs, ds)
|
| 730 |
+
elif byte == 248: # postamble (just some number of 248s)
|
| 731 |
+
break
|
| 732 |
+
else:
|
| 733 |
+
raise ValueError(f"Unknown vf opcode {byte}")
|
| 734 |
+
|
| 735 |
+
def _init_packet(self, pl):
|
| 736 |
+
if self.state != _dvistate.outer:
|
| 737 |
+
raise ValueError("Misplaced packet in vf file")
|
| 738 |
+
self.h = self.v = self.w = self.x = self.y = self.z = 0
|
| 739 |
+
self.stack = []
|
| 740 |
+
self.text = []
|
| 741 |
+
self.boxes = []
|
| 742 |
+
self.f = self._first_font
|
| 743 |
+
self._missing_font = None
|
| 744 |
+
return self.file.tell() + pl
|
| 745 |
+
|
| 746 |
+
def _finalize_packet(self, packet_char, packet_width):
|
| 747 |
+
if not self._missing_font: # Otherwise we don't have full glyph definition.
|
| 748 |
+
self._chars[packet_char] = Page(
|
| 749 |
+
text=self.text, boxes=self.boxes, width=packet_width,
|
| 750 |
+
height=None, descent=None)
|
| 751 |
+
self.state = _dvistate.outer
|
| 752 |
+
|
| 753 |
+
def _pre(self, i, x, cs, ds):
|
| 754 |
+
if self.state is not _dvistate.pre:
|
| 755 |
+
raise ValueError("pre command in middle of vf file")
|
| 756 |
+
if i != 202:
|
| 757 |
+
raise ValueError(f"Unknown vf format {i}")
|
| 758 |
+
if len(x):
|
| 759 |
+
_log.debug('vf file comment: %s', x)
|
| 760 |
+
self.state = _dvistate.outer
|
| 761 |
+
# cs = checksum, ds = design size
|
| 762 |
+
|
| 763 |
+
|
| 764 |
+
def _mul2012(num1, num2):
|
| 765 |
+
"""Multiply two numbers in 20.12 fixed point format."""
|
| 766 |
+
# Separated into a function because >> has surprising precedence
|
| 767 |
+
return (num1*num2) >> 20
|
| 768 |
+
|
| 769 |
+
|
| 770 |
+
class Tfm:
|
| 771 |
+
"""
|
| 772 |
+
A TeX Font Metric file.
|
| 773 |
+
|
| 774 |
+
This implementation covers only the bare minimum needed by the Dvi class.
|
| 775 |
+
|
| 776 |
+
Parameters
|
| 777 |
+
----------
|
| 778 |
+
filename : str or path-like
|
| 779 |
+
|
| 780 |
+
Attributes
|
| 781 |
+
----------
|
| 782 |
+
checksum : int
|
| 783 |
+
Used for verifying against the dvi file.
|
| 784 |
+
design_size : int
|
| 785 |
+
Design size of the font (unknown units)
|
| 786 |
+
width, height, depth : dict
|
| 787 |
+
Dimensions of each character, need to be scaled by the factor
|
| 788 |
+
specified in the dvi file. These are dicts because indexing may
|
| 789 |
+
not start from 0.
|
| 790 |
+
"""
|
| 791 |
+
__slots__ = ('checksum', 'design_size', 'width', 'height', 'depth')
|
| 792 |
+
|
| 793 |
+
def __init__(self, filename):
|
| 794 |
+
_log.debug('opening tfm file %s', filename)
|
| 795 |
+
with open(filename, 'rb') as file:
|
| 796 |
+
header1 = file.read(24)
|
| 797 |
+
lh, bc, ec, nw, nh, nd = struct.unpack('!6H', header1[2:14])
|
| 798 |
+
_log.debug('lh=%d, bc=%d, ec=%d, nw=%d, nh=%d, nd=%d',
|
| 799 |
+
lh, bc, ec, nw, nh, nd)
|
| 800 |
+
header2 = file.read(4*lh)
|
| 801 |
+
self.checksum, self.design_size = struct.unpack('!2I', header2[:8])
|
| 802 |
+
# there is also encoding information etc.
|
| 803 |
+
char_info = file.read(4*(ec-bc+1))
|
| 804 |
+
widths = struct.unpack(f'!{nw}i', file.read(4*nw))
|
| 805 |
+
heights = struct.unpack(f'!{nh}i', file.read(4*nh))
|
| 806 |
+
depths = struct.unpack(f'!{nd}i', file.read(4*nd))
|
| 807 |
+
self.width = {}
|
| 808 |
+
self.height = {}
|
| 809 |
+
self.depth = {}
|
| 810 |
+
for idx, char in enumerate(range(bc, ec+1)):
|
| 811 |
+
byte0 = char_info[4*idx]
|
| 812 |
+
byte1 = char_info[4*idx+1]
|
| 813 |
+
self.width[char] = widths[byte0]
|
| 814 |
+
self.height[char] = heights[byte1 >> 4]
|
| 815 |
+
self.depth[char] = depths[byte1 & 0xf]
|
| 816 |
+
|
| 817 |
+
|
| 818 |
+
PsFont = namedtuple('PsFont', 'texname psname effects encoding filename')
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
class PsfontsMap:
|
| 822 |
+
"""
|
| 823 |
+
A psfonts.map formatted file, mapping TeX fonts to PS fonts.
|
| 824 |
+
|
| 825 |
+
Parameters
|
| 826 |
+
----------
|
| 827 |
+
filename : str or path-like
|
| 828 |
+
|
| 829 |
+
Notes
|
| 830 |
+
-----
|
| 831 |
+
For historical reasons, TeX knows many Type-1 fonts by different
|
| 832 |
+
names than the outside world. (For one thing, the names have to
|
| 833 |
+
fit in eight characters.) Also, TeX's native fonts are not Type-1
|
| 834 |
+
but Metafont, which is nontrivial to convert to PostScript except
|
| 835 |
+
as a bitmap. While high-quality conversions to Type-1 format exist
|
| 836 |
+
and are shipped with modern TeX distributions, we need to know
|
| 837 |
+
which Type-1 fonts are the counterparts of which native fonts. For
|
| 838 |
+
these reasons a mapping is needed from internal font names to font
|
| 839 |
+
file names.
|
| 840 |
+
|
| 841 |
+
A texmf tree typically includes mapping files called e.g.
|
| 842 |
+
:file:`psfonts.map`, :file:`pdftex.map`, or :file:`dvipdfm.map`.
|
| 843 |
+
The file :file:`psfonts.map` is used by :program:`dvips`,
|
| 844 |
+
:file:`pdftex.map` by :program:`pdfTeX`, and :file:`dvipdfm.map`
|
| 845 |
+
by :program:`dvipdfm`. :file:`psfonts.map` might avoid embedding
|
| 846 |
+
the 35 PostScript fonts (i.e., have no filename for them, as in
|
| 847 |
+
the Times-Bold example above), while the pdf-related files perhaps
|
| 848 |
+
only avoid the "Base 14" pdf fonts. But the user may have
|
| 849 |
+
configured these files differently.
|
| 850 |
+
|
| 851 |
+
Examples
|
| 852 |
+
--------
|
| 853 |
+
>>> map = PsfontsMap(find_tex_file('pdftex.map'))
|
| 854 |
+
>>> entry = map[b'ptmbo8r']
|
| 855 |
+
>>> entry.texname
|
| 856 |
+
b'ptmbo8r'
|
| 857 |
+
>>> entry.psname
|
| 858 |
+
b'Times-Bold'
|
| 859 |
+
>>> entry.encoding
|
| 860 |
+
'/usr/local/texlive/2008/texmf-dist/fonts/enc/dvips/base/8r.enc'
|
| 861 |
+
>>> entry.effects
|
| 862 |
+
{'slant': 0.16700000000000001}
|
| 863 |
+
>>> entry.filename
|
| 864 |
+
"""
|
| 865 |
+
__slots__ = ('_filename', '_unparsed', '_parsed')
|
| 866 |
+
|
| 867 |
+
# Create a filename -> PsfontsMap cache, so that calling
|
| 868 |
+
# `PsfontsMap(filename)` with the same filename a second time immediately
|
| 869 |
+
# returns the same object.
|
| 870 |
+
@lru_cache
|
| 871 |
+
def __new__(cls, filename):
|
| 872 |
+
self = object.__new__(cls)
|
| 873 |
+
self._filename = os.fsdecode(filename)
|
| 874 |
+
# Some TeX distributions have enormous pdftex.map files which would
|
| 875 |
+
# take hundreds of milliseconds to parse, but it is easy enough to just
|
| 876 |
+
# store the unparsed lines (keyed by the first word, which is the
|
| 877 |
+
# texname) and parse them on-demand.
|
| 878 |
+
with open(filename, 'rb') as file:
|
| 879 |
+
self._unparsed = {}
|
| 880 |
+
for line in file:
|
| 881 |
+
tfmname = line.split(b' ', 1)[0]
|
| 882 |
+
self._unparsed.setdefault(tfmname, []).append(line)
|
| 883 |
+
self._parsed = {}
|
| 884 |
+
return self
|
| 885 |
+
|
| 886 |
+
def __getitem__(self, texname):
|
| 887 |
+
assert isinstance(texname, bytes)
|
| 888 |
+
if texname in self._unparsed:
|
| 889 |
+
for line in self._unparsed.pop(texname):
|
| 890 |
+
if self._parse_and_cache_line(line):
|
| 891 |
+
break
|
| 892 |
+
try:
|
| 893 |
+
return self._parsed[texname]
|
| 894 |
+
except KeyError:
|
| 895 |
+
raise LookupError(
|
| 896 |
+
f"An associated PostScript font (required by Matplotlib) "
|
| 897 |
+
f"could not be found for TeX font {texname.decode('ascii')!r} "
|
| 898 |
+
f"in {self._filename!r}; this problem can often be solved by "
|
| 899 |
+
f"installing a suitable PostScript font package in your TeX "
|
| 900 |
+
f"package manager") from None
|
| 901 |
+
|
| 902 |
+
def _parse_and_cache_line(self, line):
|
| 903 |
+
"""
|
| 904 |
+
Parse a line in the font mapping file.
|
| 905 |
+
|
| 906 |
+
The format is (partially) documented at
|
| 907 |
+
http://mirrors.ctan.org/systems/doc/pdftex/manual/pdftex-a.pdf
|
| 908 |
+
https://tug.org/texinfohtml/dvips.html#psfonts_002emap
|
| 909 |
+
Each line can have the following fields:
|
| 910 |
+
|
| 911 |
+
- tfmname (first, only required field),
|
| 912 |
+
- psname (defaults to tfmname, must come immediately after tfmname if
|
| 913 |
+
present),
|
| 914 |
+
- fontflags (integer, must come immediately after psname if present,
|
| 915 |
+
ignored by us),
|
| 916 |
+
- special (SlantFont and ExtendFont, only field that is double-quoted),
|
| 917 |
+
- fontfile, encodingfile (optional, prefixed by <, <<, or <[; << always
|
| 918 |
+
precedes a font, <[ always precedes an encoding, < can precede either
|
| 919 |
+
but then an encoding file must have extension .enc; < and << also
|
| 920 |
+
request different font subsetting behaviors but we ignore that; < can
|
| 921 |
+
be separated from the filename by whitespace).
|
| 922 |
+
|
| 923 |
+
special, fontfile, and encodingfile can appear in any order.
|
| 924 |
+
"""
|
| 925 |
+
# If the map file specifies multiple encodings for a font, we
|
| 926 |
+
# follow pdfTeX in choosing the last one specified. Such
|
| 927 |
+
# entries are probably mistakes but they have occurred.
|
| 928 |
+
# https://tex.stackexchange.com/q/10826/
|
| 929 |
+
|
| 930 |
+
if not line or line.startswith((b" ", b"%", b"*", b";", b"#")):
|
| 931 |
+
return
|
| 932 |
+
tfmname = basename = special = encodingfile = fontfile = None
|
| 933 |
+
is_subsetted = is_t1 = is_truetype = False
|
| 934 |
+
matches = re.finditer(br'"([^"]*)(?:"|$)|(\S+)', line)
|
| 935 |
+
for match in matches:
|
| 936 |
+
quoted, unquoted = match.groups()
|
| 937 |
+
if unquoted:
|
| 938 |
+
if unquoted.startswith(b"<<"): # font
|
| 939 |
+
fontfile = unquoted[2:]
|
| 940 |
+
elif unquoted.startswith(b"<["): # encoding
|
| 941 |
+
encodingfile = unquoted[2:]
|
| 942 |
+
elif unquoted.startswith(b"<"): # font or encoding
|
| 943 |
+
word = (
|
| 944 |
+
# <foo => foo
|
| 945 |
+
unquoted[1:]
|
| 946 |
+
# < by itself => read the next word
|
| 947 |
+
or next(filter(None, next(matches).groups())))
|
| 948 |
+
if word.endswith(b".enc"):
|
| 949 |
+
encodingfile = word
|
| 950 |
+
else:
|
| 951 |
+
fontfile = word
|
| 952 |
+
is_subsetted = True
|
| 953 |
+
elif tfmname is None:
|
| 954 |
+
tfmname = unquoted
|
| 955 |
+
elif basename is None:
|
| 956 |
+
basename = unquoted
|
| 957 |
+
elif quoted:
|
| 958 |
+
special = quoted
|
| 959 |
+
effects = {}
|
| 960 |
+
if special:
|
| 961 |
+
words = reversed(special.split())
|
| 962 |
+
for word in words:
|
| 963 |
+
if word == b"SlantFont":
|
| 964 |
+
effects["slant"] = float(next(words))
|
| 965 |
+
elif word == b"ExtendFont":
|
| 966 |
+
effects["extend"] = float(next(words))
|
| 967 |
+
|
| 968 |
+
# Verify some properties of the line that would cause it to be ignored
|
| 969 |
+
# otherwise.
|
| 970 |
+
if fontfile is not None:
|
| 971 |
+
if fontfile.endswith((b".ttf", b".ttc")):
|
| 972 |
+
is_truetype = True
|
| 973 |
+
elif not fontfile.endswith(b".otf"):
|
| 974 |
+
is_t1 = True
|
| 975 |
+
elif basename is not None:
|
| 976 |
+
is_t1 = True
|
| 977 |
+
if is_truetype and is_subsetted and encodingfile is None:
|
| 978 |
+
return
|
| 979 |
+
if not is_t1 and ("slant" in effects or "extend" in effects):
|
| 980 |
+
return
|
| 981 |
+
if abs(effects.get("slant", 0)) > 1:
|
| 982 |
+
return
|
| 983 |
+
if abs(effects.get("extend", 0)) > 2:
|
| 984 |
+
return
|
| 985 |
+
|
| 986 |
+
if basename is None:
|
| 987 |
+
basename = tfmname
|
| 988 |
+
if encodingfile is not None:
|
| 989 |
+
encodingfile = find_tex_file(encodingfile)
|
| 990 |
+
if fontfile is not None:
|
| 991 |
+
fontfile = find_tex_file(fontfile)
|
| 992 |
+
self._parsed[tfmname] = PsFont(
|
| 993 |
+
texname=tfmname, psname=basename, effects=effects,
|
| 994 |
+
encoding=encodingfile, filename=fontfile)
|
| 995 |
+
return True
|
| 996 |
+
|
| 997 |
+
|
| 998 |
+
def _parse_enc(path):
|
| 999 |
+
r"""
|
| 1000 |
+
Parse a \*.enc file referenced from a psfonts.map style file.
|
| 1001 |
+
|
| 1002 |
+
The format supported by this function is a tiny subset of PostScript.
|
| 1003 |
+
|
| 1004 |
+
Parameters
|
| 1005 |
+
----------
|
| 1006 |
+
path : `os.PathLike`
|
| 1007 |
+
|
| 1008 |
+
Returns
|
| 1009 |
+
-------
|
| 1010 |
+
list
|
| 1011 |
+
The nth entry of the list is the PostScript glyph name of the nth
|
| 1012 |
+
glyph.
|
| 1013 |
+
"""
|
| 1014 |
+
no_comments = re.sub("%.*", "", Path(path).read_text(encoding="ascii"))
|
| 1015 |
+
array = re.search(r"(?s)\[(.*)\]", no_comments).group(1)
|
| 1016 |
+
lines = [line for line in array.split() if line]
|
| 1017 |
+
if all(line.startswith("/") for line in lines):
|
| 1018 |
+
return [line[1:] for line in lines]
|
| 1019 |
+
else:
|
| 1020 |
+
raise ValueError(f"Failed to parse {path} as Postscript encoding")
|
| 1021 |
+
|
| 1022 |
+
|
| 1023 |
+
class _LuatexKpsewhich:
|
| 1024 |
+
@lru_cache # A singleton.
|
| 1025 |
+
def __new__(cls):
|
| 1026 |
+
self = object.__new__(cls)
|
| 1027 |
+
self._proc = self._new_proc()
|
| 1028 |
+
return self
|
| 1029 |
+
|
| 1030 |
+
def _new_proc(self):
|
| 1031 |
+
return subprocess.Popen(
|
| 1032 |
+
["luatex", "--luaonly",
|
| 1033 |
+
str(cbook._get_data_path("kpsewhich.lua"))],
|
| 1034 |
+
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
| 1035 |
+
|
| 1036 |
+
def search(self, filename):
|
| 1037 |
+
if self._proc.poll() is not None: # Dead, restart it.
|
| 1038 |
+
self._proc = self._new_proc()
|
| 1039 |
+
self._proc.stdin.write(os.fsencode(filename) + b"\n")
|
| 1040 |
+
self._proc.stdin.flush()
|
| 1041 |
+
out = self._proc.stdout.readline().rstrip()
|
| 1042 |
+
return None if out == b"nil" else os.fsdecode(out)
|
| 1043 |
+
|
| 1044 |
+
|
| 1045 |
+
@lru_cache
|
| 1046 |
+
def find_tex_file(filename):
|
| 1047 |
+
"""
|
| 1048 |
+
Find a file in the texmf tree using kpathsea_.
|
| 1049 |
+
|
| 1050 |
+
The kpathsea library, provided by most existing TeX distributions, both
|
| 1051 |
+
on Unix-like systems and on Windows (MikTeX), is invoked via a long-lived
|
| 1052 |
+
luatex process if luatex is installed, or via kpsewhich otherwise.
|
| 1053 |
+
|
| 1054 |
+
.. _kpathsea: https://www.tug.org/kpathsea/
|
| 1055 |
+
|
| 1056 |
+
Parameters
|
| 1057 |
+
----------
|
| 1058 |
+
filename : str or path-like
|
| 1059 |
+
|
| 1060 |
+
Raises
|
| 1061 |
+
------
|
| 1062 |
+
FileNotFoundError
|
| 1063 |
+
If the file is not found.
|
| 1064 |
+
"""
|
| 1065 |
+
|
| 1066 |
+
# we expect these to always be ascii encoded, but use utf-8
|
| 1067 |
+
# out of caution
|
| 1068 |
+
if isinstance(filename, bytes):
|
| 1069 |
+
filename = filename.decode('utf-8', errors='replace')
|
| 1070 |
+
|
| 1071 |
+
try:
|
| 1072 |
+
lk = _LuatexKpsewhich()
|
| 1073 |
+
except FileNotFoundError:
|
| 1074 |
+
lk = None # Fallback to directly calling kpsewhich, as below.
|
| 1075 |
+
|
| 1076 |
+
if lk:
|
| 1077 |
+
path = lk.search(filename)
|
| 1078 |
+
else:
|
| 1079 |
+
if sys.platform == 'win32':
|
| 1080 |
+
# On Windows only, kpathsea can use utf-8 for cmd args and output.
|
| 1081 |
+
# The `command_line_encoding` environment variable is set to force
|
| 1082 |
+
# it to always use utf-8 encoding. See Matplotlib issue #11848.
|
| 1083 |
+
kwargs = {'env': {**os.environ, 'command_line_encoding': 'utf-8'},
|
| 1084 |
+
'encoding': 'utf-8'}
|
| 1085 |
+
else: # On POSIX, run through the equivalent of os.fsdecode().
|
| 1086 |
+
kwargs = {'encoding': sys.getfilesystemencoding(),
|
| 1087 |
+
'errors': 'surrogateescape'}
|
| 1088 |
+
|
| 1089 |
+
try:
|
| 1090 |
+
path = (cbook._check_and_log_subprocess(['kpsewhich', filename],
|
| 1091 |
+
_log, **kwargs)
|
| 1092 |
+
.rstrip('\n'))
|
| 1093 |
+
except (FileNotFoundError, RuntimeError):
|
| 1094 |
+
path = None
|
| 1095 |
+
|
| 1096 |
+
if path:
|
| 1097 |
+
return path
|
| 1098 |
+
else:
|
| 1099 |
+
raise FileNotFoundError(
|
| 1100 |
+
f"Matplotlib's TeX implementation searched for a file named "
|
| 1101 |
+
f"{filename!r} in your texmf tree, but could not find it")
|
| 1102 |
+
|
| 1103 |
+
|
| 1104 |
+
@lru_cache
|
| 1105 |
+
def _fontfile(cls, suffix, texname):
|
| 1106 |
+
return cls(find_tex_file(texname + suffix))
|
| 1107 |
+
|
| 1108 |
+
|
| 1109 |
+
_tfmfile = partial(_fontfile, Tfm, ".tfm")
|
| 1110 |
+
_vffile = partial(_fontfile, Vf, ".vf")
|
| 1111 |
+
|
| 1112 |
+
|
| 1113 |
+
if __name__ == '__main__':
|
| 1114 |
+
from argparse import ArgumentParser
|
| 1115 |
+
import itertools
|
| 1116 |
+
|
| 1117 |
+
parser = ArgumentParser()
|
| 1118 |
+
parser.add_argument("filename")
|
| 1119 |
+
parser.add_argument("dpi", nargs="?", type=float, default=None)
|
| 1120 |
+
args = parser.parse_args()
|
| 1121 |
+
with Dvi(args.filename, args.dpi) as dvi:
|
| 1122 |
+
fontmap = PsfontsMap(find_tex_file('pdftex.map'))
|
| 1123 |
+
for page in dvi:
|
| 1124 |
+
print(f"=== new page === "
|
| 1125 |
+
f"(w: {page.width}, h: {page.height}, d: {page.descent})")
|
| 1126 |
+
for font, group in itertools.groupby(
|
| 1127 |
+
page.text, lambda text: text.font):
|
| 1128 |
+
print(f"font: {font.texname.decode('latin-1')!r}\t"
|
| 1129 |
+
f"scale: {font._scale / 2 ** 20}")
|
| 1130 |
+
print("x", "y", "glyph", "chr", "w", "(glyphs)", sep="\t")
|
| 1131 |
+
for text in group:
|
| 1132 |
+
print(text.x, text.y, text.glyph,
|
| 1133 |
+
chr(text.glyph) if chr(text.glyph).isprintable()
|
| 1134 |
+
else ".",
|
| 1135 |
+
text.width, sep="\t")
|
| 1136 |
+
if page.boxes:
|
| 1137 |
+
print("x", "y", "h", "w", "", "(boxes)", sep="\t")
|
| 1138 |
+
for box in page.boxes:
|
| 1139 |
+
print(box.x, box.y, box.height, box.width, sep="\t")
|
llava_video/lib/python3.10/site-packages/matplotlib/dviread.pyi
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
import io
|
| 3 |
+
import os
|
| 4 |
+
from enum import Enum
|
| 5 |
+
from collections.abc import Generator
|
| 6 |
+
|
| 7 |
+
from typing import NamedTuple
|
| 8 |
+
from typing_extensions import Self # < Py 3.11
|
| 9 |
+
|
| 10 |
+
class _dvistate(Enum):
|
| 11 |
+
pre: int
|
| 12 |
+
outer: int
|
| 13 |
+
inpage: int
|
| 14 |
+
post_post: int
|
| 15 |
+
finale: int
|
| 16 |
+
|
| 17 |
+
class Page(NamedTuple):
|
| 18 |
+
text: list[Text]
|
| 19 |
+
boxes: list[Box]
|
| 20 |
+
height: int
|
| 21 |
+
width: int
|
| 22 |
+
descent: int
|
| 23 |
+
|
| 24 |
+
class Box(NamedTuple):
|
| 25 |
+
x: int
|
| 26 |
+
y: int
|
| 27 |
+
height: int
|
| 28 |
+
width: int
|
| 29 |
+
|
| 30 |
+
class Text(NamedTuple):
|
| 31 |
+
x: int
|
| 32 |
+
y: int
|
| 33 |
+
font: DviFont
|
| 34 |
+
glyph: int
|
| 35 |
+
width: int
|
| 36 |
+
@property
|
| 37 |
+
def font_path(self) -> Path: ...
|
| 38 |
+
@property
|
| 39 |
+
def font_size(self) -> float: ...
|
| 40 |
+
@property
|
| 41 |
+
def font_effects(self) -> dict[str, float]: ...
|
| 42 |
+
@property
|
| 43 |
+
def glyph_name_or_index(self) -> int | str: ...
|
| 44 |
+
|
| 45 |
+
class Dvi:
|
| 46 |
+
file: io.BufferedReader
|
| 47 |
+
dpi: float | None
|
| 48 |
+
fonts: dict[int, DviFont]
|
| 49 |
+
state: _dvistate
|
| 50 |
+
def __init__(self, filename: str | os.PathLike, dpi: float | None) -> None: ...
|
| 51 |
+
def __enter__(self) -> Self: ...
|
| 52 |
+
def __exit__(self, etype, evalue, etrace) -> None: ...
|
| 53 |
+
def __iter__(self) -> Generator[Page, None, None]: ...
|
| 54 |
+
def close(self) -> None: ...
|
| 55 |
+
|
| 56 |
+
class DviFont:
|
| 57 |
+
texname: bytes
|
| 58 |
+
size: float
|
| 59 |
+
widths: list[int]
|
| 60 |
+
def __init__(
|
| 61 |
+
self, scale: float, tfm: Tfm, texname: bytes, vf: Vf | None
|
| 62 |
+
) -> None: ...
|
| 63 |
+
def __eq__(self, other: object) -> bool: ...
|
| 64 |
+
def __ne__(self, other: object) -> bool: ...
|
| 65 |
+
|
| 66 |
+
class Vf(Dvi):
|
| 67 |
+
def __init__(self, filename: str | os.PathLike) -> None: ...
|
| 68 |
+
def __getitem__(self, code: int) -> Page: ...
|
| 69 |
+
|
| 70 |
+
class Tfm:
|
| 71 |
+
checksum: int
|
| 72 |
+
design_size: int
|
| 73 |
+
width: dict[int, int]
|
| 74 |
+
height: dict[int, int]
|
| 75 |
+
depth: dict[int, int]
|
| 76 |
+
def __init__(self, filename: str | os.PathLike) -> None: ...
|
| 77 |
+
|
| 78 |
+
class PsFont(NamedTuple):
|
| 79 |
+
texname: bytes
|
| 80 |
+
psname: bytes
|
| 81 |
+
effects: dict[str, float]
|
| 82 |
+
encoding: None | bytes
|
| 83 |
+
filename: str
|
| 84 |
+
|
| 85 |
+
class PsfontsMap:
|
| 86 |
+
def __new__(cls, filename: str | os.PathLike) -> Self: ...
|
| 87 |
+
def __getitem__(self, texname: bytes) -> PsFont: ...
|
| 88 |
+
|
| 89 |
+
def find_tex_file(filename: str | os.PathLike) -> str: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/gridspec.py
ADDED
|
@@ -0,0 +1,788 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
r"""
|
| 2 |
+
:mod:`~matplotlib.gridspec` contains classes that help to layout multiple
|
| 3 |
+
`~.axes.Axes` in a grid-like pattern within a figure.
|
| 4 |
+
|
| 5 |
+
The `GridSpec` specifies the overall grid structure. Individual cells within
|
| 6 |
+
the grid are referenced by `SubplotSpec`\s.
|
| 7 |
+
|
| 8 |
+
Often, users need not access this module directly, and can use higher-level
|
| 9 |
+
methods like `~.pyplot.subplots`, `~.pyplot.subplot_mosaic` and
|
| 10 |
+
`~.Figure.subfigures`. See the tutorial :ref:`arranging_axes` for a guide.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import copy
|
| 14 |
+
import logging
|
| 15 |
+
from numbers import Integral
|
| 16 |
+
|
| 17 |
+
import numpy as np
|
| 18 |
+
|
| 19 |
+
import matplotlib as mpl
|
| 20 |
+
from matplotlib import _api, _pylab_helpers, _tight_layout
|
| 21 |
+
from matplotlib.transforms import Bbox
|
| 22 |
+
|
| 23 |
+
_log = logging.getLogger(__name__)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class GridSpecBase:
|
| 27 |
+
"""
|
| 28 |
+
A base class of GridSpec that specifies the geometry of the grid
|
| 29 |
+
that a subplot will be placed.
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
def __init__(self, nrows, ncols, height_ratios=None, width_ratios=None):
|
| 33 |
+
"""
|
| 34 |
+
Parameters
|
| 35 |
+
----------
|
| 36 |
+
nrows, ncols : int
|
| 37 |
+
The number of rows and columns of the grid.
|
| 38 |
+
width_ratios : array-like of length *ncols*, optional
|
| 39 |
+
Defines the relative widths of the columns. Each column gets a
|
| 40 |
+
relative width of ``width_ratios[i] / sum(width_ratios)``.
|
| 41 |
+
If not given, all columns will have the same width.
|
| 42 |
+
height_ratios : array-like of length *nrows*, optional
|
| 43 |
+
Defines the relative heights of the rows. Each row gets a
|
| 44 |
+
relative height of ``height_ratios[i] / sum(height_ratios)``.
|
| 45 |
+
If not given, all rows will have the same height.
|
| 46 |
+
"""
|
| 47 |
+
if not isinstance(nrows, Integral) or nrows <= 0:
|
| 48 |
+
raise ValueError(
|
| 49 |
+
f"Number of rows must be a positive integer, not {nrows!r}")
|
| 50 |
+
if not isinstance(ncols, Integral) or ncols <= 0:
|
| 51 |
+
raise ValueError(
|
| 52 |
+
f"Number of columns must be a positive integer, not {ncols!r}")
|
| 53 |
+
self._nrows, self._ncols = nrows, ncols
|
| 54 |
+
self.set_height_ratios(height_ratios)
|
| 55 |
+
self.set_width_ratios(width_ratios)
|
| 56 |
+
|
| 57 |
+
def __repr__(self):
|
| 58 |
+
height_arg = (f', height_ratios={self._row_height_ratios!r}'
|
| 59 |
+
if len(set(self._row_height_ratios)) != 1 else '')
|
| 60 |
+
width_arg = (f', width_ratios={self._col_width_ratios!r}'
|
| 61 |
+
if len(set(self._col_width_ratios)) != 1 else '')
|
| 62 |
+
return '{clsname}({nrows}, {ncols}{optionals})'.format(
|
| 63 |
+
clsname=self.__class__.__name__,
|
| 64 |
+
nrows=self._nrows,
|
| 65 |
+
ncols=self._ncols,
|
| 66 |
+
optionals=height_arg + width_arg,
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
nrows = property(lambda self: self._nrows,
|
| 70 |
+
doc="The number of rows in the grid.")
|
| 71 |
+
ncols = property(lambda self: self._ncols,
|
| 72 |
+
doc="The number of columns in the grid.")
|
| 73 |
+
|
| 74 |
+
def get_geometry(self):
|
| 75 |
+
"""
|
| 76 |
+
Return a tuple containing the number of rows and columns in the grid.
|
| 77 |
+
"""
|
| 78 |
+
return self._nrows, self._ncols
|
| 79 |
+
|
| 80 |
+
def get_subplot_params(self, figure=None):
|
| 81 |
+
# Must be implemented in subclasses
|
| 82 |
+
pass
|
| 83 |
+
|
| 84 |
+
def new_subplotspec(self, loc, rowspan=1, colspan=1):
|
| 85 |
+
"""
|
| 86 |
+
Create and return a `.SubplotSpec` instance.
|
| 87 |
+
|
| 88 |
+
Parameters
|
| 89 |
+
----------
|
| 90 |
+
loc : (int, int)
|
| 91 |
+
The position of the subplot in the grid as
|
| 92 |
+
``(row_index, column_index)``.
|
| 93 |
+
rowspan, colspan : int, default: 1
|
| 94 |
+
The number of rows and columns the subplot should span in the grid.
|
| 95 |
+
"""
|
| 96 |
+
loc1, loc2 = loc
|
| 97 |
+
subplotspec = self[loc1:loc1+rowspan, loc2:loc2+colspan]
|
| 98 |
+
return subplotspec
|
| 99 |
+
|
| 100 |
+
def set_width_ratios(self, width_ratios):
|
| 101 |
+
"""
|
| 102 |
+
Set the relative widths of the columns.
|
| 103 |
+
|
| 104 |
+
*width_ratios* must be of length *ncols*. Each column gets a relative
|
| 105 |
+
width of ``width_ratios[i] / sum(width_ratios)``.
|
| 106 |
+
"""
|
| 107 |
+
if width_ratios is None:
|
| 108 |
+
width_ratios = [1] * self._ncols
|
| 109 |
+
elif len(width_ratios) != self._ncols:
|
| 110 |
+
raise ValueError('Expected the given number of width ratios to '
|
| 111 |
+
'match the number of columns of the grid')
|
| 112 |
+
self._col_width_ratios = width_ratios
|
| 113 |
+
|
| 114 |
+
def get_width_ratios(self):
|
| 115 |
+
"""
|
| 116 |
+
Return the width ratios.
|
| 117 |
+
|
| 118 |
+
This is *None* if no width ratios have been set explicitly.
|
| 119 |
+
"""
|
| 120 |
+
return self._col_width_ratios
|
| 121 |
+
|
| 122 |
+
def set_height_ratios(self, height_ratios):
|
| 123 |
+
"""
|
| 124 |
+
Set the relative heights of the rows.
|
| 125 |
+
|
| 126 |
+
*height_ratios* must be of length *nrows*. Each row gets a relative
|
| 127 |
+
height of ``height_ratios[i] / sum(height_ratios)``.
|
| 128 |
+
"""
|
| 129 |
+
if height_ratios is None:
|
| 130 |
+
height_ratios = [1] * self._nrows
|
| 131 |
+
elif len(height_ratios) != self._nrows:
|
| 132 |
+
raise ValueError('Expected the given number of height ratios to '
|
| 133 |
+
'match the number of rows of the grid')
|
| 134 |
+
self._row_height_ratios = height_ratios
|
| 135 |
+
|
| 136 |
+
def get_height_ratios(self):
|
| 137 |
+
"""
|
| 138 |
+
Return the height ratios.
|
| 139 |
+
|
| 140 |
+
This is *None* if no height ratios have been set explicitly.
|
| 141 |
+
"""
|
| 142 |
+
return self._row_height_ratios
|
| 143 |
+
|
| 144 |
+
def get_grid_positions(self, fig):
|
| 145 |
+
"""
|
| 146 |
+
Return the positions of the grid cells in figure coordinates.
|
| 147 |
+
|
| 148 |
+
Parameters
|
| 149 |
+
----------
|
| 150 |
+
fig : `~matplotlib.figure.Figure`
|
| 151 |
+
The figure the grid should be applied to. The subplot parameters
|
| 152 |
+
(margins and spacing between subplots) are taken from *fig*.
|
| 153 |
+
|
| 154 |
+
Returns
|
| 155 |
+
-------
|
| 156 |
+
bottoms, tops, lefts, rights : array
|
| 157 |
+
The bottom, top, left, right positions of the grid cells in
|
| 158 |
+
figure coordinates.
|
| 159 |
+
"""
|
| 160 |
+
nrows, ncols = self.get_geometry()
|
| 161 |
+
subplot_params = self.get_subplot_params(fig)
|
| 162 |
+
left = subplot_params.left
|
| 163 |
+
right = subplot_params.right
|
| 164 |
+
bottom = subplot_params.bottom
|
| 165 |
+
top = subplot_params.top
|
| 166 |
+
wspace = subplot_params.wspace
|
| 167 |
+
hspace = subplot_params.hspace
|
| 168 |
+
tot_width = right - left
|
| 169 |
+
tot_height = top - bottom
|
| 170 |
+
|
| 171 |
+
# calculate accumulated heights of columns
|
| 172 |
+
cell_h = tot_height / (nrows + hspace*(nrows-1))
|
| 173 |
+
sep_h = hspace * cell_h
|
| 174 |
+
norm = cell_h * nrows / sum(self._row_height_ratios)
|
| 175 |
+
cell_heights = [r * norm for r in self._row_height_ratios]
|
| 176 |
+
sep_heights = [0] + ([sep_h] * (nrows-1))
|
| 177 |
+
cell_hs = np.cumsum(np.column_stack([sep_heights, cell_heights]).flat)
|
| 178 |
+
|
| 179 |
+
# calculate accumulated widths of rows
|
| 180 |
+
cell_w = tot_width / (ncols + wspace*(ncols-1))
|
| 181 |
+
sep_w = wspace * cell_w
|
| 182 |
+
norm = cell_w * ncols / sum(self._col_width_ratios)
|
| 183 |
+
cell_widths = [r * norm for r in self._col_width_ratios]
|
| 184 |
+
sep_widths = [0] + ([sep_w] * (ncols-1))
|
| 185 |
+
cell_ws = np.cumsum(np.column_stack([sep_widths, cell_widths]).flat)
|
| 186 |
+
|
| 187 |
+
fig_tops, fig_bottoms = (top - cell_hs).reshape((-1, 2)).T
|
| 188 |
+
fig_lefts, fig_rights = (left + cell_ws).reshape((-1, 2)).T
|
| 189 |
+
return fig_bottoms, fig_tops, fig_lefts, fig_rights
|
| 190 |
+
|
| 191 |
+
@staticmethod
|
| 192 |
+
def _check_gridspec_exists(figure, nrows, ncols):
|
| 193 |
+
"""
|
| 194 |
+
Check if the figure already has a gridspec with these dimensions,
|
| 195 |
+
or create a new one
|
| 196 |
+
"""
|
| 197 |
+
for ax in figure.get_axes():
|
| 198 |
+
gs = ax.get_gridspec()
|
| 199 |
+
if gs is not None:
|
| 200 |
+
if hasattr(gs, 'get_topmost_subplotspec'):
|
| 201 |
+
# This is needed for colorbar gridspec layouts.
|
| 202 |
+
# This is probably OK because this whole logic tree
|
| 203 |
+
# is for when the user is doing simple things with the
|
| 204 |
+
# add_subplot command. For complicated layouts
|
| 205 |
+
# like subgridspecs the proper gridspec is passed in...
|
| 206 |
+
gs = gs.get_topmost_subplotspec().get_gridspec()
|
| 207 |
+
if gs.get_geometry() == (nrows, ncols):
|
| 208 |
+
return gs
|
| 209 |
+
# else gridspec not found:
|
| 210 |
+
return GridSpec(nrows, ncols, figure=figure)
|
| 211 |
+
|
| 212 |
+
def __getitem__(self, key):
|
| 213 |
+
"""Create and return a `.SubplotSpec` instance."""
|
| 214 |
+
nrows, ncols = self.get_geometry()
|
| 215 |
+
|
| 216 |
+
def _normalize(key, size, axis): # Includes last index.
|
| 217 |
+
orig_key = key
|
| 218 |
+
if isinstance(key, slice):
|
| 219 |
+
start, stop, _ = key.indices(size)
|
| 220 |
+
if stop > start:
|
| 221 |
+
return start, stop - 1
|
| 222 |
+
raise IndexError("GridSpec slice would result in no space "
|
| 223 |
+
"allocated for subplot")
|
| 224 |
+
else:
|
| 225 |
+
if key < 0:
|
| 226 |
+
key = key + size
|
| 227 |
+
if 0 <= key < size:
|
| 228 |
+
return key, key
|
| 229 |
+
elif axis is not None:
|
| 230 |
+
raise IndexError(f"index {orig_key} is out of bounds for "
|
| 231 |
+
f"axis {axis} with size {size}")
|
| 232 |
+
else: # flat index
|
| 233 |
+
raise IndexError(f"index {orig_key} is out of bounds for "
|
| 234 |
+
f"GridSpec with size {size}")
|
| 235 |
+
|
| 236 |
+
if isinstance(key, tuple):
|
| 237 |
+
try:
|
| 238 |
+
k1, k2 = key
|
| 239 |
+
except ValueError as err:
|
| 240 |
+
raise ValueError("Unrecognized subplot spec") from err
|
| 241 |
+
num1, num2 = np.ravel_multi_index(
|
| 242 |
+
[_normalize(k1, nrows, 0), _normalize(k2, ncols, 1)],
|
| 243 |
+
(nrows, ncols))
|
| 244 |
+
else: # Single key
|
| 245 |
+
num1, num2 = _normalize(key, nrows * ncols, None)
|
| 246 |
+
|
| 247 |
+
return SubplotSpec(self, num1, num2)
|
| 248 |
+
|
| 249 |
+
def subplots(self, *, sharex=False, sharey=False, squeeze=True,
|
| 250 |
+
subplot_kw=None):
|
| 251 |
+
"""
|
| 252 |
+
Add all subplots specified by this `GridSpec` to its parent figure.
|
| 253 |
+
|
| 254 |
+
See `.Figure.subplots` for detailed documentation.
|
| 255 |
+
"""
|
| 256 |
+
|
| 257 |
+
figure = self.figure
|
| 258 |
+
|
| 259 |
+
if figure is None:
|
| 260 |
+
raise ValueError("GridSpec.subplots() only works for GridSpecs "
|
| 261 |
+
"created with a parent figure")
|
| 262 |
+
|
| 263 |
+
if not isinstance(sharex, str):
|
| 264 |
+
sharex = "all" if sharex else "none"
|
| 265 |
+
if not isinstance(sharey, str):
|
| 266 |
+
sharey = "all" if sharey else "none"
|
| 267 |
+
|
| 268 |
+
_api.check_in_list(["all", "row", "col", "none", False, True],
|
| 269 |
+
sharex=sharex, sharey=sharey)
|
| 270 |
+
if subplot_kw is None:
|
| 271 |
+
subplot_kw = {}
|
| 272 |
+
# don't mutate kwargs passed by user...
|
| 273 |
+
subplot_kw = subplot_kw.copy()
|
| 274 |
+
|
| 275 |
+
# Create array to hold all Axes.
|
| 276 |
+
axarr = np.empty((self._nrows, self._ncols), dtype=object)
|
| 277 |
+
for row in range(self._nrows):
|
| 278 |
+
for col in range(self._ncols):
|
| 279 |
+
shared_with = {"none": None, "all": axarr[0, 0],
|
| 280 |
+
"row": axarr[row, 0], "col": axarr[0, col]}
|
| 281 |
+
subplot_kw["sharex"] = shared_with[sharex]
|
| 282 |
+
subplot_kw["sharey"] = shared_with[sharey]
|
| 283 |
+
axarr[row, col] = figure.add_subplot(
|
| 284 |
+
self[row, col], **subplot_kw)
|
| 285 |
+
|
| 286 |
+
# turn off redundant tick labeling
|
| 287 |
+
if sharex in ["col", "all"]:
|
| 288 |
+
for ax in axarr.flat:
|
| 289 |
+
ax._label_outer_xaxis(skip_non_rectangular_axes=True)
|
| 290 |
+
if sharey in ["row", "all"]:
|
| 291 |
+
for ax in axarr.flat:
|
| 292 |
+
ax._label_outer_yaxis(skip_non_rectangular_axes=True)
|
| 293 |
+
|
| 294 |
+
if squeeze:
|
| 295 |
+
# Discarding unneeded dimensions that equal 1. If we only have one
|
| 296 |
+
# subplot, just return it instead of a 1-element array.
|
| 297 |
+
return axarr.item() if axarr.size == 1 else axarr.squeeze()
|
| 298 |
+
else:
|
| 299 |
+
# Returned axis array will be always 2-d, even if nrows=ncols=1.
|
| 300 |
+
return axarr
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
class GridSpec(GridSpecBase):
|
| 304 |
+
"""
|
| 305 |
+
A grid layout to place subplots within a figure.
|
| 306 |
+
|
| 307 |
+
The location of the grid cells is determined in a similar way to
|
| 308 |
+
`.SubplotParams` using *left*, *right*, *top*, *bottom*, *wspace*
|
| 309 |
+
and *hspace*.
|
| 310 |
+
|
| 311 |
+
Indexing a GridSpec instance returns a `.SubplotSpec`.
|
| 312 |
+
"""
|
| 313 |
+
def __init__(self, nrows, ncols, figure=None,
|
| 314 |
+
left=None, bottom=None, right=None, top=None,
|
| 315 |
+
wspace=None, hspace=None,
|
| 316 |
+
width_ratios=None, height_ratios=None):
|
| 317 |
+
"""
|
| 318 |
+
Parameters
|
| 319 |
+
----------
|
| 320 |
+
nrows, ncols : int
|
| 321 |
+
The number of rows and columns of the grid.
|
| 322 |
+
|
| 323 |
+
figure : `.Figure`, optional
|
| 324 |
+
Only used for constrained layout to create a proper layoutgrid.
|
| 325 |
+
|
| 326 |
+
left, right, top, bottom : float, optional
|
| 327 |
+
Extent of the subplots as a fraction of figure width or height.
|
| 328 |
+
Left cannot be larger than right, and bottom cannot be larger than
|
| 329 |
+
top. If not given, the values will be inferred from a figure or
|
| 330 |
+
rcParams at draw time. See also `GridSpec.get_subplot_params`.
|
| 331 |
+
|
| 332 |
+
wspace : float, optional
|
| 333 |
+
The amount of width reserved for space between subplots,
|
| 334 |
+
expressed as a fraction of the average axis width.
|
| 335 |
+
If not given, the values will be inferred from a figure or
|
| 336 |
+
rcParams when necessary. See also `GridSpec.get_subplot_params`.
|
| 337 |
+
|
| 338 |
+
hspace : float, optional
|
| 339 |
+
The amount of height reserved for space between subplots,
|
| 340 |
+
expressed as a fraction of the average axis height.
|
| 341 |
+
If not given, the values will be inferred from a figure or
|
| 342 |
+
rcParams when necessary. See also `GridSpec.get_subplot_params`.
|
| 343 |
+
|
| 344 |
+
width_ratios : array-like of length *ncols*, optional
|
| 345 |
+
Defines the relative widths of the columns. Each column gets a
|
| 346 |
+
relative width of ``width_ratios[i] / sum(width_ratios)``.
|
| 347 |
+
If not given, all columns will have the same width.
|
| 348 |
+
|
| 349 |
+
height_ratios : array-like of length *nrows*, optional
|
| 350 |
+
Defines the relative heights of the rows. Each row gets a
|
| 351 |
+
relative height of ``height_ratios[i] / sum(height_ratios)``.
|
| 352 |
+
If not given, all rows will have the same height.
|
| 353 |
+
|
| 354 |
+
"""
|
| 355 |
+
self.left = left
|
| 356 |
+
self.bottom = bottom
|
| 357 |
+
self.right = right
|
| 358 |
+
self.top = top
|
| 359 |
+
self.wspace = wspace
|
| 360 |
+
self.hspace = hspace
|
| 361 |
+
self.figure = figure
|
| 362 |
+
|
| 363 |
+
super().__init__(nrows, ncols,
|
| 364 |
+
width_ratios=width_ratios,
|
| 365 |
+
height_ratios=height_ratios)
|
| 366 |
+
|
| 367 |
+
_AllowedKeys = ["left", "bottom", "right", "top", "wspace", "hspace"]
|
| 368 |
+
|
| 369 |
+
def update(self, **kwargs):
|
| 370 |
+
"""
|
| 371 |
+
Update the subplot parameters of the grid.
|
| 372 |
+
|
| 373 |
+
Parameters that are not explicitly given are not changed. Setting a
|
| 374 |
+
parameter to *None* resets it to :rc:`figure.subplot.*`.
|
| 375 |
+
|
| 376 |
+
Parameters
|
| 377 |
+
----------
|
| 378 |
+
left, right, top, bottom : float or None, optional
|
| 379 |
+
Extent of the subplots as a fraction of figure width or height.
|
| 380 |
+
wspace, hspace : float, optional
|
| 381 |
+
Spacing between the subplots as a fraction of the average subplot
|
| 382 |
+
width / height.
|
| 383 |
+
"""
|
| 384 |
+
for k, v in kwargs.items():
|
| 385 |
+
if k in self._AllowedKeys:
|
| 386 |
+
setattr(self, k, v)
|
| 387 |
+
else:
|
| 388 |
+
raise AttributeError(f"{k} is an unknown keyword")
|
| 389 |
+
for figmanager in _pylab_helpers.Gcf.figs.values():
|
| 390 |
+
for ax in figmanager.canvas.figure.axes:
|
| 391 |
+
if ax.get_subplotspec() is not None:
|
| 392 |
+
ss = ax.get_subplotspec().get_topmost_subplotspec()
|
| 393 |
+
if ss.get_gridspec() == self:
|
| 394 |
+
fig = ax.get_figure(root=False)
|
| 395 |
+
ax._set_position(ax.get_subplotspec().get_position(fig))
|
| 396 |
+
|
| 397 |
+
def get_subplot_params(self, figure=None):
|
| 398 |
+
"""
|
| 399 |
+
Return the `.SubplotParams` for the GridSpec.
|
| 400 |
+
|
| 401 |
+
In order of precedence the values are taken from
|
| 402 |
+
|
| 403 |
+
- non-*None* attributes of the GridSpec
|
| 404 |
+
- the provided *figure*
|
| 405 |
+
- :rc:`figure.subplot.*`
|
| 406 |
+
|
| 407 |
+
Note that the ``figure`` attribute of the GridSpec is always ignored.
|
| 408 |
+
"""
|
| 409 |
+
if figure is None:
|
| 410 |
+
kw = {k: mpl.rcParams["figure.subplot."+k]
|
| 411 |
+
for k in self._AllowedKeys}
|
| 412 |
+
subplotpars = SubplotParams(**kw)
|
| 413 |
+
else:
|
| 414 |
+
subplotpars = copy.copy(figure.subplotpars)
|
| 415 |
+
|
| 416 |
+
subplotpars.update(**{k: getattr(self, k) for k in self._AllowedKeys})
|
| 417 |
+
|
| 418 |
+
return subplotpars
|
| 419 |
+
|
| 420 |
+
def locally_modified_subplot_params(self):
|
| 421 |
+
"""
|
| 422 |
+
Return a list of the names of the subplot parameters explicitly set
|
| 423 |
+
in the GridSpec.
|
| 424 |
+
|
| 425 |
+
This is a subset of the attributes of `.SubplotParams`.
|
| 426 |
+
"""
|
| 427 |
+
return [k for k in self._AllowedKeys if getattr(self, k)]
|
| 428 |
+
|
| 429 |
+
def tight_layout(self, figure, renderer=None,
|
| 430 |
+
pad=1.08, h_pad=None, w_pad=None, rect=None):
|
| 431 |
+
"""
|
| 432 |
+
Adjust subplot parameters to give specified padding.
|
| 433 |
+
|
| 434 |
+
Parameters
|
| 435 |
+
----------
|
| 436 |
+
figure : `.Figure`
|
| 437 |
+
The figure.
|
| 438 |
+
renderer : `.RendererBase` subclass, optional
|
| 439 |
+
The renderer to be used.
|
| 440 |
+
pad : float
|
| 441 |
+
Padding between the figure edge and the edges of subplots, as a
|
| 442 |
+
fraction of the font-size.
|
| 443 |
+
h_pad, w_pad : float, optional
|
| 444 |
+
Padding (height/width) between edges of adjacent subplots.
|
| 445 |
+
Defaults to *pad*.
|
| 446 |
+
rect : tuple (left, bottom, right, top), default: None
|
| 447 |
+
(left, bottom, right, top) rectangle in normalized figure
|
| 448 |
+
coordinates that the whole subplots area (including labels) will
|
| 449 |
+
fit into. Default (None) is the whole figure.
|
| 450 |
+
"""
|
| 451 |
+
if renderer is None:
|
| 452 |
+
renderer = figure._get_renderer()
|
| 453 |
+
kwargs = _tight_layout.get_tight_layout_figure(
|
| 454 |
+
figure, figure.axes,
|
| 455 |
+
_tight_layout.get_subplotspec_list(figure.axes, grid_spec=self),
|
| 456 |
+
renderer, pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
|
| 457 |
+
if kwargs:
|
| 458 |
+
self.update(**kwargs)
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
class GridSpecFromSubplotSpec(GridSpecBase):
|
| 462 |
+
"""
|
| 463 |
+
GridSpec whose subplot layout parameters are inherited from the
|
| 464 |
+
location specified by a given SubplotSpec.
|
| 465 |
+
"""
|
| 466 |
+
def __init__(self, nrows, ncols,
|
| 467 |
+
subplot_spec,
|
| 468 |
+
wspace=None, hspace=None,
|
| 469 |
+
height_ratios=None, width_ratios=None):
|
| 470 |
+
"""
|
| 471 |
+
Parameters
|
| 472 |
+
----------
|
| 473 |
+
nrows, ncols : int
|
| 474 |
+
Number of rows and number of columns of the grid.
|
| 475 |
+
subplot_spec : SubplotSpec
|
| 476 |
+
Spec from which the layout parameters are inherited.
|
| 477 |
+
wspace, hspace : float, optional
|
| 478 |
+
See `GridSpec` for more details. If not specified default values
|
| 479 |
+
(from the figure or rcParams) are used.
|
| 480 |
+
height_ratios : array-like of length *nrows*, optional
|
| 481 |
+
See `GridSpecBase` for details.
|
| 482 |
+
width_ratios : array-like of length *ncols*, optional
|
| 483 |
+
See `GridSpecBase` for details.
|
| 484 |
+
"""
|
| 485 |
+
self._wspace = wspace
|
| 486 |
+
self._hspace = hspace
|
| 487 |
+
if isinstance(subplot_spec, SubplotSpec):
|
| 488 |
+
self._subplot_spec = subplot_spec
|
| 489 |
+
else:
|
| 490 |
+
raise TypeError(
|
| 491 |
+
"subplot_spec must be type SubplotSpec, "
|
| 492 |
+
"usually from GridSpec, or axes.get_subplotspec.")
|
| 493 |
+
self.figure = self._subplot_spec.get_gridspec().figure
|
| 494 |
+
super().__init__(nrows, ncols,
|
| 495 |
+
width_ratios=width_ratios,
|
| 496 |
+
height_ratios=height_ratios)
|
| 497 |
+
|
| 498 |
+
def get_subplot_params(self, figure=None):
|
| 499 |
+
"""Return a dictionary of subplot layout parameters."""
|
| 500 |
+
hspace = (self._hspace if self._hspace is not None
|
| 501 |
+
else figure.subplotpars.hspace if figure is not None
|
| 502 |
+
else mpl.rcParams["figure.subplot.hspace"])
|
| 503 |
+
wspace = (self._wspace if self._wspace is not None
|
| 504 |
+
else figure.subplotpars.wspace if figure is not None
|
| 505 |
+
else mpl.rcParams["figure.subplot.wspace"])
|
| 506 |
+
|
| 507 |
+
figbox = self._subplot_spec.get_position(figure)
|
| 508 |
+
left, bottom, right, top = figbox.extents
|
| 509 |
+
|
| 510 |
+
return SubplotParams(left=left, right=right,
|
| 511 |
+
bottom=bottom, top=top,
|
| 512 |
+
wspace=wspace, hspace=hspace)
|
| 513 |
+
|
| 514 |
+
def get_topmost_subplotspec(self):
|
| 515 |
+
"""
|
| 516 |
+
Return the topmost `.SubplotSpec` instance associated with the subplot.
|
| 517 |
+
"""
|
| 518 |
+
return self._subplot_spec.get_topmost_subplotspec()
|
| 519 |
+
|
| 520 |
+
|
| 521 |
+
class SubplotSpec:
|
| 522 |
+
"""
|
| 523 |
+
The location of a subplot in a `GridSpec`.
|
| 524 |
+
|
| 525 |
+
.. note::
|
| 526 |
+
|
| 527 |
+
Likely, you will never instantiate a `SubplotSpec` yourself. Instead,
|
| 528 |
+
you will typically obtain one from a `GridSpec` using item-access.
|
| 529 |
+
|
| 530 |
+
Parameters
|
| 531 |
+
----------
|
| 532 |
+
gridspec : `~matplotlib.gridspec.GridSpec`
|
| 533 |
+
The GridSpec, which the subplot is referencing.
|
| 534 |
+
num1, num2 : int
|
| 535 |
+
The subplot will occupy the *num1*-th cell of the given
|
| 536 |
+
*gridspec*. If *num2* is provided, the subplot will span between
|
| 537 |
+
*num1*-th cell and *num2*-th cell **inclusive**.
|
| 538 |
+
|
| 539 |
+
The index starts from 0.
|
| 540 |
+
"""
|
| 541 |
+
def __init__(self, gridspec, num1, num2=None):
|
| 542 |
+
self._gridspec = gridspec
|
| 543 |
+
self.num1 = num1
|
| 544 |
+
self.num2 = num2
|
| 545 |
+
|
| 546 |
+
def __repr__(self):
|
| 547 |
+
return (f"{self.get_gridspec()}["
|
| 548 |
+
f"{self.rowspan.start}:{self.rowspan.stop}, "
|
| 549 |
+
f"{self.colspan.start}:{self.colspan.stop}]")
|
| 550 |
+
|
| 551 |
+
@staticmethod
|
| 552 |
+
def _from_subplot_args(figure, args):
|
| 553 |
+
"""
|
| 554 |
+
Construct a `.SubplotSpec` from a parent `.Figure` and either
|
| 555 |
+
|
| 556 |
+
- a `.SubplotSpec` -- returned as is;
|
| 557 |
+
- one or three numbers -- a MATLAB-style subplot specifier.
|
| 558 |
+
"""
|
| 559 |
+
if len(args) == 1:
|
| 560 |
+
arg, = args
|
| 561 |
+
if isinstance(arg, SubplotSpec):
|
| 562 |
+
return arg
|
| 563 |
+
elif not isinstance(arg, Integral):
|
| 564 |
+
raise ValueError(
|
| 565 |
+
f"Single argument to subplot must be a three-digit "
|
| 566 |
+
f"integer, not {arg!r}")
|
| 567 |
+
try:
|
| 568 |
+
rows, cols, num = map(int, str(arg))
|
| 569 |
+
except ValueError:
|
| 570 |
+
raise ValueError(
|
| 571 |
+
f"Single argument to subplot must be a three-digit "
|
| 572 |
+
f"integer, not {arg!r}") from None
|
| 573 |
+
elif len(args) == 3:
|
| 574 |
+
rows, cols, num = args
|
| 575 |
+
else:
|
| 576 |
+
raise _api.nargs_error("subplot", takes="1 or 3", given=len(args))
|
| 577 |
+
|
| 578 |
+
gs = GridSpec._check_gridspec_exists(figure, rows, cols)
|
| 579 |
+
if gs is None:
|
| 580 |
+
gs = GridSpec(rows, cols, figure=figure)
|
| 581 |
+
if isinstance(num, tuple) and len(num) == 2:
|
| 582 |
+
if not all(isinstance(n, Integral) for n in num):
|
| 583 |
+
raise ValueError(
|
| 584 |
+
f"Subplot specifier tuple must contain integers, not {num}"
|
| 585 |
+
)
|
| 586 |
+
i, j = num
|
| 587 |
+
else:
|
| 588 |
+
if not isinstance(num, Integral) or num < 1 or num > rows*cols:
|
| 589 |
+
raise ValueError(
|
| 590 |
+
f"num must be an integer with 1 <= num <= {rows*cols}, "
|
| 591 |
+
f"not {num!r}"
|
| 592 |
+
)
|
| 593 |
+
i = j = num
|
| 594 |
+
return gs[i-1:j]
|
| 595 |
+
|
| 596 |
+
# num2 is a property only to handle the case where it is None and someone
|
| 597 |
+
# mutates num1.
|
| 598 |
+
|
| 599 |
+
@property
|
| 600 |
+
def num2(self):
|
| 601 |
+
return self.num1 if self._num2 is None else self._num2
|
| 602 |
+
|
| 603 |
+
@num2.setter
|
| 604 |
+
def num2(self, value):
|
| 605 |
+
self._num2 = value
|
| 606 |
+
|
| 607 |
+
def get_gridspec(self):
|
| 608 |
+
return self._gridspec
|
| 609 |
+
|
| 610 |
+
def get_geometry(self):
|
| 611 |
+
"""
|
| 612 |
+
Return the subplot geometry as tuple ``(n_rows, n_cols, start, stop)``.
|
| 613 |
+
|
| 614 |
+
The indices *start* and *stop* define the range of the subplot within
|
| 615 |
+
the `GridSpec`. *stop* is inclusive (i.e. for a single cell
|
| 616 |
+
``start == stop``).
|
| 617 |
+
"""
|
| 618 |
+
rows, cols = self.get_gridspec().get_geometry()
|
| 619 |
+
return rows, cols, self.num1, self.num2
|
| 620 |
+
|
| 621 |
+
@property
|
| 622 |
+
def rowspan(self):
|
| 623 |
+
"""The rows spanned by this subplot, as a `range` object."""
|
| 624 |
+
ncols = self.get_gridspec().ncols
|
| 625 |
+
return range(self.num1 // ncols, self.num2 // ncols + 1)
|
| 626 |
+
|
| 627 |
+
@property
|
| 628 |
+
def colspan(self):
|
| 629 |
+
"""The columns spanned by this subplot, as a `range` object."""
|
| 630 |
+
ncols = self.get_gridspec().ncols
|
| 631 |
+
# We explicitly support num2 referring to a column on num1's *left*, so
|
| 632 |
+
# we must sort the column indices here so that the range makes sense.
|
| 633 |
+
c1, c2 = sorted([self.num1 % ncols, self.num2 % ncols])
|
| 634 |
+
return range(c1, c2 + 1)
|
| 635 |
+
|
| 636 |
+
def is_first_row(self):
|
| 637 |
+
return self.rowspan.start == 0
|
| 638 |
+
|
| 639 |
+
def is_last_row(self):
|
| 640 |
+
return self.rowspan.stop == self.get_gridspec().nrows
|
| 641 |
+
|
| 642 |
+
def is_first_col(self):
|
| 643 |
+
return self.colspan.start == 0
|
| 644 |
+
|
| 645 |
+
def is_last_col(self):
|
| 646 |
+
return self.colspan.stop == self.get_gridspec().ncols
|
| 647 |
+
|
| 648 |
+
def get_position(self, figure):
|
| 649 |
+
"""
|
| 650 |
+
Update the subplot position from ``figure.subplotpars``.
|
| 651 |
+
"""
|
| 652 |
+
gridspec = self.get_gridspec()
|
| 653 |
+
nrows, ncols = gridspec.get_geometry()
|
| 654 |
+
rows, cols = np.unravel_index([self.num1, self.num2], (nrows, ncols))
|
| 655 |
+
fig_bottoms, fig_tops, fig_lefts, fig_rights = \
|
| 656 |
+
gridspec.get_grid_positions(figure)
|
| 657 |
+
|
| 658 |
+
fig_bottom = fig_bottoms[rows].min()
|
| 659 |
+
fig_top = fig_tops[rows].max()
|
| 660 |
+
fig_left = fig_lefts[cols].min()
|
| 661 |
+
fig_right = fig_rights[cols].max()
|
| 662 |
+
return Bbox.from_extents(fig_left, fig_bottom, fig_right, fig_top)
|
| 663 |
+
|
| 664 |
+
def get_topmost_subplotspec(self):
|
| 665 |
+
"""
|
| 666 |
+
Return the topmost `SubplotSpec` instance associated with the subplot.
|
| 667 |
+
"""
|
| 668 |
+
gridspec = self.get_gridspec()
|
| 669 |
+
if hasattr(gridspec, "get_topmost_subplotspec"):
|
| 670 |
+
return gridspec.get_topmost_subplotspec()
|
| 671 |
+
else:
|
| 672 |
+
return self
|
| 673 |
+
|
| 674 |
+
def __eq__(self, other):
|
| 675 |
+
"""
|
| 676 |
+
Two SubplotSpecs are considered equal if they refer to the same
|
| 677 |
+
position(s) in the same `GridSpec`.
|
| 678 |
+
"""
|
| 679 |
+
# other may not even have the attributes we are checking.
|
| 680 |
+
return ((self._gridspec, self.num1, self.num2)
|
| 681 |
+
== (getattr(other, "_gridspec", object()),
|
| 682 |
+
getattr(other, "num1", object()),
|
| 683 |
+
getattr(other, "num2", object())))
|
| 684 |
+
|
| 685 |
+
def __hash__(self):
|
| 686 |
+
return hash((self._gridspec, self.num1, self.num2))
|
| 687 |
+
|
| 688 |
+
def subgridspec(self, nrows, ncols, **kwargs):
|
| 689 |
+
"""
|
| 690 |
+
Create a GridSpec within this subplot.
|
| 691 |
+
|
| 692 |
+
The created `.GridSpecFromSubplotSpec` will have this `SubplotSpec` as
|
| 693 |
+
a parent.
|
| 694 |
+
|
| 695 |
+
Parameters
|
| 696 |
+
----------
|
| 697 |
+
nrows : int
|
| 698 |
+
Number of rows in grid.
|
| 699 |
+
|
| 700 |
+
ncols : int
|
| 701 |
+
Number of columns in grid.
|
| 702 |
+
|
| 703 |
+
Returns
|
| 704 |
+
-------
|
| 705 |
+
`.GridSpecFromSubplotSpec`
|
| 706 |
+
|
| 707 |
+
Other Parameters
|
| 708 |
+
----------------
|
| 709 |
+
**kwargs
|
| 710 |
+
All other parameters are passed to `.GridSpecFromSubplotSpec`.
|
| 711 |
+
|
| 712 |
+
See Also
|
| 713 |
+
--------
|
| 714 |
+
matplotlib.pyplot.subplots
|
| 715 |
+
|
| 716 |
+
Examples
|
| 717 |
+
--------
|
| 718 |
+
Adding three subplots in the space occupied by a single subplot::
|
| 719 |
+
|
| 720 |
+
fig = plt.figure()
|
| 721 |
+
gs0 = fig.add_gridspec(3, 1)
|
| 722 |
+
ax1 = fig.add_subplot(gs0[0])
|
| 723 |
+
ax2 = fig.add_subplot(gs0[1])
|
| 724 |
+
gssub = gs0[2].subgridspec(1, 3)
|
| 725 |
+
for i in range(3):
|
| 726 |
+
fig.add_subplot(gssub[0, i])
|
| 727 |
+
"""
|
| 728 |
+
return GridSpecFromSubplotSpec(nrows, ncols, self, **kwargs)
|
| 729 |
+
|
| 730 |
+
|
| 731 |
+
class SubplotParams:
|
| 732 |
+
"""
|
| 733 |
+
Parameters defining the positioning of a subplots grid in a figure.
|
| 734 |
+
"""
|
| 735 |
+
|
| 736 |
+
def __init__(self, left=None, bottom=None, right=None, top=None,
|
| 737 |
+
wspace=None, hspace=None):
|
| 738 |
+
"""
|
| 739 |
+
Defaults are given by :rc:`figure.subplot.[name]`.
|
| 740 |
+
|
| 741 |
+
Parameters
|
| 742 |
+
----------
|
| 743 |
+
left : float
|
| 744 |
+
The position of the left edge of the subplots,
|
| 745 |
+
as a fraction of the figure width.
|
| 746 |
+
right : float
|
| 747 |
+
The position of the right edge of the subplots,
|
| 748 |
+
as a fraction of the figure width.
|
| 749 |
+
bottom : float
|
| 750 |
+
The position of the bottom edge of the subplots,
|
| 751 |
+
as a fraction of the figure height.
|
| 752 |
+
top : float
|
| 753 |
+
The position of the top edge of the subplots,
|
| 754 |
+
as a fraction of the figure height.
|
| 755 |
+
wspace : float
|
| 756 |
+
The width of the padding between subplots,
|
| 757 |
+
as a fraction of the average Axes width.
|
| 758 |
+
hspace : float
|
| 759 |
+
The height of the padding between subplots,
|
| 760 |
+
as a fraction of the average Axes height.
|
| 761 |
+
"""
|
| 762 |
+
for key in ["left", "bottom", "right", "top", "wspace", "hspace"]:
|
| 763 |
+
setattr(self, key, mpl.rcParams[f"figure.subplot.{key}"])
|
| 764 |
+
self.update(left, bottom, right, top, wspace, hspace)
|
| 765 |
+
|
| 766 |
+
def update(self, left=None, bottom=None, right=None, top=None,
|
| 767 |
+
wspace=None, hspace=None):
|
| 768 |
+
"""
|
| 769 |
+
Update the dimensions of the passed parameters. *None* means unchanged.
|
| 770 |
+
"""
|
| 771 |
+
if ((left if left is not None else self.left)
|
| 772 |
+
>= (right if right is not None else self.right)):
|
| 773 |
+
raise ValueError('left cannot be >= right')
|
| 774 |
+
if ((bottom if bottom is not None else self.bottom)
|
| 775 |
+
>= (top if top is not None else self.top)):
|
| 776 |
+
raise ValueError('bottom cannot be >= top')
|
| 777 |
+
if left is not None:
|
| 778 |
+
self.left = left
|
| 779 |
+
if right is not None:
|
| 780 |
+
self.right = right
|
| 781 |
+
if bottom is not None:
|
| 782 |
+
self.bottom = bottom
|
| 783 |
+
if top is not None:
|
| 784 |
+
self.top = top
|
| 785 |
+
if wspace is not None:
|
| 786 |
+
self.wspace = wspace
|
| 787 |
+
if hspace is not None:
|
| 788 |
+
self.hspace = hspace
|
llava_video/lib/python3.10/site-packages/matplotlib/inset.py
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
The inset module defines the InsetIndicator class, which draws the rectangle and
|
| 3 |
+
connectors required for `.Axes.indicate_inset` and `.Axes.indicate_inset_zoom`.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from . import _api, artist, transforms
|
| 7 |
+
from matplotlib.patches import ConnectionPatch, PathPatch, Rectangle
|
| 8 |
+
from matplotlib.path import Path
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
_shared_properties = ('alpha', 'edgecolor', 'linestyle', 'linewidth')
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class InsetIndicator(artist.Artist):
|
| 15 |
+
"""
|
| 16 |
+
An artist to highlight an area of interest.
|
| 17 |
+
|
| 18 |
+
An inset indicator is a rectangle on the plot at the position indicated by
|
| 19 |
+
*bounds* that optionally has lines that connect the rectangle to an inset
|
| 20 |
+
Axes (`.Axes.inset_axes`).
|
| 21 |
+
|
| 22 |
+
.. versionadded:: 3.10
|
| 23 |
+
"""
|
| 24 |
+
zorder = 4.99
|
| 25 |
+
|
| 26 |
+
def __init__(self, bounds=None, inset_ax=None, zorder=None, **kwargs):
|
| 27 |
+
"""
|
| 28 |
+
Parameters
|
| 29 |
+
----------
|
| 30 |
+
bounds : [x0, y0, width, height], optional
|
| 31 |
+
Lower-left corner of rectangle to be marked, and its width
|
| 32 |
+
and height. If not set, the bounds will be calculated from the
|
| 33 |
+
data limits of inset_ax, which must be supplied.
|
| 34 |
+
|
| 35 |
+
inset_ax : `~.axes.Axes`, optional
|
| 36 |
+
An optional inset Axes to draw connecting lines to. Two lines are
|
| 37 |
+
drawn connecting the indicator box to the inset Axes on corners
|
| 38 |
+
chosen so as to not overlap with the indicator box.
|
| 39 |
+
|
| 40 |
+
zorder : float, default: 4.99
|
| 41 |
+
Drawing order of the rectangle and connector lines. The default,
|
| 42 |
+
4.99, is just below the default level of inset Axes.
|
| 43 |
+
|
| 44 |
+
**kwargs
|
| 45 |
+
Other keyword arguments are passed on to the `.Rectangle` patch.
|
| 46 |
+
"""
|
| 47 |
+
if bounds is None and inset_ax is None:
|
| 48 |
+
raise ValueError("At least one of bounds or inset_ax must be supplied")
|
| 49 |
+
|
| 50 |
+
self._inset_ax = inset_ax
|
| 51 |
+
|
| 52 |
+
if bounds is None:
|
| 53 |
+
# Work out bounds from inset_ax
|
| 54 |
+
self._auto_update_bounds = True
|
| 55 |
+
bounds = self._bounds_from_inset_ax()
|
| 56 |
+
else:
|
| 57 |
+
self._auto_update_bounds = False
|
| 58 |
+
|
| 59 |
+
x, y, width, height = bounds
|
| 60 |
+
|
| 61 |
+
self._rectangle = Rectangle((x, y), width, height, clip_on=False, **kwargs)
|
| 62 |
+
|
| 63 |
+
# Connector positions cannot be calculated till the artist has been added
|
| 64 |
+
# to an axes, so just make an empty list for now.
|
| 65 |
+
self._connectors = []
|
| 66 |
+
|
| 67 |
+
super().__init__()
|
| 68 |
+
self.set_zorder(zorder)
|
| 69 |
+
|
| 70 |
+
# Initial style properties for the artist should match the rectangle.
|
| 71 |
+
for prop in _shared_properties:
|
| 72 |
+
setattr(self, f'_{prop}', artist.getp(self._rectangle, prop))
|
| 73 |
+
|
| 74 |
+
def _shared_setter(self, prop, val):
|
| 75 |
+
"""
|
| 76 |
+
Helper function to set the same style property on the artist and its children.
|
| 77 |
+
"""
|
| 78 |
+
setattr(self, f'_{prop}', val)
|
| 79 |
+
|
| 80 |
+
artist.setp([self._rectangle, *self._connectors], prop, val)
|
| 81 |
+
|
| 82 |
+
def set_alpha(self, alpha):
|
| 83 |
+
# docstring inherited
|
| 84 |
+
self._shared_setter('alpha', alpha)
|
| 85 |
+
|
| 86 |
+
def set_edgecolor(self, color):
|
| 87 |
+
"""
|
| 88 |
+
Set the edge color of the rectangle and the connectors.
|
| 89 |
+
|
| 90 |
+
Parameters
|
| 91 |
+
----------
|
| 92 |
+
color : :mpltype:`color` or None
|
| 93 |
+
"""
|
| 94 |
+
self._shared_setter('edgecolor', color)
|
| 95 |
+
|
| 96 |
+
def set_color(self, c):
|
| 97 |
+
"""
|
| 98 |
+
Set the edgecolor of the rectangle and the connectors, and the
|
| 99 |
+
facecolor for the rectangle.
|
| 100 |
+
|
| 101 |
+
Parameters
|
| 102 |
+
----------
|
| 103 |
+
c : :mpltype:`color`
|
| 104 |
+
"""
|
| 105 |
+
self._shared_setter('edgecolor', c)
|
| 106 |
+
self._shared_setter('facecolor', c)
|
| 107 |
+
|
| 108 |
+
def set_linewidth(self, w):
|
| 109 |
+
"""
|
| 110 |
+
Set the linewidth in points of the rectangle and the connectors.
|
| 111 |
+
|
| 112 |
+
Parameters
|
| 113 |
+
----------
|
| 114 |
+
w : float or None
|
| 115 |
+
"""
|
| 116 |
+
self._shared_setter('linewidth', w)
|
| 117 |
+
|
| 118 |
+
def set_linestyle(self, ls):
|
| 119 |
+
"""
|
| 120 |
+
Set the linestyle of the rectangle and the connectors.
|
| 121 |
+
|
| 122 |
+
========================================== =================
|
| 123 |
+
linestyle description
|
| 124 |
+
========================================== =================
|
| 125 |
+
``'-'`` or ``'solid'`` solid line
|
| 126 |
+
``'--'`` or ``'dashed'`` dashed line
|
| 127 |
+
``'-.'`` or ``'dashdot'`` dash-dotted line
|
| 128 |
+
``':'`` or ``'dotted'`` dotted line
|
| 129 |
+
``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing
|
| 130 |
+
========================================== =================
|
| 131 |
+
|
| 132 |
+
Alternatively a dash tuple of the following form can be provided::
|
| 133 |
+
|
| 134 |
+
(offset, onoffseq)
|
| 135 |
+
|
| 136 |
+
where ``onoffseq`` is an even length tuple of on and off ink in points.
|
| 137 |
+
|
| 138 |
+
Parameters
|
| 139 |
+
----------
|
| 140 |
+
ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
|
| 141 |
+
The line style.
|
| 142 |
+
"""
|
| 143 |
+
self._shared_setter('linestyle', ls)
|
| 144 |
+
|
| 145 |
+
def _bounds_from_inset_ax(self):
|
| 146 |
+
xlim = self._inset_ax.get_xlim()
|
| 147 |
+
ylim = self._inset_ax.get_ylim()
|
| 148 |
+
return (xlim[0], ylim[0], xlim[1] - xlim[0], ylim[1] - ylim[0])
|
| 149 |
+
|
| 150 |
+
def _update_connectors(self):
|
| 151 |
+
(x, y) = self._rectangle.get_xy()
|
| 152 |
+
width = self._rectangle.get_width()
|
| 153 |
+
height = self._rectangle.get_height()
|
| 154 |
+
|
| 155 |
+
existing_connectors = self._connectors or [None] * 4
|
| 156 |
+
|
| 157 |
+
# connect the inset_axes to the rectangle
|
| 158 |
+
for xy_inset_ax, existing in zip([(0, 0), (0, 1), (1, 0), (1, 1)],
|
| 159 |
+
existing_connectors):
|
| 160 |
+
# inset_ax positions are in axes coordinates
|
| 161 |
+
# The 0, 1 values define the four edges if the inset_ax
|
| 162 |
+
# lower_left, upper_left, lower_right upper_right.
|
| 163 |
+
ex, ey = xy_inset_ax
|
| 164 |
+
if self.axes.xaxis.get_inverted():
|
| 165 |
+
ex = 1 - ex
|
| 166 |
+
if self.axes.yaxis.get_inverted():
|
| 167 |
+
ey = 1 - ey
|
| 168 |
+
xy_data = x + ex * width, y + ey * height
|
| 169 |
+
if existing is None:
|
| 170 |
+
# Create new connection patch with styles inherited from the
|
| 171 |
+
# parent artist.
|
| 172 |
+
p = ConnectionPatch(
|
| 173 |
+
xyA=xy_inset_ax, coordsA=self._inset_ax.transAxes,
|
| 174 |
+
xyB=xy_data, coordsB=self.axes.transData,
|
| 175 |
+
arrowstyle="-",
|
| 176 |
+
edgecolor=self._edgecolor, alpha=self.get_alpha(),
|
| 177 |
+
linestyle=self._linestyle, linewidth=self._linewidth)
|
| 178 |
+
self._connectors.append(p)
|
| 179 |
+
else:
|
| 180 |
+
# Only update positioning of existing connection patch. We
|
| 181 |
+
# do not want to override any style settings made by the user.
|
| 182 |
+
existing.xy1 = xy_inset_ax
|
| 183 |
+
existing.xy2 = xy_data
|
| 184 |
+
existing.coords1 = self._inset_ax.transAxes
|
| 185 |
+
existing.coords2 = self.axes.transData
|
| 186 |
+
|
| 187 |
+
if existing is None:
|
| 188 |
+
# decide which two of the lines to keep visible....
|
| 189 |
+
pos = self._inset_ax.get_position()
|
| 190 |
+
bboxins = pos.transformed(self.get_figure(root=False).transSubfigure)
|
| 191 |
+
rectbbox = transforms.Bbox.from_bounds(x, y, width, height).transformed(
|
| 192 |
+
self._rectangle.get_transform())
|
| 193 |
+
x0 = rectbbox.x0 < bboxins.x0
|
| 194 |
+
x1 = rectbbox.x1 < bboxins.x1
|
| 195 |
+
y0 = rectbbox.y0 < bboxins.y0
|
| 196 |
+
y1 = rectbbox.y1 < bboxins.y1
|
| 197 |
+
self._connectors[0].set_visible(x0 ^ y0)
|
| 198 |
+
self._connectors[1].set_visible(x0 == y1)
|
| 199 |
+
self._connectors[2].set_visible(x1 == y0)
|
| 200 |
+
self._connectors[3].set_visible(x1 ^ y1)
|
| 201 |
+
|
| 202 |
+
@property
|
| 203 |
+
def rectangle(self):
|
| 204 |
+
"""`.Rectangle`: the indicator frame."""
|
| 205 |
+
return self._rectangle
|
| 206 |
+
|
| 207 |
+
@property
|
| 208 |
+
def connectors(self):
|
| 209 |
+
"""
|
| 210 |
+
4-tuple of `.patches.ConnectionPatch` or None
|
| 211 |
+
The four connector lines connecting to (lower_left, upper_left,
|
| 212 |
+
lower_right upper_right) corners of *inset_ax*. Two lines are
|
| 213 |
+
set with visibility to *False*, but the user can set the
|
| 214 |
+
visibility to True if the automatic choice is not deemed correct.
|
| 215 |
+
"""
|
| 216 |
+
if self._inset_ax is None:
|
| 217 |
+
return
|
| 218 |
+
|
| 219 |
+
if self._auto_update_bounds:
|
| 220 |
+
self._rectangle.set_bounds(self._bounds_from_inset_ax())
|
| 221 |
+
self._update_connectors()
|
| 222 |
+
return tuple(self._connectors)
|
| 223 |
+
|
| 224 |
+
def draw(self, renderer):
|
| 225 |
+
# docstring inherited
|
| 226 |
+
conn_same_style = []
|
| 227 |
+
|
| 228 |
+
# Figure out which connectors have the same style as the box, so should
|
| 229 |
+
# be drawn as a single path.
|
| 230 |
+
for conn in self.connectors or []:
|
| 231 |
+
if conn.get_visible():
|
| 232 |
+
drawn = False
|
| 233 |
+
for s in _shared_properties:
|
| 234 |
+
if artist.getp(self._rectangle, s) != artist.getp(conn, s):
|
| 235 |
+
# Draw this connector by itself
|
| 236 |
+
conn.draw(renderer)
|
| 237 |
+
drawn = True
|
| 238 |
+
break
|
| 239 |
+
|
| 240 |
+
if not drawn:
|
| 241 |
+
# Connector has same style as box.
|
| 242 |
+
conn_same_style.append(conn)
|
| 243 |
+
|
| 244 |
+
if conn_same_style:
|
| 245 |
+
# Since at least one connector has the same style as the rectangle, draw
|
| 246 |
+
# them as a compound path.
|
| 247 |
+
artists = [self._rectangle] + conn_same_style
|
| 248 |
+
paths = [a.get_transform().transform_path(a.get_path()) for a in artists]
|
| 249 |
+
path = Path.make_compound_path(*paths)
|
| 250 |
+
|
| 251 |
+
# Create a temporary patch to draw the path.
|
| 252 |
+
p = PathPatch(path)
|
| 253 |
+
p.update_from(self._rectangle)
|
| 254 |
+
p.set_transform(transforms.IdentityTransform())
|
| 255 |
+
p.draw(renderer)
|
| 256 |
+
|
| 257 |
+
return
|
| 258 |
+
|
| 259 |
+
# Just draw the rectangle
|
| 260 |
+
self._rectangle.draw(renderer)
|
| 261 |
+
|
| 262 |
+
@_api.deprecated(
|
| 263 |
+
'3.10',
|
| 264 |
+
message=('Since Matplotlib 3.10 indicate_inset_[zoom] returns a single '
|
| 265 |
+
'InsetIndicator artist with a rectangle property and a connectors '
|
| 266 |
+
'property. From 3.12 it will no longer be possible to unpack the '
|
| 267 |
+
'return value into two elements.'))
|
| 268 |
+
def __getitem__(self, key):
|
| 269 |
+
return [self._rectangle, self.connectors][key]
|
llava_video/lib/python3.10/site-packages/matplotlib/layout_engine.py
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Classes to layout elements in a `.Figure`.
|
| 3 |
+
|
| 4 |
+
Figures have a ``layout_engine`` property that holds a subclass of
|
| 5 |
+
`~.LayoutEngine` defined here (or *None* for no layout). At draw time
|
| 6 |
+
``figure.get_layout_engine().execute()`` is called, the goal of which is
|
| 7 |
+
usually to rearrange Axes on the figure to produce a pleasing layout. This is
|
| 8 |
+
like a ``draw`` callback but with two differences. First, when printing we
|
| 9 |
+
disable the layout engine for the final draw. Second, it is useful to know the
|
| 10 |
+
layout engine while the figure is being created. In particular, colorbars are
|
| 11 |
+
made differently with different layout engines (for historical reasons).
|
| 12 |
+
|
| 13 |
+
Matplotlib supplies two layout engines, `.TightLayoutEngine` and
|
| 14 |
+
`.ConstrainedLayoutEngine`. Third parties can create their own layout engine
|
| 15 |
+
by subclassing `.LayoutEngine`.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
from contextlib import nullcontext
|
| 19 |
+
|
| 20 |
+
import matplotlib as mpl
|
| 21 |
+
|
| 22 |
+
from matplotlib._constrained_layout import do_constrained_layout
|
| 23 |
+
from matplotlib._tight_layout import (get_subplotspec_list,
|
| 24 |
+
get_tight_layout_figure)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
class LayoutEngine:
|
| 28 |
+
"""
|
| 29 |
+
Base class for Matplotlib layout engines.
|
| 30 |
+
|
| 31 |
+
A layout engine can be passed to a figure at instantiation or at any time
|
| 32 |
+
with `~.figure.Figure.set_layout_engine`. Once attached to a figure, the
|
| 33 |
+
layout engine ``execute`` function is called at draw time by
|
| 34 |
+
`~.figure.Figure.draw`, providing a special draw-time hook.
|
| 35 |
+
|
| 36 |
+
.. note::
|
| 37 |
+
|
| 38 |
+
However, note that layout engines affect the creation of colorbars, so
|
| 39 |
+
`~.figure.Figure.set_layout_engine` should be called before any
|
| 40 |
+
colorbars are created.
|
| 41 |
+
|
| 42 |
+
Currently, there are two properties of `LayoutEngine` classes that are
|
| 43 |
+
consulted while manipulating the figure:
|
| 44 |
+
|
| 45 |
+
- ``engine.colorbar_gridspec`` tells `.Figure.colorbar` whether to make the
|
| 46 |
+
axes using the gridspec method (see `.colorbar.make_axes_gridspec`) or
|
| 47 |
+
not (see `.colorbar.make_axes`);
|
| 48 |
+
- ``engine.adjust_compatible`` stops `.Figure.subplots_adjust` from being
|
| 49 |
+
run if it is not compatible with the layout engine.
|
| 50 |
+
|
| 51 |
+
To implement a custom `LayoutEngine`:
|
| 52 |
+
|
| 53 |
+
1. override ``_adjust_compatible`` and ``_colorbar_gridspec``
|
| 54 |
+
2. override `LayoutEngine.set` to update *self._params*
|
| 55 |
+
3. override `LayoutEngine.execute` with your implementation
|
| 56 |
+
|
| 57 |
+
"""
|
| 58 |
+
# override these in subclass
|
| 59 |
+
_adjust_compatible = None
|
| 60 |
+
_colorbar_gridspec = None
|
| 61 |
+
|
| 62 |
+
def __init__(self, **kwargs):
|
| 63 |
+
super().__init__(**kwargs)
|
| 64 |
+
self._params = {}
|
| 65 |
+
|
| 66 |
+
def set(self, **kwargs):
|
| 67 |
+
"""
|
| 68 |
+
Set the parameters for the layout engine.
|
| 69 |
+
"""
|
| 70 |
+
raise NotImplementedError
|
| 71 |
+
|
| 72 |
+
@property
|
| 73 |
+
def colorbar_gridspec(self):
|
| 74 |
+
"""
|
| 75 |
+
Return a boolean if the layout engine creates colorbars using a
|
| 76 |
+
gridspec.
|
| 77 |
+
"""
|
| 78 |
+
if self._colorbar_gridspec is None:
|
| 79 |
+
raise NotImplementedError
|
| 80 |
+
return self._colorbar_gridspec
|
| 81 |
+
|
| 82 |
+
@property
|
| 83 |
+
def adjust_compatible(self):
|
| 84 |
+
"""
|
| 85 |
+
Return a boolean if the layout engine is compatible with
|
| 86 |
+
`~.Figure.subplots_adjust`.
|
| 87 |
+
"""
|
| 88 |
+
if self._adjust_compatible is None:
|
| 89 |
+
raise NotImplementedError
|
| 90 |
+
return self._adjust_compatible
|
| 91 |
+
|
| 92 |
+
def get(self):
|
| 93 |
+
"""
|
| 94 |
+
Return copy of the parameters for the layout engine.
|
| 95 |
+
"""
|
| 96 |
+
return dict(self._params)
|
| 97 |
+
|
| 98 |
+
def execute(self, fig):
|
| 99 |
+
"""
|
| 100 |
+
Execute the layout on the figure given by *fig*.
|
| 101 |
+
"""
|
| 102 |
+
# subclasses must implement this.
|
| 103 |
+
raise NotImplementedError
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class PlaceHolderLayoutEngine(LayoutEngine):
|
| 107 |
+
"""
|
| 108 |
+
This layout engine does not adjust the figure layout at all.
|
| 109 |
+
|
| 110 |
+
The purpose of this `.LayoutEngine` is to act as a placeholder when the user removes
|
| 111 |
+
a layout engine to ensure an incompatible `.LayoutEngine` cannot be set later.
|
| 112 |
+
|
| 113 |
+
Parameters
|
| 114 |
+
----------
|
| 115 |
+
adjust_compatible, colorbar_gridspec : bool
|
| 116 |
+
Allow the PlaceHolderLayoutEngine to mirror the behavior of whatever
|
| 117 |
+
layout engine it is replacing.
|
| 118 |
+
|
| 119 |
+
"""
|
| 120 |
+
def __init__(self, adjust_compatible, colorbar_gridspec, **kwargs):
|
| 121 |
+
self._adjust_compatible = adjust_compatible
|
| 122 |
+
self._colorbar_gridspec = colorbar_gridspec
|
| 123 |
+
super().__init__(**kwargs)
|
| 124 |
+
|
| 125 |
+
def execute(self, fig):
|
| 126 |
+
"""
|
| 127 |
+
Do nothing.
|
| 128 |
+
"""
|
| 129 |
+
return
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
class TightLayoutEngine(LayoutEngine):
|
| 133 |
+
"""
|
| 134 |
+
Implements the ``tight_layout`` geometry management. See
|
| 135 |
+
:ref:`tight_layout_guide` for details.
|
| 136 |
+
"""
|
| 137 |
+
_adjust_compatible = True
|
| 138 |
+
_colorbar_gridspec = True
|
| 139 |
+
|
| 140 |
+
def __init__(self, *, pad=1.08, h_pad=None, w_pad=None,
|
| 141 |
+
rect=(0, 0, 1, 1), **kwargs):
|
| 142 |
+
"""
|
| 143 |
+
Initialize tight_layout engine.
|
| 144 |
+
|
| 145 |
+
Parameters
|
| 146 |
+
----------
|
| 147 |
+
pad : float, default: 1.08
|
| 148 |
+
Padding between the figure edge and the edges of subplots, as a
|
| 149 |
+
fraction of the font size.
|
| 150 |
+
h_pad, w_pad : float
|
| 151 |
+
Padding (height/width) between edges of adjacent subplots.
|
| 152 |
+
Defaults to *pad*.
|
| 153 |
+
rect : tuple (left, bottom, right, top), default: (0, 0, 1, 1).
|
| 154 |
+
rectangle in normalized figure coordinates that the subplots
|
| 155 |
+
(including labels) will fit into.
|
| 156 |
+
"""
|
| 157 |
+
super().__init__(**kwargs)
|
| 158 |
+
for td in ['pad', 'h_pad', 'w_pad', 'rect']:
|
| 159 |
+
# initialize these in case None is passed in above:
|
| 160 |
+
self._params[td] = None
|
| 161 |
+
self.set(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
|
| 162 |
+
|
| 163 |
+
def execute(self, fig):
|
| 164 |
+
"""
|
| 165 |
+
Execute tight_layout.
|
| 166 |
+
|
| 167 |
+
This decides the subplot parameters given the padding that
|
| 168 |
+
will allow the Axes labels to not be covered by other labels
|
| 169 |
+
and Axes.
|
| 170 |
+
|
| 171 |
+
Parameters
|
| 172 |
+
----------
|
| 173 |
+
fig : `.Figure` to perform layout on.
|
| 174 |
+
|
| 175 |
+
See Also
|
| 176 |
+
--------
|
| 177 |
+
.figure.Figure.tight_layout
|
| 178 |
+
.pyplot.tight_layout
|
| 179 |
+
"""
|
| 180 |
+
info = self._params
|
| 181 |
+
renderer = fig._get_renderer()
|
| 182 |
+
with getattr(renderer, "_draw_disabled", nullcontext)():
|
| 183 |
+
kwargs = get_tight_layout_figure(
|
| 184 |
+
fig, fig.axes, get_subplotspec_list(fig.axes), renderer,
|
| 185 |
+
pad=info['pad'], h_pad=info['h_pad'], w_pad=info['w_pad'],
|
| 186 |
+
rect=info['rect'])
|
| 187 |
+
if kwargs:
|
| 188 |
+
fig.subplots_adjust(**kwargs)
|
| 189 |
+
|
| 190 |
+
def set(self, *, pad=None, w_pad=None, h_pad=None, rect=None):
|
| 191 |
+
"""
|
| 192 |
+
Set the pads for tight_layout.
|
| 193 |
+
|
| 194 |
+
Parameters
|
| 195 |
+
----------
|
| 196 |
+
pad : float
|
| 197 |
+
Padding between the figure edge and the edges of subplots, as a
|
| 198 |
+
fraction of the font size.
|
| 199 |
+
w_pad, h_pad : float
|
| 200 |
+
Padding (width/height) between edges of adjacent subplots.
|
| 201 |
+
Defaults to *pad*.
|
| 202 |
+
rect : tuple (left, bottom, right, top)
|
| 203 |
+
rectangle in normalized figure coordinates that the subplots
|
| 204 |
+
(including labels) will fit into.
|
| 205 |
+
"""
|
| 206 |
+
for td in self.set.__kwdefaults__:
|
| 207 |
+
if locals()[td] is not None:
|
| 208 |
+
self._params[td] = locals()[td]
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
class ConstrainedLayoutEngine(LayoutEngine):
|
| 212 |
+
"""
|
| 213 |
+
Implements the ``constrained_layout`` geometry management. See
|
| 214 |
+
:ref:`constrainedlayout_guide` for details.
|
| 215 |
+
"""
|
| 216 |
+
|
| 217 |
+
_adjust_compatible = False
|
| 218 |
+
_colorbar_gridspec = False
|
| 219 |
+
|
| 220 |
+
def __init__(self, *, h_pad=None, w_pad=None,
|
| 221 |
+
hspace=None, wspace=None, rect=(0, 0, 1, 1),
|
| 222 |
+
compress=False, **kwargs):
|
| 223 |
+
"""
|
| 224 |
+
Initialize ``constrained_layout`` settings.
|
| 225 |
+
|
| 226 |
+
Parameters
|
| 227 |
+
----------
|
| 228 |
+
h_pad, w_pad : float
|
| 229 |
+
Padding around the Axes elements in inches.
|
| 230 |
+
Default to :rc:`figure.constrained_layout.h_pad` and
|
| 231 |
+
:rc:`figure.constrained_layout.w_pad`.
|
| 232 |
+
hspace, wspace : float
|
| 233 |
+
Fraction of the figure to dedicate to space between the
|
| 234 |
+
axes. These are evenly spread between the gaps between the Axes.
|
| 235 |
+
A value of 0.2 for a three-column layout would have a space
|
| 236 |
+
of 0.1 of the figure width between each column.
|
| 237 |
+
If h/wspace < h/w_pad, then the pads are used instead.
|
| 238 |
+
Default to :rc:`figure.constrained_layout.hspace` and
|
| 239 |
+
:rc:`figure.constrained_layout.wspace`.
|
| 240 |
+
rect : tuple of 4 floats
|
| 241 |
+
Rectangle in figure coordinates to perform constrained layout in
|
| 242 |
+
(left, bottom, width, height), each from 0-1.
|
| 243 |
+
compress : bool
|
| 244 |
+
Whether to shift Axes so that white space in between them is
|
| 245 |
+
removed. This is useful for simple grids of fixed-aspect Axes (e.g.
|
| 246 |
+
a grid of images). See :ref:`compressed_layout`.
|
| 247 |
+
"""
|
| 248 |
+
super().__init__(**kwargs)
|
| 249 |
+
# set the defaults:
|
| 250 |
+
self.set(w_pad=mpl.rcParams['figure.constrained_layout.w_pad'],
|
| 251 |
+
h_pad=mpl.rcParams['figure.constrained_layout.h_pad'],
|
| 252 |
+
wspace=mpl.rcParams['figure.constrained_layout.wspace'],
|
| 253 |
+
hspace=mpl.rcParams['figure.constrained_layout.hspace'],
|
| 254 |
+
rect=(0, 0, 1, 1))
|
| 255 |
+
# set anything that was passed in (None will be ignored):
|
| 256 |
+
self.set(w_pad=w_pad, h_pad=h_pad, wspace=wspace, hspace=hspace,
|
| 257 |
+
rect=rect)
|
| 258 |
+
self._compress = compress
|
| 259 |
+
|
| 260 |
+
def execute(self, fig):
|
| 261 |
+
"""
|
| 262 |
+
Perform constrained_layout and move and resize Axes accordingly.
|
| 263 |
+
|
| 264 |
+
Parameters
|
| 265 |
+
----------
|
| 266 |
+
fig : `.Figure` to perform layout on.
|
| 267 |
+
"""
|
| 268 |
+
width, height = fig.get_size_inches()
|
| 269 |
+
# pads are relative to the current state of the figure...
|
| 270 |
+
w_pad = self._params['w_pad'] / width
|
| 271 |
+
h_pad = self._params['h_pad'] / height
|
| 272 |
+
|
| 273 |
+
return do_constrained_layout(fig, w_pad=w_pad, h_pad=h_pad,
|
| 274 |
+
wspace=self._params['wspace'],
|
| 275 |
+
hspace=self._params['hspace'],
|
| 276 |
+
rect=self._params['rect'],
|
| 277 |
+
compress=self._compress)
|
| 278 |
+
|
| 279 |
+
def set(self, *, h_pad=None, w_pad=None,
|
| 280 |
+
hspace=None, wspace=None, rect=None):
|
| 281 |
+
"""
|
| 282 |
+
Set the pads for constrained_layout.
|
| 283 |
+
|
| 284 |
+
Parameters
|
| 285 |
+
----------
|
| 286 |
+
h_pad, w_pad : float
|
| 287 |
+
Padding around the Axes elements in inches.
|
| 288 |
+
Default to :rc:`figure.constrained_layout.h_pad` and
|
| 289 |
+
:rc:`figure.constrained_layout.w_pad`.
|
| 290 |
+
hspace, wspace : float
|
| 291 |
+
Fraction of the figure to dedicate to space between the
|
| 292 |
+
axes. These are evenly spread between the gaps between the Axes.
|
| 293 |
+
A value of 0.2 for a three-column layout would have a space
|
| 294 |
+
of 0.1 of the figure width between each column.
|
| 295 |
+
If h/wspace < h/w_pad, then the pads are used instead.
|
| 296 |
+
Default to :rc:`figure.constrained_layout.hspace` and
|
| 297 |
+
:rc:`figure.constrained_layout.wspace`.
|
| 298 |
+
rect : tuple of 4 floats
|
| 299 |
+
Rectangle in figure coordinates to perform constrained layout in
|
| 300 |
+
(left, bottom, width, height), each from 0-1.
|
| 301 |
+
"""
|
| 302 |
+
for td in self.set.__kwdefaults__:
|
| 303 |
+
if locals()[td] is not None:
|
| 304 |
+
self._params[td] = locals()[td]
|
llava_video/lib/python3.10/site-packages/matplotlib/legend.py
ADDED
|
@@ -0,0 +1,1370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
The legend module defines the Legend class, which is responsible for
|
| 3 |
+
drawing legends associated with Axes and/or figures.
|
| 4 |
+
|
| 5 |
+
.. important::
|
| 6 |
+
|
| 7 |
+
It is unlikely that you would ever create a Legend instance manually.
|
| 8 |
+
Most users would normally create a legend via the `~.Axes.legend`
|
| 9 |
+
function. For more details on legends there is also a :ref:`legend guide
|
| 10 |
+
<legend_guide>`.
|
| 11 |
+
|
| 12 |
+
The `Legend` class is a container of legend handles and legend texts.
|
| 13 |
+
|
| 14 |
+
The legend handler map specifies how to create legend handles from artists
|
| 15 |
+
(lines, patches, etc.) in the Axes or figures. Default legend handlers are
|
| 16 |
+
defined in the :mod:`~matplotlib.legend_handler` module. While not all artist
|
| 17 |
+
types are covered by the default legend handlers, custom legend handlers can be
|
| 18 |
+
defined to support arbitrary objects.
|
| 19 |
+
|
| 20 |
+
See the :ref`<legend_guide>` for more
|
| 21 |
+
information.
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
import itertools
|
| 25 |
+
import logging
|
| 26 |
+
import numbers
|
| 27 |
+
import time
|
| 28 |
+
|
| 29 |
+
import numpy as np
|
| 30 |
+
|
| 31 |
+
import matplotlib as mpl
|
| 32 |
+
from matplotlib import _api, _docstring, cbook, colors, offsetbox
|
| 33 |
+
from matplotlib.artist import Artist, allow_rasterization
|
| 34 |
+
from matplotlib.cbook import silent_list
|
| 35 |
+
from matplotlib.font_manager import FontProperties
|
| 36 |
+
from matplotlib.lines import Line2D
|
| 37 |
+
from matplotlib.patches import (Patch, Rectangle, Shadow, FancyBboxPatch,
|
| 38 |
+
StepPatch)
|
| 39 |
+
from matplotlib.collections import (
|
| 40 |
+
Collection, CircleCollection, LineCollection, PathCollection,
|
| 41 |
+
PolyCollection, RegularPolyCollection)
|
| 42 |
+
from matplotlib.text import Text
|
| 43 |
+
from matplotlib.transforms import Bbox, BboxBase, TransformedBbox
|
| 44 |
+
from matplotlib.transforms import BboxTransformTo, BboxTransformFrom
|
| 45 |
+
from matplotlib.offsetbox import (
|
| 46 |
+
AnchoredOffsetbox, DraggableOffsetBox,
|
| 47 |
+
HPacker, VPacker,
|
| 48 |
+
DrawingArea, TextArea,
|
| 49 |
+
)
|
| 50 |
+
from matplotlib.container import ErrorbarContainer, BarContainer, StemContainer
|
| 51 |
+
from . import legend_handler
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
class DraggableLegend(DraggableOffsetBox):
|
| 55 |
+
def __init__(self, legend, use_blit=False, update="loc"):
|
| 56 |
+
"""
|
| 57 |
+
Wrapper around a `.Legend` to support mouse dragging.
|
| 58 |
+
|
| 59 |
+
Parameters
|
| 60 |
+
----------
|
| 61 |
+
legend : `.Legend`
|
| 62 |
+
The `.Legend` instance to wrap.
|
| 63 |
+
use_blit : bool, optional
|
| 64 |
+
Use blitting for faster image composition. For details see
|
| 65 |
+
:ref:`func-animation`.
|
| 66 |
+
update : {'loc', 'bbox'}, optional
|
| 67 |
+
If "loc", update the *loc* parameter of the legend upon finalizing.
|
| 68 |
+
If "bbox", update the *bbox_to_anchor* parameter.
|
| 69 |
+
"""
|
| 70 |
+
self.legend = legend
|
| 71 |
+
|
| 72 |
+
_api.check_in_list(["loc", "bbox"], update=update)
|
| 73 |
+
self._update = update
|
| 74 |
+
|
| 75 |
+
super().__init__(legend, legend._legend_box, use_blit=use_blit)
|
| 76 |
+
|
| 77 |
+
def finalize_offset(self):
|
| 78 |
+
if self._update == "loc":
|
| 79 |
+
self._update_loc(self.get_loc_in_canvas())
|
| 80 |
+
elif self._update == "bbox":
|
| 81 |
+
self._update_bbox_to_anchor(self.get_loc_in_canvas())
|
| 82 |
+
|
| 83 |
+
def _update_loc(self, loc_in_canvas):
|
| 84 |
+
bbox = self.legend.get_bbox_to_anchor()
|
| 85 |
+
# if bbox has zero width or height, the transformation is
|
| 86 |
+
# ill-defined. Fall back to the default bbox_to_anchor.
|
| 87 |
+
if bbox.width == 0 or bbox.height == 0:
|
| 88 |
+
self.legend.set_bbox_to_anchor(None)
|
| 89 |
+
bbox = self.legend.get_bbox_to_anchor()
|
| 90 |
+
_bbox_transform = BboxTransformFrom(bbox)
|
| 91 |
+
self.legend._loc = tuple(_bbox_transform.transform(loc_in_canvas))
|
| 92 |
+
|
| 93 |
+
def _update_bbox_to_anchor(self, loc_in_canvas):
|
| 94 |
+
loc_in_bbox = self.legend.axes.transAxes.transform(loc_in_canvas)
|
| 95 |
+
self.legend.set_bbox_to_anchor(loc_in_bbox)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
_legend_kw_doc_base = """
|
| 99 |
+
bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
|
| 100 |
+
Box that is used to position the legend in conjunction with *loc*.
|
| 101 |
+
Defaults to ``axes.bbox`` (if called as a method to `.Axes.legend`) or
|
| 102 |
+
``figure.bbox`` (if ``figure.legend``). This argument allows arbitrary
|
| 103 |
+
placement of the legend.
|
| 104 |
+
|
| 105 |
+
Bbox coordinates are interpreted in the coordinate system given by
|
| 106 |
+
*bbox_transform*, with the default transform
|
| 107 |
+
Axes or Figure coordinates, depending on which ``legend`` is called.
|
| 108 |
+
|
| 109 |
+
If a 4-tuple or `.BboxBase` is given, then it specifies the bbox
|
| 110 |
+
``(x, y, width, height)`` that the legend is placed in.
|
| 111 |
+
To put the legend in the best location in the bottom right
|
| 112 |
+
quadrant of the Axes (or figure)::
|
| 113 |
+
|
| 114 |
+
loc='best', bbox_to_anchor=(0.5, 0., 0.5, 0.5)
|
| 115 |
+
|
| 116 |
+
A 2-tuple ``(x, y)`` places the corner of the legend specified by *loc* at
|
| 117 |
+
x, y. For example, to put the legend's upper right-hand corner in the
|
| 118 |
+
center of the Axes (or figure) the following keywords can be used::
|
| 119 |
+
|
| 120 |
+
loc='upper right', bbox_to_anchor=(0.5, 0.5)
|
| 121 |
+
|
| 122 |
+
ncols : int, default: 1
|
| 123 |
+
The number of columns that the legend has.
|
| 124 |
+
|
| 125 |
+
For backward compatibility, the spelling *ncol* is also supported
|
| 126 |
+
but it is discouraged. If both are given, *ncols* takes precedence.
|
| 127 |
+
|
| 128 |
+
prop : None or `~matplotlib.font_manager.FontProperties` or dict
|
| 129 |
+
The font properties of the legend. If None (default), the current
|
| 130 |
+
:data:`matplotlib.rcParams` will be used.
|
| 131 |
+
|
| 132 |
+
fontsize : int or {'xx-small', 'x-small', 'small', 'medium', 'large', \
|
| 133 |
+
'x-large', 'xx-large'}
|
| 134 |
+
The font size of the legend. If the value is numeric the size will be the
|
| 135 |
+
absolute font size in points. String values are relative to the current
|
| 136 |
+
default font size. This argument is only used if *prop* is not specified.
|
| 137 |
+
|
| 138 |
+
labelcolor : str or list, default: :rc:`legend.labelcolor`
|
| 139 |
+
The color of the text in the legend. Either a valid color string
|
| 140 |
+
(for example, 'red'), or a list of color strings. The labelcolor can
|
| 141 |
+
also be made to match the color of the line or marker using 'linecolor',
|
| 142 |
+
'markerfacecolor' (or 'mfc'), or 'markeredgecolor' (or 'mec').
|
| 143 |
+
|
| 144 |
+
Labelcolor can be set globally using :rc:`legend.labelcolor`. If None,
|
| 145 |
+
use :rc:`text.color`.
|
| 146 |
+
|
| 147 |
+
numpoints : int, default: :rc:`legend.numpoints`
|
| 148 |
+
The number of marker points in the legend when creating a legend
|
| 149 |
+
entry for a `.Line2D` (line).
|
| 150 |
+
|
| 151 |
+
scatterpoints : int, default: :rc:`legend.scatterpoints`
|
| 152 |
+
The number of marker points in the legend when creating
|
| 153 |
+
a legend entry for a `.PathCollection` (scatter plot).
|
| 154 |
+
|
| 155 |
+
scatteryoffsets : iterable of floats, default: ``[0.375, 0.5, 0.3125]``
|
| 156 |
+
The vertical offset (relative to the font size) for the markers
|
| 157 |
+
created for a scatter plot legend entry. 0.0 is at the base the
|
| 158 |
+
legend text, and 1.0 is at the top. To draw all markers at the
|
| 159 |
+
same height, set to ``[0.5]``.
|
| 160 |
+
|
| 161 |
+
markerscale : float, default: :rc:`legend.markerscale`
|
| 162 |
+
The relative size of legend markers compared to the originally drawn ones.
|
| 163 |
+
|
| 164 |
+
markerfirst : bool, default: True
|
| 165 |
+
If *True*, legend marker is placed to the left of the legend label.
|
| 166 |
+
If *False*, legend marker is placed to the right of the legend label.
|
| 167 |
+
|
| 168 |
+
reverse : bool, default: False
|
| 169 |
+
If *True*, the legend labels are displayed in reverse order from the input.
|
| 170 |
+
If *False*, the legend labels are displayed in the same order as the input.
|
| 171 |
+
|
| 172 |
+
.. versionadded:: 3.7
|
| 173 |
+
|
| 174 |
+
frameon : bool, default: :rc:`legend.frameon`
|
| 175 |
+
Whether the legend should be drawn on a patch (frame).
|
| 176 |
+
|
| 177 |
+
fancybox : bool, default: :rc:`legend.fancybox`
|
| 178 |
+
Whether round edges should be enabled around the `.FancyBboxPatch` which
|
| 179 |
+
makes up the legend's background.
|
| 180 |
+
|
| 181 |
+
shadow : None, bool or dict, default: :rc:`legend.shadow`
|
| 182 |
+
Whether to draw a shadow behind the legend.
|
| 183 |
+
The shadow can be configured using `.Patch` keywords.
|
| 184 |
+
Customization via :rc:`legend.shadow` is currently not supported.
|
| 185 |
+
|
| 186 |
+
framealpha : float, default: :rc:`legend.framealpha`
|
| 187 |
+
The alpha transparency of the legend's background.
|
| 188 |
+
If *shadow* is activated and *framealpha* is ``None``, the default value is
|
| 189 |
+
ignored.
|
| 190 |
+
|
| 191 |
+
facecolor : "inherit" or color, default: :rc:`legend.facecolor`
|
| 192 |
+
The legend's background color.
|
| 193 |
+
If ``"inherit"``, use :rc:`axes.facecolor`.
|
| 194 |
+
|
| 195 |
+
edgecolor : "inherit" or color, default: :rc:`legend.edgecolor`
|
| 196 |
+
The legend's background patch edge color.
|
| 197 |
+
If ``"inherit"``, use :rc:`axes.edgecolor`.
|
| 198 |
+
|
| 199 |
+
mode : {"expand", None}
|
| 200 |
+
If *mode* is set to ``"expand"`` the legend will be horizontally
|
| 201 |
+
expanded to fill the Axes area (or *bbox_to_anchor* if defines
|
| 202 |
+
the legend's size).
|
| 203 |
+
|
| 204 |
+
bbox_transform : None or `~matplotlib.transforms.Transform`
|
| 205 |
+
The transform for the bounding box (*bbox_to_anchor*). For a value
|
| 206 |
+
of ``None`` (default) the Axes'
|
| 207 |
+
:data:`~matplotlib.axes.Axes.transAxes` transform will be used.
|
| 208 |
+
|
| 209 |
+
title : str or None
|
| 210 |
+
The legend's title. Default is no title (``None``).
|
| 211 |
+
|
| 212 |
+
title_fontproperties : None or `~matplotlib.font_manager.FontProperties` or dict
|
| 213 |
+
The font properties of the legend's title. If None (default), the
|
| 214 |
+
*title_fontsize* argument will be used if present; if *title_fontsize* is
|
| 215 |
+
also None, the current :rc:`legend.title_fontsize` will be used.
|
| 216 |
+
|
| 217 |
+
title_fontsize : int or {'xx-small', 'x-small', 'small', 'medium', 'large', \
|
| 218 |
+
'x-large', 'xx-large'}, default: :rc:`legend.title_fontsize`
|
| 219 |
+
The font size of the legend's title.
|
| 220 |
+
Note: This cannot be combined with *title_fontproperties*. If you want
|
| 221 |
+
to set the fontsize alongside other font properties, use the *size*
|
| 222 |
+
parameter in *title_fontproperties*.
|
| 223 |
+
|
| 224 |
+
alignment : {'center', 'left', 'right'}, default: 'center'
|
| 225 |
+
The alignment of the legend title and the box of entries. The entries
|
| 226 |
+
are aligned as a single block, so that markers always lined up.
|
| 227 |
+
|
| 228 |
+
borderpad : float, default: :rc:`legend.borderpad`
|
| 229 |
+
The fractional whitespace inside the legend border, in font-size units.
|
| 230 |
+
|
| 231 |
+
labelspacing : float, default: :rc:`legend.labelspacing`
|
| 232 |
+
The vertical space between the legend entries, in font-size units.
|
| 233 |
+
|
| 234 |
+
handlelength : float, default: :rc:`legend.handlelength`
|
| 235 |
+
The length of the legend handles, in font-size units.
|
| 236 |
+
|
| 237 |
+
handleheight : float, default: :rc:`legend.handleheight`
|
| 238 |
+
The height of the legend handles, in font-size units.
|
| 239 |
+
|
| 240 |
+
handletextpad : float, default: :rc:`legend.handletextpad`
|
| 241 |
+
The pad between the legend handle and text, in font-size units.
|
| 242 |
+
|
| 243 |
+
borderaxespad : float, default: :rc:`legend.borderaxespad`
|
| 244 |
+
The pad between the Axes and legend border, in font-size units.
|
| 245 |
+
|
| 246 |
+
columnspacing : float, default: :rc:`legend.columnspacing`
|
| 247 |
+
The spacing between columns, in font-size units.
|
| 248 |
+
|
| 249 |
+
handler_map : dict or None
|
| 250 |
+
The custom dictionary mapping instances or types to a legend
|
| 251 |
+
handler. This *handler_map* updates the default handler map
|
| 252 |
+
found at `matplotlib.legend.Legend.get_legend_handler_map`.
|
| 253 |
+
|
| 254 |
+
draggable : bool, default: False
|
| 255 |
+
Whether the legend can be dragged with the mouse.
|
| 256 |
+
"""
|
| 257 |
+
|
| 258 |
+
_loc_doc_base = """
|
| 259 |
+
loc : str or pair of floats, default: {default}
|
| 260 |
+
The location of the legend.
|
| 261 |
+
|
| 262 |
+
The strings ``'upper left'``, ``'upper right'``, ``'lower left'``,
|
| 263 |
+
``'lower right'`` place the legend at the corresponding corner of the
|
| 264 |
+
{parent}.
|
| 265 |
+
|
| 266 |
+
The strings ``'upper center'``, ``'lower center'``, ``'center left'``,
|
| 267 |
+
``'center right'`` place the legend at the center of the corresponding edge
|
| 268 |
+
of the {parent}.
|
| 269 |
+
|
| 270 |
+
The string ``'center'`` places the legend at the center of the {parent}.
|
| 271 |
+
{best}
|
| 272 |
+
The location can also be a 2-tuple giving the coordinates of the lower-left
|
| 273 |
+
corner of the legend in {parent} coordinates (in which case *bbox_to_anchor*
|
| 274 |
+
will be ignored).
|
| 275 |
+
|
| 276 |
+
For back-compatibility, ``'center right'`` (but no other location) can also
|
| 277 |
+
be spelled ``'right'``, and each "string" location can also be given as a
|
| 278 |
+
numeric value:
|
| 279 |
+
|
| 280 |
+
================== =============
|
| 281 |
+
Location String Location Code
|
| 282 |
+
================== =============
|
| 283 |
+
'best' (Axes only) 0
|
| 284 |
+
'upper right' 1
|
| 285 |
+
'upper left' 2
|
| 286 |
+
'lower left' 3
|
| 287 |
+
'lower right' 4
|
| 288 |
+
'right' 5
|
| 289 |
+
'center left' 6
|
| 290 |
+
'center right' 7
|
| 291 |
+
'lower center' 8
|
| 292 |
+
'upper center' 9
|
| 293 |
+
'center' 10
|
| 294 |
+
================== =============
|
| 295 |
+
{outside}"""
|
| 296 |
+
|
| 297 |
+
_loc_doc_best = """
|
| 298 |
+
The string ``'best'`` places the legend at the location, among the nine
|
| 299 |
+
locations defined so far, with the minimum overlap with other drawn
|
| 300 |
+
artists. This option can be quite slow for plots with large amounts of
|
| 301 |
+
data; your plotting speed may benefit from providing a specific location.
|
| 302 |
+
"""
|
| 303 |
+
|
| 304 |
+
_legend_kw_axes_st = (
|
| 305 |
+
_loc_doc_base.format(parent='axes', default=':rc:`legend.loc`',
|
| 306 |
+
best=_loc_doc_best, outside='') +
|
| 307 |
+
_legend_kw_doc_base)
|
| 308 |
+
_docstring.interpd.register(_legend_kw_axes=_legend_kw_axes_st)
|
| 309 |
+
|
| 310 |
+
_outside_doc = """
|
| 311 |
+
If a figure is using the constrained layout manager, the string codes
|
| 312 |
+
of the *loc* keyword argument can get better layout behaviour using the
|
| 313 |
+
prefix 'outside'. There is ambiguity at the corners, so 'outside
|
| 314 |
+
upper right' will make space for the legend above the rest of the
|
| 315 |
+
axes in the layout, and 'outside right upper' will make space on the
|
| 316 |
+
right side of the layout. In addition to the values of *loc*
|
| 317 |
+
listed above, we have 'outside right upper', 'outside right lower',
|
| 318 |
+
'outside left upper', and 'outside left lower'. See
|
| 319 |
+
:ref:`legend_guide` for more details.
|
| 320 |
+
"""
|
| 321 |
+
|
| 322 |
+
_legend_kw_figure_st = (
|
| 323 |
+
_loc_doc_base.format(parent='figure', default="'upper right'",
|
| 324 |
+
best='', outside=_outside_doc) +
|
| 325 |
+
_legend_kw_doc_base)
|
| 326 |
+
_docstring.interpd.register(_legend_kw_figure=_legend_kw_figure_st)
|
| 327 |
+
|
| 328 |
+
_legend_kw_both_st = (
|
| 329 |
+
_loc_doc_base.format(parent='axes/figure',
|
| 330 |
+
default=":rc:`legend.loc` for Axes, 'upper right' for Figure",
|
| 331 |
+
best=_loc_doc_best, outside=_outside_doc) +
|
| 332 |
+
_legend_kw_doc_base)
|
| 333 |
+
_docstring.interpd.register(_legend_kw_doc=_legend_kw_both_st)
|
| 334 |
+
|
| 335 |
+
_legend_kw_set_loc_st = (
|
| 336 |
+
_loc_doc_base.format(parent='axes/figure',
|
| 337 |
+
default=":rc:`legend.loc` for Axes, 'upper right' for Figure",
|
| 338 |
+
best=_loc_doc_best, outside=_outside_doc))
|
| 339 |
+
_docstring.interpd.register(_legend_kw_set_loc_doc=_legend_kw_set_loc_st)
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
class Legend(Artist):
|
| 343 |
+
"""
|
| 344 |
+
Place a legend on the figure/axes.
|
| 345 |
+
"""
|
| 346 |
+
|
| 347 |
+
# 'best' is only implemented for Axes legends
|
| 348 |
+
codes = {'best': 0, **AnchoredOffsetbox.codes}
|
| 349 |
+
zorder = 5
|
| 350 |
+
|
| 351 |
+
def __str__(self):
|
| 352 |
+
return "Legend"
|
| 353 |
+
|
| 354 |
+
@_docstring.interpd
|
| 355 |
+
def __init__(
|
| 356 |
+
self, parent, handles, labels,
|
| 357 |
+
*,
|
| 358 |
+
loc=None,
|
| 359 |
+
numpoints=None, # number of points in the legend line
|
| 360 |
+
markerscale=None, # relative size of legend markers vs. original
|
| 361 |
+
markerfirst=True, # left/right ordering of legend marker and label
|
| 362 |
+
reverse=False, # reverse ordering of legend marker and label
|
| 363 |
+
scatterpoints=None, # number of scatter points
|
| 364 |
+
scatteryoffsets=None,
|
| 365 |
+
prop=None, # properties for the legend texts
|
| 366 |
+
fontsize=None, # keyword to set font size directly
|
| 367 |
+
labelcolor=None, # keyword to set the text color
|
| 368 |
+
|
| 369 |
+
# spacing & pad defined as a fraction of the font-size
|
| 370 |
+
borderpad=None, # whitespace inside the legend border
|
| 371 |
+
labelspacing=None, # vertical space between the legend entries
|
| 372 |
+
handlelength=None, # length of the legend handles
|
| 373 |
+
handleheight=None, # height of the legend handles
|
| 374 |
+
handletextpad=None, # pad between the legend handle and text
|
| 375 |
+
borderaxespad=None, # pad between the Axes and legend border
|
| 376 |
+
columnspacing=None, # spacing between columns
|
| 377 |
+
|
| 378 |
+
ncols=1, # number of columns
|
| 379 |
+
mode=None, # horizontal distribution of columns: None or "expand"
|
| 380 |
+
|
| 381 |
+
fancybox=None, # True: fancy box, False: rounded box, None: rcParam
|
| 382 |
+
shadow=None,
|
| 383 |
+
title=None, # legend title
|
| 384 |
+
title_fontsize=None, # legend title font size
|
| 385 |
+
framealpha=None, # set frame alpha
|
| 386 |
+
edgecolor=None, # frame patch edgecolor
|
| 387 |
+
facecolor=None, # frame patch facecolor
|
| 388 |
+
|
| 389 |
+
bbox_to_anchor=None, # bbox to which the legend will be anchored
|
| 390 |
+
bbox_transform=None, # transform for the bbox
|
| 391 |
+
frameon=None, # draw frame
|
| 392 |
+
handler_map=None,
|
| 393 |
+
title_fontproperties=None, # properties for the legend title
|
| 394 |
+
alignment="center", # control the alignment within the legend box
|
| 395 |
+
ncol=1, # synonym for ncols (backward compatibility)
|
| 396 |
+
draggable=False # whether the legend can be dragged with the mouse
|
| 397 |
+
):
|
| 398 |
+
"""
|
| 399 |
+
Parameters
|
| 400 |
+
----------
|
| 401 |
+
parent : `~matplotlib.axes.Axes` or `.Figure`
|
| 402 |
+
The artist that contains the legend.
|
| 403 |
+
|
| 404 |
+
handles : list of (`.Artist` or tuple of `.Artist`)
|
| 405 |
+
A list of Artists (lines, patches) to be added to the legend.
|
| 406 |
+
|
| 407 |
+
labels : list of str
|
| 408 |
+
A list of labels to show next to the artists. The length of handles
|
| 409 |
+
and labels should be the same. If they are not, they are truncated
|
| 410 |
+
to the length of the shorter list.
|
| 411 |
+
|
| 412 |
+
Other Parameters
|
| 413 |
+
----------------
|
| 414 |
+
%(_legend_kw_doc)s
|
| 415 |
+
|
| 416 |
+
Attributes
|
| 417 |
+
----------
|
| 418 |
+
legend_handles
|
| 419 |
+
List of `.Artist` objects added as legend entries.
|
| 420 |
+
|
| 421 |
+
.. versionadded:: 3.7
|
| 422 |
+
"""
|
| 423 |
+
# local import only to avoid circularity
|
| 424 |
+
from matplotlib.axes import Axes
|
| 425 |
+
from matplotlib.figure import FigureBase
|
| 426 |
+
|
| 427 |
+
super().__init__()
|
| 428 |
+
|
| 429 |
+
if prop is None:
|
| 430 |
+
self.prop = FontProperties(size=mpl._val_or_rc(fontsize, "legend.fontsize"))
|
| 431 |
+
else:
|
| 432 |
+
self.prop = FontProperties._from_any(prop)
|
| 433 |
+
if isinstance(prop, dict) and "size" not in prop:
|
| 434 |
+
self.prop.set_size(mpl.rcParams["legend.fontsize"])
|
| 435 |
+
|
| 436 |
+
self._fontsize = self.prop.get_size_in_points()
|
| 437 |
+
|
| 438 |
+
self.texts = []
|
| 439 |
+
self.legend_handles = []
|
| 440 |
+
self._legend_title_box = None
|
| 441 |
+
|
| 442 |
+
#: A dictionary with the extra handler mappings for this Legend
|
| 443 |
+
#: instance.
|
| 444 |
+
self._custom_handler_map = handler_map
|
| 445 |
+
|
| 446 |
+
self.numpoints = mpl._val_or_rc(numpoints, 'legend.numpoints')
|
| 447 |
+
self.markerscale = mpl._val_or_rc(markerscale, 'legend.markerscale')
|
| 448 |
+
self.scatterpoints = mpl._val_or_rc(scatterpoints, 'legend.scatterpoints')
|
| 449 |
+
self.borderpad = mpl._val_or_rc(borderpad, 'legend.borderpad')
|
| 450 |
+
self.labelspacing = mpl._val_or_rc(labelspacing, 'legend.labelspacing')
|
| 451 |
+
self.handlelength = mpl._val_or_rc(handlelength, 'legend.handlelength')
|
| 452 |
+
self.handleheight = mpl._val_or_rc(handleheight, 'legend.handleheight')
|
| 453 |
+
self.handletextpad = mpl._val_or_rc(handletextpad, 'legend.handletextpad')
|
| 454 |
+
self.borderaxespad = mpl._val_or_rc(borderaxespad, 'legend.borderaxespad')
|
| 455 |
+
self.columnspacing = mpl._val_or_rc(columnspacing, 'legend.columnspacing')
|
| 456 |
+
self.shadow = mpl._val_or_rc(shadow, 'legend.shadow')
|
| 457 |
+
|
| 458 |
+
if reverse:
|
| 459 |
+
labels = [*reversed(labels)]
|
| 460 |
+
handles = [*reversed(handles)]
|
| 461 |
+
|
| 462 |
+
if len(handles) < 2:
|
| 463 |
+
ncols = 1
|
| 464 |
+
self._ncols = ncols if ncols != 1 else ncol
|
| 465 |
+
|
| 466 |
+
if self.numpoints <= 0:
|
| 467 |
+
raise ValueError("numpoints must be > 0; it was %d" % numpoints)
|
| 468 |
+
|
| 469 |
+
# introduce y-offset for handles of the scatter plot
|
| 470 |
+
if scatteryoffsets is None:
|
| 471 |
+
self._scatteryoffsets = np.array([3. / 8., 4. / 8., 2.5 / 8.])
|
| 472 |
+
else:
|
| 473 |
+
self._scatteryoffsets = np.asarray(scatteryoffsets)
|
| 474 |
+
reps = self.scatterpoints // len(self._scatteryoffsets) + 1
|
| 475 |
+
self._scatteryoffsets = np.tile(self._scatteryoffsets,
|
| 476 |
+
reps)[:self.scatterpoints]
|
| 477 |
+
|
| 478 |
+
# _legend_box is a VPacker instance that contains all
|
| 479 |
+
# legend items and will be initialized from _init_legend_box()
|
| 480 |
+
# method.
|
| 481 |
+
self._legend_box = None
|
| 482 |
+
|
| 483 |
+
if isinstance(parent, Axes):
|
| 484 |
+
self.isaxes = True
|
| 485 |
+
self.axes = parent
|
| 486 |
+
self.set_figure(parent.get_figure(root=False))
|
| 487 |
+
elif isinstance(parent, FigureBase):
|
| 488 |
+
self.isaxes = False
|
| 489 |
+
self.set_figure(parent)
|
| 490 |
+
else:
|
| 491 |
+
raise TypeError(
|
| 492 |
+
"Legend needs either Axes or FigureBase as parent"
|
| 493 |
+
)
|
| 494 |
+
self.parent = parent
|
| 495 |
+
|
| 496 |
+
self._mode = mode
|
| 497 |
+
self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform)
|
| 498 |
+
|
| 499 |
+
# Figure out if self.shadow is valid
|
| 500 |
+
# If shadow was None, rcParams loads False
|
| 501 |
+
# So it shouldn't be None here
|
| 502 |
+
|
| 503 |
+
self._shadow_props = {'ox': 2, 'oy': -2} # default location offsets
|
| 504 |
+
if isinstance(self.shadow, dict):
|
| 505 |
+
self._shadow_props.update(self.shadow)
|
| 506 |
+
self.shadow = True
|
| 507 |
+
elif self.shadow in (0, 1, True, False):
|
| 508 |
+
self.shadow = bool(self.shadow)
|
| 509 |
+
else:
|
| 510 |
+
raise ValueError(
|
| 511 |
+
'Legend shadow must be a dict or bool, not '
|
| 512 |
+
f'{self.shadow!r} of type {type(self.shadow)}.'
|
| 513 |
+
)
|
| 514 |
+
|
| 515 |
+
# We use FancyBboxPatch to draw a legend frame. The location
|
| 516 |
+
# and size of the box will be updated during the drawing time.
|
| 517 |
+
|
| 518 |
+
facecolor = mpl._val_or_rc(facecolor, "legend.facecolor")
|
| 519 |
+
if facecolor == 'inherit':
|
| 520 |
+
facecolor = mpl.rcParams["axes.facecolor"]
|
| 521 |
+
|
| 522 |
+
edgecolor = mpl._val_or_rc(edgecolor, "legend.edgecolor")
|
| 523 |
+
if edgecolor == 'inherit':
|
| 524 |
+
edgecolor = mpl.rcParams["axes.edgecolor"]
|
| 525 |
+
|
| 526 |
+
fancybox = mpl._val_or_rc(fancybox, "legend.fancybox")
|
| 527 |
+
|
| 528 |
+
self.legendPatch = FancyBboxPatch(
|
| 529 |
+
xy=(0, 0), width=1, height=1,
|
| 530 |
+
facecolor=facecolor, edgecolor=edgecolor,
|
| 531 |
+
# If shadow is used, default to alpha=1 (#8943).
|
| 532 |
+
alpha=(framealpha if framealpha is not None
|
| 533 |
+
else 1 if shadow
|
| 534 |
+
else mpl.rcParams["legend.framealpha"]),
|
| 535 |
+
# The width and height of the legendPatch will be set (in draw())
|
| 536 |
+
# to the length that includes the padding. Thus we set pad=0 here.
|
| 537 |
+
boxstyle=("round,pad=0,rounding_size=0.2" if fancybox
|
| 538 |
+
else "square,pad=0"),
|
| 539 |
+
mutation_scale=self._fontsize,
|
| 540 |
+
snap=True,
|
| 541 |
+
visible=mpl._val_or_rc(frameon, "legend.frameon")
|
| 542 |
+
)
|
| 543 |
+
self._set_artist_props(self.legendPatch)
|
| 544 |
+
|
| 545 |
+
_api.check_in_list(["center", "left", "right"], alignment=alignment)
|
| 546 |
+
self._alignment = alignment
|
| 547 |
+
|
| 548 |
+
# init with null renderer
|
| 549 |
+
self._init_legend_box(handles, labels, markerfirst)
|
| 550 |
+
|
| 551 |
+
# Set legend location
|
| 552 |
+
self.set_loc(loc)
|
| 553 |
+
|
| 554 |
+
# figure out title font properties:
|
| 555 |
+
if title_fontsize is not None and title_fontproperties is not None:
|
| 556 |
+
raise ValueError(
|
| 557 |
+
"title_fontsize and title_fontproperties can't be specified "
|
| 558 |
+
"at the same time. Only use one of them. ")
|
| 559 |
+
title_prop_fp = FontProperties._from_any(title_fontproperties)
|
| 560 |
+
if isinstance(title_fontproperties, dict):
|
| 561 |
+
if "size" not in title_fontproperties:
|
| 562 |
+
title_fontsize = mpl.rcParams["legend.title_fontsize"]
|
| 563 |
+
title_prop_fp.set_size(title_fontsize)
|
| 564 |
+
elif title_fontsize is not None:
|
| 565 |
+
title_prop_fp.set_size(title_fontsize)
|
| 566 |
+
elif not isinstance(title_fontproperties, FontProperties):
|
| 567 |
+
title_fontsize = mpl.rcParams["legend.title_fontsize"]
|
| 568 |
+
title_prop_fp.set_size(title_fontsize)
|
| 569 |
+
|
| 570 |
+
self.set_title(title, prop=title_prop_fp)
|
| 571 |
+
|
| 572 |
+
self._draggable = None
|
| 573 |
+
self.set_draggable(state=draggable)
|
| 574 |
+
|
| 575 |
+
# set the text color
|
| 576 |
+
|
| 577 |
+
color_getters = { # getter function depends on line or patch
|
| 578 |
+
'linecolor': ['get_color', 'get_facecolor'],
|
| 579 |
+
'markerfacecolor': ['get_markerfacecolor', 'get_facecolor'],
|
| 580 |
+
'mfc': ['get_markerfacecolor', 'get_facecolor'],
|
| 581 |
+
'markeredgecolor': ['get_markeredgecolor', 'get_edgecolor'],
|
| 582 |
+
'mec': ['get_markeredgecolor', 'get_edgecolor'],
|
| 583 |
+
}
|
| 584 |
+
labelcolor = mpl._val_or_rc(labelcolor, 'legend.labelcolor')
|
| 585 |
+
if labelcolor is None:
|
| 586 |
+
labelcolor = mpl.rcParams['text.color']
|
| 587 |
+
if isinstance(labelcolor, str) and labelcolor in color_getters:
|
| 588 |
+
getter_names = color_getters[labelcolor]
|
| 589 |
+
for handle, text in zip(self.legend_handles, self.texts):
|
| 590 |
+
try:
|
| 591 |
+
if handle.get_array() is not None:
|
| 592 |
+
continue
|
| 593 |
+
except AttributeError:
|
| 594 |
+
pass
|
| 595 |
+
for getter_name in getter_names:
|
| 596 |
+
try:
|
| 597 |
+
color = getattr(handle, getter_name)()
|
| 598 |
+
if isinstance(color, np.ndarray):
|
| 599 |
+
if (
|
| 600 |
+
color.shape[0] == 1
|
| 601 |
+
or np.isclose(color, color[0]).all()
|
| 602 |
+
):
|
| 603 |
+
text.set_color(color[0])
|
| 604 |
+
else:
|
| 605 |
+
pass
|
| 606 |
+
else:
|
| 607 |
+
text.set_color(color)
|
| 608 |
+
break
|
| 609 |
+
except AttributeError:
|
| 610 |
+
pass
|
| 611 |
+
elif cbook._str_equal(labelcolor, 'none'):
|
| 612 |
+
for text in self.texts:
|
| 613 |
+
text.set_color(labelcolor)
|
| 614 |
+
elif np.iterable(labelcolor):
|
| 615 |
+
for text, color in zip(self.texts,
|
| 616 |
+
itertools.cycle(
|
| 617 |
+
colors.to_rgba_array(labelcolor))):
|
| 618 |
+
text.set_color(color)
|
| 619 |
+
else:
|
| 620 |
+
raise ValueError(f"Invalid labelcolor: {labelcolor!r}")
|
| 621 |
+
|
| 622 |
+
def _set_artist_props(self, a):
|
| 623 |
+
"""
|
| 624 |
+
Set the boilerplate props for artists added to Axes.
|
| 625 |
+
"""
|
| 626 |
+
a.set_figure(self.get_figure(root=False))
|
| 627 |
+
if self.isaxes:
|
| 628 |
+
a.axes = self.axes
|
| 629 |
+
|
| 630 |
+
a.set_transform(self.get_transform())
|
| 631 |
+
|
| 632 |
+
@_docstring.interpd
|
| 633 |
+
def set_loc(self, loc=None):
|
| 634 |
+
"""
|
| 635 |
+
Set the location of the legend.
|
| 636 |
+
|
| 637 |
+
.. versionadded:: 3.8
|
| 638 |
+
|
| 639 |
+
Parameters
|
| 640 |
+
----------
|
| 641 |
+
%(_legend_kw_set_loc_doc)s
|
| 642 |
+
"""
|
| 643 |
+
loc0 = loc
|
| 644 |
+
self._loc_used_default = loc is None
|
| 645 |
+
if loc is None:
|
| 646 |
+
loc = mpl.rcParams["legend.loc"]
|
| 647 |
+
if not self.isaxes and loc in [0, 'best']:
|
| 648 |
+
loc = 'upper right'
|
| 649 |
+
|
| 650 |
+
type_err_message = ("loc must be string, coordinate tuple, or"
|
| 651 |
+
f" an integer 0-10, not {loc!r}")
|
| 652 |
+
|
| 653 |
+
# handle outside legends:
|
| 654 |
+
self._outside_loc = None
|
| 655 |
+
if isinstance(loc, str):
|
| 656 |
+
if loc.split()[0] == 'outside':
|
| 657 |
+
# strip outside:
|
| 658 |
+
loc = loc.split('outside ')[1]
|
| 659 |
+
# strip "center" at the beginning
|
| 660 |
+
self._outside_loc = loc.replace('center ', '')
|
| 661 |
+
# strip first
|
| 662 |
+
self._outside_loc = self._outside_loc.split()[0]
|
| 663 |
+
locs = loc.split()
|
| 664 |
+
if len(locs) > 1 and locs[0] in ('right', 'left'):
|
| 665 |
+
# locs doesn't accept "left upper", etc, so swap
|
| 666 |
+
if locs[0] != 'center':
|
| 667 |
+
locs = locs[::-1]
|
| 668 |
+
loc = locs[0] + ' ' + locs[1]
|
| 669 |
+
# check that loc is in acceptable strings
|
| 670 |
+
loc = _api.check_getitem(self.codes, loc=loc)
|
| 671 |
+
elif np.iterable(loc):
|
| 672 |
+
# coerce iterable into tuple
|
| 673 |
+
loc = tuple(loc)
|
| 674 |
+
# validate the tuple represents Real coordinates
|
| 675 |
+
if len(loc) != 2 or not all(isinstance(e, numbers.Real) for e in loc):
|
| 676 |
+
raise ValueError(type_err_message)
|
| 677 |
+
elif isinstance(loc, int):
|
| 678 |
+
# validate the integer represents a string numeric value
|
| 679 |
+
if loc < 0 or loc > 10:
|
| 680 |
+
raise ValueError(type_err_message)
|
| 681 |
+
else:
|
| 682 |
+
# all other cases are invalid values of loc
|
| 683 |
+
raise ValueError(type_err_message)
|
| 684 |
+
|
| 685 |
+
if self.isaxes and self._outside_loc:
|
| 686 |
+
raise ValueError(
|
| 687 |
+
f"'outside' option for loc='{loc0}' keyword argument only "
|
| 688 |
+
"works for figure legends")
|
| 689 |
+
|
| 690 |
+
if not self.isaxes and loc == 0:
|
| 691 |
+
raise ValueError(
|
| 692 |
+
"Automatic legend placement (loc='best') not implemented for "
|
| 693 |
+
"figure legend")
|
| 694 |
+
|
| 695 |
+
tmp = self._loc_used_default
|
| 696 |
+
self._set_loc(loc)
|
| 697 |
+
self._loc_used_default = tmp # ignore changes done by _set_loc
|
| 698 |
+
|
| 699 |
+
def _set_loc(self, loc):
|
| 700 |
+
# find_offset function will be provided to _legend_box and
|
| 701 |
+
# _legend_box will draw itself at the location of the return
|
| 702 |
+
# value of the find_offset.
|
| 703 |
+
self._loc_used_default = False
|
| 704 |
+
self._loc_real = loc
|
| 705 |
+
self.stale = True
|
| 706 |
+
self._legend_box.set_offset(self._findoffset)
|
| 707 |
+
|
| 708 |
+
def set_ncols(self, ncols):
|
| 709 |
+
"""Set the number of columns."""
|
| 710 |
+
self._ncols = ncols
|
| 711 |
+
|
| 712 |
+
def _get_loc(self):
|
| 713 |
+
return self._loc_real
|
| 714 |
+
|
| 715 |
+
_loc = property(_get_loc, _set_loc)
|
| 716 |
+
|
| 717 |
+
def _findoffset(self, width, height, xdescent, ydescent, renderer):
|
| 718 |
+
"""Helper function to locate the legend."""
|
| 719 |
+
|
| 720 |
+
if self._loc == 0: # "best".
|
| 721 |
+
x, y = self._find_best_position(width, height, renderer)
|
| 722 |
+
elif self._loc in Legend.codes.values(): # Fixed location.
|
| 723 |
+
bbox = Bbox.from_bounds(0, 0, width, height)
|
| 724 |
+
x, y = self._get_anchored_bbox(self._loc, bbox,
|
| 725 |
+
self.get_bbox_to_anchor(),
|
| 726 |
+
renderer)
|
| 727 |
+
else: # Axes or figure coordinates.
|
| 728 |
+
fx, fy = self._loc
|
| 729 |
+
bbox = self.get_bbox_to_anchor()
|
| 730 |
+
x, y = bbox.x0 + bbox.width * fx, bbox.y0 + bbox.height * fy
|
| 731 |
+
|
| 732 |
+
return x + xdescent, y + ydescent
|
| 733 |
+
|
| 734 |
+
@allow_rasterization
|
| 735 |
+
def draw(self, renderer):
|
| 736 |
+
# docstring inherited
|
| 737 |
+
if not self.get_visible():
|
| 738 |
+
return
|
| 739 |
+
|
| 740 |
+
renderer.open_group('legend', gid=self.get_gid())
|
| 741 |
+
|
| 742 |
+
fontsize = renderer.points_to_pixels(self._fontsize)
|
| 743 |
+
|
| 744 |
+
# if mode == fill, set the width of the legend_box to the
|
| 745 |
+
# width of the parent (minus pads)
|
| 746 |
+
if self._mode in ["expand"]:
|
| 747 |
+
pad = 2 * (self.borderaxespad + self.borderpad) * fontsize
|
| 748 |
+
self._legend_box.set_width(self.get_bbox_to_anchor().width - pad)
|
| 749 |
+
|
| 750 |
+
# update the location and size of the legend. This needs to
|
| 751 |
+
# be done in any case to clip the figure right.
|
| 752 |
+
bbox = self._legend_box.get_window_extent(renderer)
|
| 753 |
+
self.legendPatch.set_bounds(bbox.bounds)
|
| 754 |
+
self.legendPatch.set_mutation_scale(fontsize)
|
| 755 |
+
|
| 756 |
+
# self.shadow is validated in __init__
|
| 757 |
+
# So by here it is a bool and self._shadow_props contains any configs
|
| 758 |
+
|
| 759 |
+
if self.shadow:
|
| 760 |
+
Shadow(self.legendPatch, **self._shadow_props).draw(renderer)
|
| 761 |
+
|
| 762 |
+
self.legendPatch.draw(renderer)
|
| 763 |
+
self._legend_box.draw(renderer)
|
| 764 |
+
|
| 765 |
+
renderer.close_group('legend')
|
| 766 |
+
self.stale = False
|
| 767 |
+
|
| 768 |
+
# _default_handler_map defines the default mapping between plot
|
| 769 |
+
# elements and the legend handlers.
|
| 770 |
+
|
| 771 |
+
_default_handler_map = {
|
| 772 |
+
StemContainer: legend_handler.HandlerStem(),
|
| 773 |
+
ErrorbarContainer: legend_handler.HandlerErrorbar(),
|
| 774 |
+
Line2D: legend_handler.HandlerLine2D(),
|
| 775 |
+
Patch: legend_handler.HandlerPatch(),
|
| 776 |
+
StepPatch: legend_handler.HandlerStepPatch(),
|
| 777 |
+
LineCollection: legend_handler.HandlerLineCollection(),
|
| 778 |
+
RegularPolyCollection: legend_handler.HandlerRegularPolyCollection(),
|
| 779 |
+
CircleCollection: legend_handler.HandlerCircleCollection(),
|
| 780 |
+
BarContainer: legend_handler.HandlerPatch(
|
| 781 |
+
update_func=legend_handler.update_from_first_child),
|
| 782 |
+
tuple: legend_handler.HandlerTuple(),
|
| 783 |
+
PathCollection: legend_handler.HandlerPathCollection(),
|
| 784 |
+
PolyCollection: legend_handler.HandlerPolyCollection()
|
| 785 |
+
}
|
| 786 |
+
|
| 787 |
+
# (get|set|update)_default_handler_maps are public interfaces to
|
| 788 |
+
# modify the default handler map.
|
| 789 |
+
|
| 790 |
+
@classmethod
|
| 791 |
+
def get_default_handler_map(cls):
|
| 792 |
+
"""Return the global default handler map, shared by all legends."""
|
| 793 |
+
return cls._default_handler_map
|
| 794 |
+
|
| 795 |
+
@classmethod
|
| 796 |
+
def set_default_handler_map(cls, handler_map):
|
| 797 |
+
"""Set the global default handler map, shared by all legends."""
|
| 798 |
+
cls._default_handler_map = handler_map
|
| 799 |
+
|
| 800 |
+
@classmethod
|
| 801 |
+
def update_default_handler_map(cls, handler_map):
|
| 802 |
+
"""Update the global default handler map, shared by all legends."""
|
| 803 |
+
cls._default_handler_map.update(handler_map)
|
| 804 |
+
|
| 805 |
+
def get_legend_handler_map(self):
|
| 806 |
+
"""Return this legend instance's handler map."""
|
| 807 |
+
default_handler_map = self.get_default_handler_map()
|
| 808 |
+
return ({**default_handler_map, **self._custom_handler_map}
|
| 809 |
+
if self._custom_handler_map else default_handler_map)
|
| 810 |
+
|
| 811 |
+
@staticmethod
|
| 812 |
+
def get_legend_handler(legend_handler_map, orig_handle):
|
| 813 |
+
"""
|
| 814 |
+
Return a legend handler from *legend_handler_map* that
|
| 815 |
+
corresponds to *orig_handler*.
|
| 816 |
+
|
| 817 |
+
*legend_handler_map* should be a dictionary object (that is
|
| 818 |
+
returned by the get_legend_handler_map method).
|
| 819 |
+
|
| 820 |
+
It first checks if the *orig_handle* itself is a key in the
|
| 821 |
+
*legend_handler_map* and return the associated value.
|
| 822 |
+
Otherwise, it checks for each of the classes in its
|
| 823 |
+
method-resolution-order. If no matching key is found, it
|
| 824 |
+
returns ``None``.
|
| 825 |
+
"""
|
| 826 |
+
try:
|
| 827 |
+
return legend_handler_map[orig_handle]
|
| 828 |
+
except (TypeError, KeyError): # TypeError if unhashable.
|
| 829 |
+
pass
|
| 830 |
+
for handle_type in type(orig_handle).mro():
|
| 831 |
+
try:
|
| 832 |
+
return legend_handler_map[handle_type]
|
| 833 |
+
except KeyError:
|
| 834 |
+
pass
|
| 835 |
+
return None
|
| 836 |
+
|
| 837 |
+
def _init_legend_box(self, handles, labels, markerfirst=True):
|
| 838 |
+
"""
|
| 839 |
+
Initialize the legend_box. The legend_box is an instance of
|
| 840 |
+
the OffsetBox, which is packed with legend handles and
|
| 841 |
+
texts. Once packed, their location is calculated during the
|
| 842 |
+
drawing time.
|
| 843 |
+
"""
|
| 844 |
+
|
| 845 |
+
fontsize = self._fontsize
|
| 846 |
+
|
| 847 |
+
# legend_box is a HPacker, horizontally packed with columns.
|
| 848 |
+
# Each column is a VPacker, vertically packed with legend items.
|
| 849 |
+
# Each legend item is a HPacker packed with:
|
| 850 |
+
# - handlebox: a DrawingArea which contains the legend handle.
|
| 851 |
+
# - labelbox: a TextArea which contains the legend text.
|
| 852 |
+
|
| 853 |
+
text_list = [] # the list of text instances
|
| 854 |
+
handle_list = [] # the list of handle instances
|
| 855 |
+
handles_and_labels = []
|
| 856 |
+
|
| 857 |
+
# The approximate height and descent of text. These values are
|
| 858 |
+
# only used for plotting the legend handle.
|
| 859 |
+
descent = 0.35 * fontsize * (self.handleheight - 0.7) # heuristic.
|
| 860 |
+
height = fontsize * self.handleheight - descent
|
| 861 |
+
# each handle needs to be drawn inside a box of (x, y, w, h) =
|
| 862 |
+
# (0, -descent, width, height). And their coordinates should
|
| 863 |
+
# be given in the display coordinates.
|
| 864 |
+
|
| 865 |
+
# The transformation of each handle will be automatically set
|
| 866 |
+
# to self.get_transform(). If the artist does not use its
|
| 867 |
+
# default transform (e.g., Collections), you need to
|
| 868 |
+
# manually set their transform to the self.get_transform().
|
| 869 |
+
legend_handler_map = self.get_legend_handler_map()
|
| 870 |
+
|
| 871 |
+
for orig_handle, label in zip(handles, labels):
|
| 872 |
+
handler = self.get_legend_handler(legend_handler_map, orig_handle)
|
| 873 |
+
if handler is None:
|
| 874 |
+
_api.warn_external(
|
| 875 |
+
"Legend does not support handles for "
|
| 876 |
+
f"{type(orig_handle).__name__} "
|
| 877 |
+
"instances.\nA proxy artist may be used "
|
| 878 |
+
"instead.\nSee: https://matplotlib.org/"
|
| 879 |
+
"stable/users/explain/axes/legend_guide.html"
|
| 880 |
+
"#controlling-the-legend-entries")
|
| 881 |
+
# No handle for this artist, so we just defer to None.
|
| 882 |
+
handle_list.append(None)
|
| 883 |
+
else:
|
| 884 |
+
textbox = TextArea(label, multilinebaseline=True,
|
| 885 |
+
textprops=dict(
|
| 886 |
+
verticalalignment='baseline',
|
| 887 |
+
horizontalalignment='left',
|
| 888 |
+
fontproperties=self.prop))
|
| 889 |
+
handlebox = DrawingArea(width=self.handlelength * fontsize,
|
| 890 |
+
height=height,
|
| 891 |
+
xdescent=0., ydescent=descent)
|
| 892 |
+
|
| 893 |
+
text_list.append(textbox._text)
|
| 894 |
+
# Create the artist for the legend which represents the
|
| 895 |
+
# original artist/handle.
|
| 896 |
+
handle_list.append(handler.legend_artist(self, orig_handle,
|
| 897 |
+
fontsize, handlebox))
|
| 898 |
+
handles_and_labels.append((handlebox, textbox))
|
| 899 |
+
|
| 900 |
+
columnbox = []
|
| 901 |
+
# array_split splits n handles_and_labels into ncols columns, with the
|
| 902 |
+
# first n%ncols columns having an extra entry. filter(len, ...)
|
| 903 |
+
# handles the case where n < ncols: the last ncols-n columns are empty
|
| 904 |
+
# and get filtered out.
|
| 905 |
+
for handles_and_labels_column in filter(
|
| 906 |
+
len, np.array_split(handles_and_labels, self._ncols)):
|
| 907 |
+
# pack handlebox and labelbox into itembox
|
| 908 |
+
itemboxes = [HPacker(pad=0,
|
| 909 |
+
sep=self.handletextpad * fontsize,
|
| 910 |
+
children=[h, t] if markerfirst else [t, h],
|
| 911 |
+
align="baseline")
|
| 912 |
+
for h, t in handles_and_labels_column]
|
| 913 |
+
# pack columnbox
|
| 914 |
+
alignment = "baseline" if markerfirst else "right"
|
| 915 |
+
columnbox.append(VPacker(pad=0,
|
| 916 |
+
sep=self.labelspacing * fontsize,
|
| 917 |
+
align=alignment,
|
| 918 |
+
children=itemboxes))
|
| 919 |
+
|
| 920 |
+
mode = "expand" if self._mode == "expand" else "fixed"
|
| 921 |
+
sep = self.columnspacing * fontsize
|
| 922 |
+
self._legend_handle_box = HPacker(pad=0,
|
| 923 |
+
sep=sep, align="baseline",
|
| 924 |
+
mode=mode,
|
| 925 |
+
children=columnbox)
|
| 926 |
+
self._legend_title_box = TextArea("")
|
| 927 |
+
self._legend_box = VPacker(pad=self.borderpad * fontsize,
|
| 928 |
+
sep=self.labelspacing * fontsize,
|
| 929 |
+
align=self._alignment,
|
| 930 |
+
children=[self._legend_title_box,
|
| 931 |
+
self._legend_handle_box])
|
| 932 |
+
self._legend_box.set_figure(self.get_figure(root=False))
|
| 933 |
+
self._legend_box.axes = self.axes
|
| 934 |
+
self.texts = text_list
|
| 935 |
+
self.legend_handles = handle_list
|
| 936 |
+
|
| 937 |
+
def _auto_legend_data(self):
|
| 938 |
+
"""
|
| 939 |
+
Return display coordinates for hit testing for "best" positioning.
|
| 940 |
+
|
| 941 |
+
Returns
|
| 942 |
+
-------
|
| 943 |
+
bboxes
|
| 944 |
+
List of bounding boxes of all patches.
|
| 945 |
+
lines
|
| 946 |
+
List of `.Path` corresponding to each line.
|
| 947 |
+
offsets
|
| 948 |
+
List of (x, y) offsets of all collection.
|
| 949 |
+
"""
|
| 950 |
+
assert self.isaxes # always holds, as this is only called internally
|
| 951 |
+
bboxes = []
|
| 952 |
+
lines = []
|
| 953 |
+
offsets = []
|
| 954 |
+
for artist in self.parent._children:
|
| 955 |
+
if isinstance(artist, Line2D):
|
| 956 |
+
lines.append(
|
| 957 |
+
artist.get_transform().transform_path(artist.get_path()))
|
| 958 |
+
elif isinstance(artist, Rectangle):
|
| 959 |
+
bboxes.append(
|
| 960 |
+
artist.get_bbox().transformed(artist.get_data_transform()))
|
| 961 |
+
elif isinstance(artist, Patch):
|
| 962 |
+
lines.append(
|
| 963 |
+
artist.get_transform().transform_path(artist.get_path()))
|
| 964 |
+
elif isinstance(artist, PolyCollection):
|
| 965 |
+
lines.extend(artist.get_transform().transform_path(path)
|
| 966 |
+
for path in artist.get_paths())
|
| 967 |
+
elif isinstance(artist, Collection):
|
| 968 |
+
transform, transOffset, hoffsets, _ = artist._prepare_points()
|
| 969 |
+
if len(hoffsets):
|
| 970 |
+
offsets.extend(transOffset.transform(hoffsets))
|
| 971 |
+
elif isinstance(artist, Text):
|
| 972 |
+
bboxes.append(artist.get_window_extent())
|
| 973 |
+
|
| 974 |
+
return bboxes, lines, offsets
|
| 975 |
+
|
| 976 |
+
def get_children(self):
|
| 977 |
+
# docstring inherited
|
| 978 |
+
return [self._legend_box, self.get_frame()]
|
| 979 |
+
|
| 980 |
+
def get_frame(self):
|
| 981 |
+
"""Return the `~.patches.Rectangle` used to frame the legend."""
|
| 982 |
+
return self.legendPatch
|
| 983 |
+
|
| 984 |
+
def get_lines(self):
|
| 985 |
+
r"""Return the list of `~.lines.Line2D`\s in the legend."""
|
| 986 |
+
return [h for h in self.legend_handles if isinstance(h, Line2D)]
|
| 987 |
+
|
| 988 |
+
def get_patches(self):
|
| 989 |
+
r"""Return the list of `~.patches.Patch`\s in the legend."""
|
| 990 |
+
return silent_list('Patch',
|
| 991 |
+
[h for h in self.legend_handles
|
| 992 |
+
if isinstance(h, Patch)])
|
| 993 |
+
|
| 994 |
+
def get_texts(self):
|
| 995 |
+
r"""Return the list of `~.text.Text`\s in the legend."""
|
| 996 |
+
return silent_list('Text', self.texts)
|
| 997 |
+
|
| 998 |
+
def set_alignment(self, alignment):
|
| 999 |
+
"""
|
| 1000 |
+
Set the alignment of the legend title and the box of entries.
|
| 1001 |
+
|
| 1002 |
+
The entries are aligned as a single block, so that markers always
|
| 1003 |
+
lined up.
|
| 1004 |
+
|
| 1005 |
+
Parameters
|
| 1006 |
+
----------
|
| 1007 |
+
alignment : {'center', 'left', 'right'}.
|
| 1008 |
+
|
| 1009 |
+
"""
|
| 1010 |
+
_api.check_in_list(["center", "left", "right"], alignment=alignment)
|
| 1011 |
+
self._alignment = alignment
|
| 1012 |
+
self._legend_box.align = alignment
|
| 1013 |
+
|
| 1014 |
+
def get_alignment(self):
|
| 1015 |
+
"""Get the alignment value of the legend box"""
|
| 1016 |
+
return self._legend_box.align
|
| 1017 |
+
|
| 1018 |
+
def set_title(self, title, prop=None):
|
| 1019 |
+
"""
|
| 1020 |
+
Set legend title and title style.
|
| 1021 |
+
|
| 1022 |
+
Parameters
|
| 1023 |
+
----------
|
| 1024 |
+
title : str
|
| 1025 |
+
The legend title.
|
| 1026 |
+
|
| 1027 |
+
prop : `.font_manager.FontProperties` or `str` or `pathlib.Path`
|
| 1028 |
+
The font properties of the legend title.
|
| 1029 |
+
If a `str`, it is interpreted as a fontconfig pattern parsed by
|
| 1030 |
+
`.FontProperties`. If a `pathlib.Path`, it is interpreted as the
|
| 1031 |
+
absolute path to a font file.
|
| 1032 |
+
|
| 1033 |
+
"""
|
| 1034 |
+
self._legend_title_box._text.set_text(title)
|
| 1035 |
+
if title:
|
| 1036 |
+
self._legend_title_box._text.set_visible(True)
|
| 1037 |
+
self._legend_title_box.set_visible(True)
|
| 1038 |
+
else:
|
| 1039 |
+
self._legend_title_box._text.set_visible(False)
|
| 1040 |
+
self._legend_title_box.set_visible(False)
|
| 1041 |
+
|
| 1042 |
+
if prop is not None:
|
| 1043 |
+
self._legend_title_box._text.set_fontproperties(prop)
|
| 1044 |
+
|
| 1045 |
+
self.stale = True
|
| 1046 |
+
|
| 1047 |
+
def get_title(self):
|
| 1048 |
+
"""Return the `.Text` instance for the legend title."""
|
| 1049 |
+
return self._legend_title_box._text
|
| 1050 |
+
|
| 1051 |
+
def get_window_extent(self, renderer=None):
|
| 1052 |
+
# docstring inherited
|
| 1053 |
+
if renderer is None:
|
| 1054 |
+
renderer = self.get_figure(root=True)._get_renderer()
|
| 1055 |
+
return self._legend_box.get_window_extent(renderer=renderer)
|
| 1056 |
+
|
| 1057 |
+
def get_tightbbox(self, renderer=None):
|
| 1058 |
+
# docstring inherited
|
| 1059 |
+
return self._legend_box.get_window_extent(renderer)
|
| 1060 |
+
|
| 1061 |
+
def get_frame_on(self):
|
| 1062 |
+
"""Get whether the legend box patch is drawn."""
|
| 1063 |
+
return self.legendPatch.get_visible()
|
| 1064 |
+
|
| 1065 |
+
def set_frame_on(self, b):
|
| 1066 |
+
"""
|
| 1067 |
+
Set whether the legend box patch is drawn.
|
| 1068 |
+
|
| 1069 |
+
Parameters
|
| 1070 |
+
----------
|
| 1071 |
+
b : bool
|
| 1072 |
+
"""
|
| 1073 |
+
self.legendPatch.set_visible(b)
|
| 1074 |
+
self.stale = True
|
| 1075 |
+
|
| 1076 |
+
draw_frame = set_frame_on # Backcompat alias.
|
| 1077 |
+
|
| 1078 |
+
def get_bbox_to_anchor(self):
|
| 1079 |
+
"""Return the bbox that the legend will be anchored to."""
|
| 1080 |
+
if self._bbox_to_anchor is None:
|
| 1081 |
+
return self.parent.bbox
|
| 1082 |
+
else:
|
| 1083 |
+
return self._bbox_to_anchor
|
| 1084 |
+
|
| 1085 |
+
def set_bbox_to_anchor(self, bbox, transform=None):
|
| 1086 |
+
"""
|
| 1087 |
+
Set the bbox that the legend will be anchored to.
|
| 1088 |
+
|
| 1089 |
+
Parameters
|
| 1090 |
+
----------
|
| 1091 |
+
bbox : `~matplotlib.transforms.BboxBase` or tuple
|
| 1092 |
+
The bounding box can be specified in the following ways:
|
| 1093 |
+
|
| 1094 |
+
- A `.BboxBase` instance
|
| 1095 |
+
- A tuple of ``(left, bottom, width, height)`` in the given
|
| 1096 |
+
transform (normalized axes coordinate if None)
|
| 1097 |
+
- A tuple of ``(left, bottom)`` where the width and height will be
|
| 1098 |
+
assumed to be zero.
|
| 1099 |
+
- *None*, to remove the bbox anchoring, and use the parent bbox.
|
| 1100 |
+
|
| 1101 |
+
transform : `~matplotlib.transforms.Transform`, optional
|
| 1102 |
+
A transform to apply to the bounding box. If not specified, this
|
| 1103 |
+
will use a transform to the bounding box of the parent.
|
| 1104 |
+
"""
|
| 1105 |
+
if bbox is None:
|
| 1106 |
+
self._bbox_to_anchor = None
|
| 1107 |
+
return
|
| 1108 |
+
elif isinstance(bbox, BboxBase):
|
| 1109 |
+
self._bbox_to_anchor = bbox
|
| 1110 |
+
else:
|
| 1111 |
+
try:
|
| 1112 |
+
l = len(bbox)
|
| 1113 |
+
except TypeError as err:
|
| 1114 |
+
raise ValueError(f"Invalid bbox: {bbox}") from err
|
| 1115 |
+
|
| 1116 |
+
if l == 2:
|
| 1117 |
+
bbox = [bbox[0], bbox[1], 0, 0]
|
| 1118 |
+
|
| 1119 |
+
self._bbox_to_anchor = Bbox.from_bounds(*bbox)
|
| 1120 |
+
|
| 1121 |
+
if transform is None:
|
| 1122 |
+
transform = BboxTransformTo(self.parent.bbox)
|
| 1123 |
+
|
| 1124 |
+
self._bbox_to_anchor = TransformedBbox(self._bbox_to_anchor,
|
| 1125 |
+
transform)
|
| 1126 |
+
self.stale = True
|
| 1127 |
+
|
| 1128 |
+
def _get_anchored_bbox(self, loc, bbox, parentbbox, renderer):
|
| 1129 |
+
"""
|
| 1130 |
+
Place the *bbox* inside the *parentbbox* according to a given
|
| 1131 |
+
location code. Return the (x, y) coordinate of the bbox.
|
| 1132 |
+
|
| 1133 |
+
Parameters
|
| 1134 |
+
----------
|
| 1135 |
+
loc : int
|
| 1136 |
+
A location code in range(1, 11). This corresponds to the possible
|
| 1137 |
+
values for ``self._loc``, excluding "best".
|
| 1138 |
+
bbox : `~matplotlib.transforms.Bbox`
|
| 1139 |
+
bbox to be placed, in display coordinates.
|
| 1140 |
+
parentbbox : `~matplotlib.transforms.Bbox`
|
| 1141 |
+
A parent box which will contain the bbox, in display coordinates.
|
| 1142 |
+
"""
|
| 1143 |
+
return offsetbox._get_anchored_bbox(
|
| 1144 |
+
loc, bbox, parentbbox,
|
| 1145 |
+
self.borderaxespad * renderer.points_to_pixels(self._fontsize))
|
| 1146 |
+
|
| 1147 |
+
def _find_best_position(self, width, height, renderer):
|
| 1148 |
+
"""Determine the best location to place the legend."""
|
| 1149 |
+
assert self.isaxes # always holds, as this is only called internally
|
| 1150 |
+
|
| 1151 |
+
start_time = time.perf_counter()
|
| 1152 |
+
|
| 1153 |
+
bboxes, lines, offsets = self._auto_legend_data()
|
| 1154 |
+
|
| 1155 |
+
bbox = Bbox.from_bounds(0, 0, width, height)
|
| 1156 |
+
|
| 1157 |
+
candidates = []
|
| 1158 |
+
for idx in range(1, len(self.codes)):
|
| 1159 |
+
l, b = self._get_anchored_bbox(idx, bbox,
|
| 1160 |
+
self.get_bbox_to_anchor(),
|
| 1161 |
+
renderer)
|
| 1162 |
+
legendBox = Bbox.from_bounds(l, b, width, height)
|
| 1163 |
+
# XXX TODO: If markers are present, it would be good to take them
|
| 1164 |
+
# into account when checking vertex overlaps in the next line.
|
| 1165 |
+
badness = (sum(legendBox.count_contains(line.vertices)
|
| 1166 |
+
for line in lines)
|
| 1167 |
+
+ legendBox.count_contains(offsets)
|
| 1168 |
+
+ legendBox.count_overlaps(bboxes)
|
| 1169 |
+
+ sum(line.intersects_bbox(legendBox, filled=False)
|
| 1170 |
+
for line in lines))
|
| 1171 |
+
# Include the index to favor lower codes in case of a tie.
|
| 1172 |
+
candidates.append((badness, idx, (l, b)))
|
| 1173 |
+
if badness == 0:
|
| 1174 |
+
break
|
| 1175 |
+
|
| 1176 |
+
_, _, (l, b) = min(candidates)
|
| 1177 |
+
|
| 1178 |
+
if self._loc_used_default and time.perf_counter() - start_time > 1:
|
| 1179 |
+
_api.warn_external(
|
| 1180 |
+
'Creating legend with loc="best" can be slow with large '
|
| 1181 |
+
'amounts of data.')
|
| 1182 |
+
|
| 1183 |
+
return l, b
|
| 1184 |
+
|
| 1185 |
+
def contains(self, mouseevent):
|
| 1186 |
+
return self.legendPatch.contains(mouseevent)
|
| 1187 |
+
|
| 1188 |
+
def set_draggable(self, state, use_blit=False, update='loc'):
|
| 1189 |
+
"""
|
| 1190 |
+
Enable or disable mouse dragging support of the legend.
|
| 1191 |
+
|
| 1192 |
+
Parameters
|
| 1193 |
+
----------
|
| 1194 |
+
state : bool
|
| 1195 |
+
Whether mouse dragging is enabled.
|
| 1196 |
+
use_blit : bool, optional
|
| 1197 |
+
Use blitting for faster image composition. For details see
|
| 1198 |
+
:ref:`func-animation`.
|
| 1199 |
+
update : {'loc', 'bbox'}, optional
|
| 1200 |
+
The legend parameter to be changed when dragged:
|
| 1201 |
+
|
| 1202 |
+
- 'loc': update the *loc* parameter of the legend
|
| 1203 |
+
- 'bbox': update the *bbox_to_anchor* parameter of the legend
|
| 1204 |
+
|
| 1205 |
+
Returns
|
| 1206 |
+
-------
|
| 1207 |
+
`.DraggableLegend` or *None*
|
| 1208 |
+
If *state* is ``True`` this returns the `.DraggableLegend` helper
|
| 1209 |
+
instance. Otherwise this returns *None*.
|
| 1210 |
+
"""
|
| 1211 |
+
if state:
|
| 1212 |
+
if self._draggable is None:
|
| 1213 |
+
self._draggable = DraggableLegend(self,
|
| 1214 |
+
use_blit,
|
| 1215 |
+
update=update)
|
| 1216 |
+
else:
|
| 1217 |
+
if self._draggable is not None:
|
| 1218 |
+
self._draggable.disconnect()
|
| 1219 |
+
self._draggable = None
|
| 1220 |
+
return self._draggable
|
| 1221 |
+
|
| 1222 |
+
def get_draggable(self):
|
| 1223 |
+
"""Return ``True`` if the legend is draggable, ``False`` otherwise."""
|
| 1224 |
+
return self._draggable is not None
|
| 1225 |
+
|
| 1226 |
+
|
| 1227 |
+
# Helper functions to parse legend arguments for both `figure.legend` and
|
| 1228 |
+
# `axes.legend`:
|
| 1229 |
+
def _get_legend_handles(axs, legend_handler_map=None):
|
| 1230 |
+
"""Yield artists that can be used as handles in a legend."""
|
| 1231 |
+
handles_original = []
|
| 1232 |
+
for ax in axs:
|
| 1233 |
+
handles_original += [
|
| 1234 |
+
*(a for a in ax._children
|
| 1235 |
+
if isinstance(a, (Line2D, Patch, Collection, Text))),
|
| 1236 |
+
*ax.containers]
|
| 1237 |
+
# support parasite Axes:
|
| 1238 |
+
if hasattr(ax, 'parasites'):
|
| 1239 |
+
for axx in ax.parasites:
|
| 1240 |
+
handles_original += [
|
| 1241 |
+
*(a for a in axx._children
|
| 1242 |
+
if isinstance(a, (Line2D, Patch, Collection, Text))),
|
| 1243 |
+
*axx.containers]
|
| 1244 |
+
|
| 1245 |
+
handler_map = {**Legend.get_default_handler_map(),
|
| 1246 |
+
**(legend_handler_map or {})}
|
| 1247 |
+
has_handler = Legend.get_legend_handler
|
| 1248 |
+
for handle in handles_original:
|
| 1249 |
+
label = handle.get_label()
|
| 1250 |
+
if label != '_nolegend_' and has_handler(handler_map, handle):
|
| 1251 |
+
yield handle
|
| 1252 |
+
elif (label and not label.startswith('_') and
|
| 1253 |
+
not has_handler(handler_map, handle)):
|
| 1254 |
+
_api.warn_external(
|
| 1255 |
+
"Legend does not support handles for "
|
| 1256 |
+
f"{type(handle).__name__} "
|
| 1257 |
+
"instances.\nSee: https://matplotlib.org/stable/"
|
| 1258 |
+
"tutorials/intermediate/legend_guide.html"
|
| 1259 |
+
"#implementing-a-custom-legend-handler")
|
| 1260 |
+
continue
|
| 1261 |
+
|
| 1262 |
+
|
| 1263 |
+
def _get_legend_handles_labels(axs, legend_handler_map=None):
|
| 1264 |
+
"""Return handles and labels for legend."""
|
| 1265 |
+
handles = []
|
| 1266 |
+
labels = []
|
| 1267 |
+
for handle in _get_legend_handles(axs, legend_handler_map):
|
| 1268 |
+
label = handle.get_label()
|
| 1269 |
+
if label and not label.startswith('_'):
|
| 1270 |
+
handles.append(handle)
|
| 1271 |
+
labels.append(label)
|
| 1272 |
+
return handles, labels
|
| 1273 |
+
|
| 1274 |
+
|
| 1275 |
+
def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):
|
| 1276 |
+
"""
|
| 1277 |
+
Get the handles and labels from the calls to either ``figure.legend``
|
| 1278 |
+
or ``axes.legend``.
|
| 1279 |
+
|
| 1280 |
+
The parser is a bit involved because we support::
|
| 1281 |
+
|
| 1282 |
+
legend()
|
| 1283 |
+
legend(labels)
|
| 1284 |
+
legend(handles, labels)
|
| 1285 |
+
legend(labels=labels)
|
| 1286 |
+
legend(handles=handles)
|
| 1287 |
+
legend(handles=handles, labels=labels)
|
| 1288 |
+
|
| 1289 |
+
The behavior for a mixture of positional and keyword handles and labels
|
| 1290 |
+
is undefined and issues a warning; it will be an error in the future.
|
| 1291 |
+
|
| 1292 |
+
Parameters
|
| 1293 |
+
----------
|
| 1294 |
+
axs : list of `.Axes`
|
| 1295 |
+
If handles are not given explicitly, the artists in these Axes are
|
| 1296 |
+
used as handles.
|
| 1297 |
+
*args : tuple
|
| 1298 |
+
Positional parameters passed to ``legend()``.
|
| 1299 |
+
handles
|
| 1300 |
+
The value of the keyword argument ``legend(handles=...)``, or *None*
|
| 1301 |
+
if that keyword argument was not used.
|
| 1302 |
+
labels
|
| 1303 |
+
The value of the keyword argument ``legend(labels=...)``, or *None*
|
| 1304 |
+
if that keyword argument was not used.
|
| 1305 |
+
**kwargs
|
| 1306 |
+
All other keyword arguments passed to ``legend()``.
|
| 1307 |
+
|
| 1308 |
+
Returns
|
| 1309 |
+
-------
|
| 1310 |
+
handles : list of (`.Artist` or tuple of `.Artist`)
|
| 1311 |
+
The legend handles.
|
| 1312 |
+
labels : list of str
|
| 1313 |
+
The legend labels.
|
| 1314 |
+
kwargs : dict
|
| 1315 |
+
*kwargs* with keywords handles and labels removed.
|
| 1316 |
+
|
| 1317 |
+
"""
|
| 1318 |
+
log = logging.getLogger(__name__)
|
| 1319 |
+
|
| 1320 |
+
handlers = kwargs.get('handler_map')
|
| 1321 |
+
|
| 1322 |
+
if (handles is not None or labels is not None) and args:
|
| 1323 |
+
_api.warn_deprecated("3.9", message=(
|
| 1324 |
+
"You have mixed positional and keyword arguments, some input may "
|
| 1325 |
+
"be discarded. This is deprecated since %(since)s and will "
|
| 1326 |
+
"become an error in %(removal)s."))
|
| 1327 |
+
|
| 1328 |
+
if (hasattr(handles, "__len__") and
|
| 1329 |
+
hasattr(labels, "__len__") and
|
| 1330 |
+
len(handles) != len(labels)):
|
| 1331 |
+
_api.warn_external(f"Mismatched number of handles and labels: "
|
| 1332 |
+
f"len(handles) = {len(handles)} "
|
| 1333 |
+
f"len(labels) = {len(labels)}")
|
| 1334 |
+
# if got both handles and labels as kwargs, make same length
|
| 1335 |
+
if handles and labels:
|
| 1336 |
+
handles, labels = zip(*zip(handles, labels))
|
| 1337 |
+
|
| 1338 |
+
elif handles is not None and labels is None:
|
| 1339 |
+
labels = [handle.get_label() for handle in handles]
|
| 1340 |
+
|
| 1341 |
+
elif labels is not None and handles is None:
|
| 1342 |
+
# Get as many handles as there are labels.
|
| 1343 |
+
handles = [handle for handle, label
|
| 1344 |
+
in zip(_get_legend_handles(axs, handlers), labels)]
|
| 1345 |
+
|
| 1346 |
+
elif len(args) == 0: # 0 args: automatically detect labels and handles.
|
| 1347 |
+
handles, labels = _get_legend_handles_labels(axs, handlers)
|
| 1348 |
+
if not handles:
|
| 1349 |
+
_api.warn_external(
|
| 1350 |
+
"No artists with labels found to put in legend. Note that "
|
| 1351 |
+
"artists whose label start with an underscore are ignored "
|
| 1352 |
+
"when legend() is called with no argument.")
|
| 1353 |
+
|
| 1354 |
+
elif len(args) == 1: # 1 arg: user defined labels, automatic handle detection.
|
| 1355 |
+
labels, = args
|
| 1356 |
+
if any(isinstance(l, Artist) for l in labels):
|
| 1357 |
+
raise TypeError("A single argument passed to legend() must be a "
|
| 1358 |
+
"list of labels, but found an Artist in there.")
|
| 1359 |
+
|
| 1360 |
+
# Get as many handles as there are labels.
|
| 1361 |
+
handles = [handle for handle, label
|
| 1362 |
+
in zip(_get_legend_handles(axs, handlers), labels)]
|
| 1363 |
+
|
| 1364 |
+
elif len(args) == 2: # 2 args: user defined handles and labels.
|
| 1365 |
+
handles, labels = args[:2]
|
| 1366 |
+
|
| 1367 |
+
else:
|
| 1368 |
+
raise _api.nargs_error('legend', '0-2', len(args))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ib.axes import Axes
|
| 2 |
+
from matplotlib.artist import Artist
|
| 3 |
+
from matplotlib.backend_bases import MouseEvent
|
| 4 |
+
from matplotlib.figure import Figure
|
| 5 |
+
from matplotlib.font_manager import FontProperties
|
| 6 |
+
from matplotlib.legend_handler import HandlerBase
|
| 7 |
+
from matplotlib.lines import Line2D
|
| 8 |
+
from matplotlib.offsetbox import (
|
| 9 |
+
DraggableOffsetBox,
|
| 10 |
+
)
|
| 11 |
+
from matplotlib.patches import FancyBboxPatch, Patch, Rectangle
|
| 12 |
+
from matplotlib.text import Text
|
| 13 |
+
from matplotlib.transforms import (
|
| 14 |
+
BboxBase,
|
| 15 |
+
Transform,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
import pathlib
|
| 20 |
+
from collections.abc import Iterable
|
| 21 |
+
from typing import Any, Literal, overload
|
| 22 |
+
from .typing import ColorType
|
| 23 |
+
|
| 24 |
+
class DraggableLegend(DraggableOffsetBox):
|
| 25 |
+
legend: Legend
|
| 26 |
+
def __init__(
|
| 27 |
+
self, legend: Legend, use_blit: bool = ..., update: Literal["loc", "bbox"] = ...
|
| 28 |
+
) -> None: ...
|
| 29 |
+
def finalize_offset(self) -> None: ...
|
| 30 |
+
|
| 31 |
+
class Legend(Artist):
|
| 32 |
+
codes: dict[str, int]
|
| 33 |
+
zorder: float
|
| 34 |
+
prop: FontProperties
|
| 35 |
+
texts: list[Text]
|
| 36 |
+
legend_handles: list[Artist | None]
|
| 37 |
+
numpoints: int
|
| 38 |
+
markerscale: float
|
| 39 |
+
scatterpoints: int
|
| 40 |
+
borderpad: float
|
| 41 |
+
labelspacing: float
|
| 42 |
+
handlelength: float
|
| 43 |
+
handleheight: float
|
| 44 |
+
handletextpad: float
|
| 45 |
+
borderaxespad: float
|
| 46 |
+
columnspacing: float
|
| 47 |
+
shadow: bool
|
| 48 |
+
isaxes: bool
|
| 49 |
+
axes: Axes
|
| 50 |
+
parent: Axes | Figure
|
| 51 |
+
legendPatch: FancyBboxPatch
|
| 52 |
+
def __init__(
|
| 53 |
+
self,
|
| 54 |
+
parent: Axes | Figure,
|
| 55 |
+
handles: Iterable[Artist | tuple[Artist, ...]],
|
| 56 |
+
labels: Iterable[str],
|
| 57 |
+
*,
|
| 58 |
+
loc: str | tuple[float, float] | int | None = ...,
|
| 59 |
+
numpoints: int | None = ...,
|
| 60 |
+
markerscale: float | None = ...,
|
| 61 |
+
markerfirst: bool = ...,
|
| 62 |
+
reverse: bool = ...,
|
| 63 |
+
scatterpoints: int | None = ...,
|
| 64 |
+
scatteryoffsets: Iterable[float] | None = ...,
|
| 65 |
+
prop: FontProperties | dict[str, Any] | None = ...,
|
| 66 |
+
fontsize: float | str | None = ...,
|
| 67 |
+
labelcolor: ColorType
|
| 68 |
+
| Iterable[ColorType]
|
| 69 |
+
| Literal["linecolor", "markerfacecolor", "mfc", "markeredgecolor", "mec"]
|
| 70 |
+
| None = ...,
|
| 71 |
+
borderpad: float | None = ...,
|
| 72 |
+
labelspacing: float | None = ...,
|
| 73 |
+
handlelength: float | None = ...,
|
| 74 |
+
handleheight: float | None = ...,
|
| 75 |
+
handletextpad: float | None = ...,
|
| 76 |
+
borderaxespad: float | None = ...,
|
| 77 |
+
columnspacing: float | None = ...,
|
| 78 |
+
ncols: int = ...,
|
| 79 |
+
mode: Literal["expand"] | None = ...,
|
| 80 |
+
fancybox: bool | None = ...,
|
| 81 |
+
shadow: bool | dict[str, Any] | None = ...,
|
| 82 |
+
title: str | None = ...,
|
| 83 |
+
title_fontsize: float | None = ...,
|
| 84 |
+
framealpha: float | None = ...,
|
| 85 |
+
edgecolor: Literal["inherit"] | ColorType | None = ...,
|
| 86 |
+
facecolor: Literal["inherit"] | ColorType | None = ...,
|
| 87 |
+
bbox_to_anchor: BboxBase
|
| 88 |
+
| tuple[float, float]
|
| 89 |
+
| tuple[float, float, float, float]
|
| 90 |
+
| None = ...,
|
| 91 |
+
bbox_transform: Transform | None = ...,
|
| 92 |
+
frameon: bool | None = ...,
|
| 93 |
+
handler_map: dict[Artist | type, HandlerBase] | None = ...,
|
| 94 |
+
title_fontproperties: FontProperties | dict[str, Any] | None = ...,
|
| 95 |
+
alignment: Literal["center", "left", "right"] = ...,
|
| 96 |
+
ncol: int = ...,
|
| 97 |
+
draggable: bool = ...
|
| 98 |
+
) -> None: ...
|
| 99 |
+
def contains(self, mouseevent: MouseEvent) -> tuple[bool, dict[Any, Any]]: ...
|
| 100 |
+
def set_ncols(self, ncols: int) -> None: ...
|
| 101 |
+
@classmethod
|
| 102 |
+
def get_default_handler_map(cls) -> dict[type, HandlerBase]: ...
|
| 103 |
+
@classmethod
|
| 104 |
+
def set_default_handler_map(cls, handler_map: dict[type, HandlerBase]) -> None: ...
|
| 105 |
+
@classmethod
|
| 106 |
+
def update_default_handler_map(
|
| 107 |
+
cls, handler_map: dict[type, HandlerBase]
|
| 108 |
+
) -> None: ...
|
| 109 |
+
def get_legend_handler_map(self) -> dict[type, HandlerBase]: ...
|
| 110 |
+
@staticmethod
|
| 111 |
+
def get_legend_handler(
|
| 112 |
+
legend_handler_map: dict[type, HandlerBase], orig_handle: Any
|
| 113 |
+
) -> HandlerBase | None: ...
|
| 114 |
+
def get_children(self) -> list[Artist]: ...
|
| 115 |
+
def get_frame(self) -> Rectangle: ...
|
| 116 |
+
def get_lines(self) -> list[Line2D]: ...
|
| 117 |
+
def get_patches(self) -> list[Patch]: ...
|
| 118 |
+
def get_texts(self) -> list[Text]: ...
|
| 119 |
+
def set_alignment(self, alignment: Literal["center", "left", "right"]) -> None: ...
|
| 120 |
+
def get_alignment(self) -> Literal["center", "left", "right"]: ...
|
| 121 |
+
def set_loc(self, loc: str | tuple[float, float] | int | None = ...) -> None: ...
|
| 122 |
+
def set_title(
|
| 123 |
+
self, title: str, prop: FontProperties | str | pathlib.Path | None = ...
|
| 124 |
+
) -> None: ...
|
| 125 |
+
def get_title(self) -> Text: ...
|
| 126 |
+
def get_frame_on(self) -> bool: ...
|
| 127 |
+
def set_frame_on(self, b: bool) -> None: ...
|
| 128 |
+
draw_frame = set_frame_on
|
| 129 |
+
def get_bbox_to_anchor(self) -> BboxBase: ...
|
| 130 |
+
def set_bbox_to_anchor(
|
| 131 |
+
self,
|
| 132 |
+
bbox: BboxBase
|
| 133 |
+
| tuple[float, float]
|
| 134 |
+
| tuple[float, float, float, float]
|
| 135 |
+
| None,
|
| 136 |
+
transform: Transform | None = ...
|
| 137 |
+
) -> None: ...
|
| 138 |
+
@overload
|
| 139 |
+
def set_draggable(
|
| 140 |
+
self,
|
| 141 |
+
state: Literal[True],
|
| 142 |
+
use_blit: bool = ...,
|
| 143 |
+
update: Literal["loc", "bbox"] = ...,
|
| 144 |
+
) -> DraggableLegend: ...
|
| 145 |
+
@overload
|
| 146 |
+
def set_draggable(
|
| 147 |
+
self,
|
| 148 |
+
state: Literal[False],
|
| 149 |
+
use_blit: bool = ...,
|
| 150 |
+
update: Literal["loc", "bbox"] = ...,
|
| 151 |
+
) -> None: ...
|
| 152 |
+
def get_draggable(self) -> bool: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/markers.pyi
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Literal
|
| 2 |
+
|
| 3 |
+
from .path import Path
|
| 4 |
+
from .transforms import Affine2D, Transform
|
| 5 |
+
|
| 6 |
+
from numpy.typing import ArrayLike
|
| 7 |
+
from .typing import CapStyleType, FillStyleType, JoinStyleType
|
| 8 |
+
|
| 9 |
+
TICKLEFT: int
|
| 10 |
+
TICKRIGHT: int
|
| 11 |
+
TICKUP: int
|
| 12 |
+
TICKDOWN: int
|
| 13 |
+
CARETLEFT: int
|
| 14 |
+
CARETRIGHT: int
|
| 15 |
+
CARETUP: int
|
| 16 |
+
CARETDOWN: int
|
| 17 |
+
CARETLEFTBASE: int
|
| 18 |
+
CARETRIGHTBASE: int
|
| 19 |
+
CARETUPBASE: int
|
| 20 |
+
CARETDOWNBASE: int
|
| 21 |
+
|
| 22 |
+
class MarkerStyle:
|
| 23 |
+
markers: dict[str | int, str]
|
| 24 |
+
filled_markers: tuple[str, ...]
|
| 25 |
+
fillstyles: tuple[FillStyleType, ...]
|
| 26 |
+
|
| 27 |
+
def __init__(
|
| 28 |
+
self,
|
| 29 |
+
marker: str | ArrayLike | Path | MarkerStyle,
|
| 30 |
+
fillstyle: FillStyleType | None = ...,
|
| 31 |
+
transform: Transform | None = ...,
|
| 32 |
+
capstyle: CapStyleType | None = ...,
|
| 33 |
+
joinstyle: JoinStyleType | None = ...,
|
| 34 |
+
) -> None: ...
|
| 35 |
+
def __bool__(self) -> bool: ...
|
| 36 |
+
def is_filled(self) -> bool: ...
|
| 37 |
+
def get_fillstyle(self) -> FillStyleType: ...
|
| 38 |
+
def get_joinstyle(self) -> Literal["miter", "round", "bevel"]: ...
|
| 39 |
+
def get_capstyle(self) -> Literal["butt", "projecting", "round"]: ...
|
| 40 |
+
def get_marker(self) -> str | ArrayLike | Path | None: ...
|
| 41 |
+
def get_path(self) -> Path: ...
|
| 42 |
+
def get_transform(self) -> Transform: ...
|
| 43 |
+
def get_alt_path(self) -> Path | None: ...
|
| 44 |
+
def get_alt_transform(self) -> Transform: ...
|
| 45 |
+
def get_snap_threshold(self) -> float | None: ...
|
| 46 |
+
def get_user_transform(self) -> Transform | None: ...
|
| 47 |
+
def transformed(self, transform: Affine2D) -> MarkerStyle: ...
|
| 48 |
+
def rotated(
|
| 49 |
+
self, *, deg: float | None = ..., rad: float | None = ...
|
| 50 |
+
) -> MarkerStyle: ...
|
| 51 |
+
def scaled(self, sx: float, sy: float | None = ...) -> MarkerStyle: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/offsetbox.py
ADDED
|
@@ -0,0 +1,1573 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
r"""
|
| 2 |
+
Container classes for `.Artist`\s.
|
| 3 |
+
|
| 4 |
+
`OffsetBox`
|
| 5 |
+
The base of all container artists defined in this module.
|
| 6 |
+
|
| 7 |
+
`AnchoredOffsetbox`, `AnchoredText`
|
| 8 |
+
Anchor and align an arbitrary `.Artist` or a text relative to the parent
|
| 9 |
+
axes or a specific anchor point.
|
| 10 |
+
|
| 11 |
+
`DrawingArea`
|
| 12 |
+
A container with fixed width and height. Children have a fixed position
|
| 13 |
+
inside the container and may be clipped.
|
| 14 |
+
|
| 15 |
+
`HPacker`, `VPacker`
|
| 16 |
+
Containers for layouting their children vertically or horizontally.
|
| 17 |
+
|
| 18 |
+
`PaddedBox`
|
| 19 |
+
A container to add a padding around an `.Artist`.
|
| 20 |
+
|
| 21 |
+
`TextArea`
|
| 22 |
+
Contains a single `.Text` instance.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
import functools
|
| 26 |
+
|
| 27 |
+
import numpy as np
|
| 28 |
+
|
| 29 |
+
import matplotlib as mpl
|
| 30 |
+
from matplotlib import _api, _docstring
|
| 31 |
+
import matplotlib.artist as martist
|
| 32 |
+
import matplotlib.path as mpath
|
| 33 |
+
import matplotlib.text as mtext
|
| 34 |
+
import matplotlib.transforms as mtransforms
|
| 35 |
+
from matplotlib.font_manager import FontProperties
|
| 36 |
+
from matplotlib.image import BboxImage
|
| 37 |
+
from matplotlib.patches import (
|
| 38 |
+
FancyBboxPatch, FancyArrowPatch, bbox_artist as mbbox_artist)
|
| 39 |
+
from matplotlib.transforms import Bbox, BboxBase, TransformedBbox
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
DEBUG = False
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def _compat_get_offset(meth):
|
| 46 |
+
"""
|
| 47 |
+
Decorator for the get_offset method of OffsetBox and subclasses, that
|
| 48 |
+
allows supporting both the new signature (self, bbox, renderer) and the old
|
| 49 |
+
signature (self, width, height, xdescent, ydescent, renderer).
|
| 50 |
+
"""
|
| 51 |
+
sigs = [lambda self, width, height, xdescent, ydescent, renderer: locals(),
|
| 52 |
+
lambda self, bbox, renderer: locals()]
|
| 53 |
+
|
| 54 |
+
@functools.wraps(meth)
|
| 55 |
+
def get_offset(self, *args, **kwargs):
|
| 56 |
+
params = _api.select_matching_signature(sigs, self, *args, **kwargs)
|
| 57 |
+
bbox = (params["bbox"] if "bbox" in params else
|
| 58 |
+
Bbox.from_bounds(-params["xdescent"], -params["ydescent"],
|
| 59 |
+
params["width"], params["height"]))
|
| 60 |
+
return meth(params["self"], bbox, params["renderer"])
|
| 61 |
+
return get_offset
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
# for debugging use
|
| 65 |
+
def _bbox_artist(*args, **kwargs):
|
| 66 |
+
if DEBUG:
|
| 67 |
+
mbbox_artist(*args, **kwargs)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def _get_packed_offsets(widths, total, sep, mode="fixed"):
|
| 71 |
+
r"""
|
| 72 |
+
Pack boxes specified by their *widths*.
|
| 73 |
+
|
| 74 |
+
For simplicity of the description, the terminology used here assumes a
|
| 75 |
+
horizontal layout, but the function works equally for a vertical layout.
|
| 76 |
+
|
| 77 |
+
There are three packing *mode*\s:
|
| 78 |
+
|
| 79 |
+
- 'fixed': The elements are packed tight to the left with a spacing of
|
| 80 |
+
*sep* in between. If *total* is *None* the returned total will be the
|
| 81 |
+
right edge of the last box. A non-*None* total will be passed unchecked
|
| 82 |
+
to the output. In particular this means that right edge of the last
|
| 83 |
+
box may be further to the right than the returned total.
|
| 84 |
+
|
| 85 |
+
- 'expand': Distribute the boxes with equal spacing so that the left edge
|
| 86 |
+
of the first box is at 0, and the right edge of the last box is at
|
| 87 |
+
*total*. The parameter *sep* is ignored in this mode. A total of *None*
|
| 88 |
+
is accepted and considered equal to 1. The total is returned unchanged
|
| 89 |
+
(except for the conversion *None* to 1). If the total is smaller than
|
| 90 |
+
the sum of the widths, the laid out boxes will overlap.
|
| 91 |
+
|
| 92 |
+
- 'equal': If *total* is given, the total space is divided in N equal
|
| 93 |
+
ranges and each box is left-aligned within its subspace.
|
| 94 |
+
Otherwise (*total* is *None*), *sep* must be provided and each box is
|
| 95 |
+
left-aligned in its subspace of width ``(max(widths) + sep)``. The
|
| 96 |
+
total width is then calculated to be ``N * (max(widths) + sep)``.
|
| 97 |
+
|
| 98 |
+
Parameters
|
| 99 |
+
----------
|
| 100 |
+
widths : list of float
|
| 101 |
+
Widths of boxes to be packed.
|
| 102 |
+
total : float or None
|
| 103 |
+
Intended total length. *None* if not used.
|
| 104 |
+
sep : float or None
|
| 105 |
+
Spacing between boxes.
|
| 106 |
+
mode : {'fixed', 'expand', 'equal'}
|
| 107 |
+
The packing mode.
|
| 108 |
+
|
| 109 |
+
Returns
|
| 110 |
+
-------
|
| 111 |
+
total : float
|
| 112 |
+
The total width needed to accommodate the laid out boxes.
|
| 113 |
+
offsets : array of float
|
| 114 |
+
The left offsets of the boxes.
|
| 115 |
+
"""
|
| 116 |
+
_api.check_in_list(["fixed", "expand", "equal"], mode=mode)
|
| 117 |
+
|
| 118 |
+
if mode == "fixed":
|
| 119 |
+
offsets_ = np.cumsum([0] + [w + sep for w in widths])
|
| 120 |
+
offsets = offsets_[:-1]
|
| 121 |
+
if total is None:
|
| 122 |
+
total = offsets_[-1] - sep
|
| 123 |
+
return total, offsets
|
| 124 |
+
|
| 125 |
+
elif mode == "expand":
|
| 126 |
+
# This is a bit of a hack to avoid a TypeError when *total*
|
| 127 |
+
# is None and used in conjugation with tight layout.
|
| 128 |
+
if total is None:
|
| 129 |
+
total = 1
|
| 130 |
+
if len(widths) > 1:
|
| 131 |
+
sep = (total - sum(widths)) / (len(widths) - 1)
|
| 132 |
+
else:
|
| 133 |
+
sep = 0
|
| 134 |
+
offsets_ = np.cumsum([0] + [w + sep for w in widths])
|
| 135 |
+
offsets = offsets_[:-1]
|
| 136 |
+
return total, offsets
|
| 137 |
+
|
| 138 |
+
elif mode == "equal":
|
| 139 |
+
maxh = max(widths)
|
| 140 |
+
if total is None:
|
| 141 |
+
if sep is None:
|
| 142 |
+
raise ValueError("total and sep cannot both be None when "
|
| 143 |
+
"using layout mode 'equal'")
|
| 144 |
+
total = (maxh + sep) * len(widths)
|
| 145 |
+
else:
|
| 146 |
+
sep = total / len(widths) - maxh
|
| 147 |
+
offsets = (maxh + sep) * np.arange(len(widths))
|
| 148 |
+
return total, offsets
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def _get_aligned_offsets(yspans, height, align="baseline"):
|
| 152 |
+
"""
|
| 153 |
+
Align boxes each specified by their ``(y0, y1)`` spans.
|
| 154 |
+
|
| 155 |
+
For simplicity of the description, the terminology used here assumes a
|
| 156 |
+
horizontal layout (i.e., vertical alignment), but the function works
|
| 157 |
+
equally for a vertical layout.
|
| 158 |
+
|
| 159 |
+
Parameters
|
| 160 |
+
----------
|
| 161 |
+
yspans
|
| 162 |
+
List of (y0, y1) spans of boxes to be aligned.
|
| 163 |
+
height : float or None
|
| 164 |
+
Intended total height. If None, the maximum of the heights
|
| 165 |
+
(``y1 - y0``) in *yspans* is used.
|
| 166 |
+
align : {'baseline', 'left', 'top', 'right', 'bottom', 'center'}
|
| 167 |
+
The alignment anchor of the boxes.
|
| 168 |
+
|
| 169 |
+
Returns
|
| 170 |
+
-------
|
| 171 |
+
(y0, y1)
|
| 172 |
+
y range spanned by the packing. If a *height* was originally passed
|
| 173 |
+
in, then for all alignments other than "baseline", a span of ``(0,
|
| 174 |
+
height)`` is used without checking that it is actually large enough).
|
| 175 |
+
descent
|
| 176 |
+
The descent of the packing.
|
| 177 |
+
offsets
|
| 178 |
+
The bottom offsets of the boxes.
|
| 179 |
+
"""
|
| 180 |
+
|
| 181 |
+
_api.check_in_list(
|
| 182 |
+
["baseline", "left", "top", "right", "bottom", "center"], align=align)
|
| 183 |
+
if height is None:
|
| 184 |
+
height = max(y1 - y0 for y0, y1 in yspans)
|
| 185 |
+
|
| 186 |
+
if align == "baseline":
|
| 187 |
+
yspan = (min(y0 for y0, y1 in yspans), max(y1 for y0, y1 in yspans))
|
| 188 |
+
offsets = [0] * len(yspans)
|
| 189 |
+
elif align in ["left", "bottom"]:
|
| 190 |
+
yspan = (0, height)
|
| 191 |
+
offsets = [-y0 for y0, y1 in yspans]
|
| 192 |
+
elif align in ["right", "top"]:
|
| 193 |
+
yspan = (0, height)
|
| 194 |
+
offsets = [height - y1 for y0, y1 in yspans]
|
| 195 |
+
elif align == "center":
|
| 196 |
+
yspan = (0, height)
|
| 197 |
+
offsets = [(height - (y1 - y0)) * .5 - y0 for y0, y1 in yspans]
|
| 198 |
+
|
| 199 |
+
return yspan, offsets
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class OffsetBox(martist.Artist):
|
| 203 |
+
"""
|
| 204 |
+
The OffsetBox is a simple container artist.
|
| 205 |
+
|
| 206 |
+
The child artists are meant to be drawn at a relative position to its
|
| 207 |
+
parent.
|
| 208 |
+
|
| 209 |
+
Being an artist itself, all parameters are passed on to `.Artist`.
|
| 210 |
+
"""
|
| 211 |
+
def __init__(self, *args, **kwargs):
|
| 212 |
+
super().__init__(*args)
|
| 213 |
+
self._internal_update(kwargs)
|
| 214 |
+
# Clipping has not been implemented in the OffsetBox family, so
|
| 215 |
+
# disable the clip flag for consistency. It can always be turned back
|
| 216 |
+
# on to zero effect.
|
| 217 |
+
self.set_clip_on(False)
|
| 218 |
+
self._children = []
|
| 219 |
+
self._offset = (0, 0)
|
| 220 |
+
|
| 221 |
+
def set_figure(self, fig):
|
| 222 |
+
"""
|
| 223 |
+
Set the `.Figure` for the `.OffsetBox` and all its children.
|
| 224 |
+
|
| 225 |
+
Parameters
|
| 226 |
+
----------
|
| 227 |
+
fig : `~matplotlib.figure.Figure`
|
| 228 |
+
"""
|
| 229 |
+
super().set_figure(fig)
|
| 230 |
+
for c in self.get_children():
|
| 231 |
+
c.set_figure(fig)
|
| 232 |
+
|
| 233 |
+
@martist.Artist.axes.setter
|
| 234 |
+
def axes(self, ax):
|
| 235 |
+
# TODO deal with this better
|
| 236 |
+
martist.Artist.axes.fset(self, ax)
|
| 237 |
+
for c in self.get_children():
|
| 238 |
+
if c is not None:
|
| 239 |
+
c.axes = ax
|
| 240 |
+
|
| 241 |
+
def contains(self, mouseevent):
|
| 242 |
+
"""
|
| 243 |
+
Delegate the mouse event contains-check to the children.
|
| 244 |
+
|
| 245 |
+
As a container, the `.OffsetBox` does not respond itself to
|
| 246 |
+
mouseevents.
|
| 247 |
+
|
| 248 |
+
Parameters
|
| 249 |
+
----------
|
| 250 |
+
mouseevent : `~matplotlib.backend_bases.MouseEvent`
|
| 251 |
+
|
| 252 |
+
Returns
|
| 253 |
+
-------
|
| 254 |
+
contains : bool
|
| 255 |
+
Whether any values are within the radius.
|
| 256 |
+
details : dict
|
| 257 |
+
An artist-specific dictionary of details of the event context,
|
| 258 |
+
such as which points are contained in the pick radius. See the
|
| 259 |
+
individual Artist subclasses for details.
|
| 260 |
+
|
| 261 |
+
See Also
|
| 262 |
+
--------
|
| 263 |
+
.Artist.contains
|
| 264 |
+
"""
|
| 265 |
+
if self._different_canvas(mouseevent):
|
| 266 |
+
return False, {}
|
| 267 |
+
for c in self.get_children():
|
| 268 |
+
a, b = c.contains(mouseevent)
|
| 269 |
+
if a:
|
| 270 |
+
return a, b
|
| 271 |
+
return False, {}
|
| 272 |
+
|
| 273 |
+
def set_offset(self, xy):
|
| 274 |
+
"""
|
| 275 |
+
Set the offset.
|
| 276 |
+
|
| 277 |
+
Parameters
|
| 278 |
+
----------
|
| 279 |
+
xy : (float, float) or callable
|
| 280 |
+
The (x, y) coordinates of the offset in display units. These can
|
| 281 |
+
either be given explicitly as a tuple (x, y), or by providing a
|
| 282 |
+
function that converts the extent into the offset. This function
|
| 283 |
+
must have the signature::
|
| 284 |
+
|
| 285 |
+
def offset(width, height, xdescent, ydescent, renderer) \
|
| 286 |
+
-> (float, float)
|
| 287 |
+
"""
|
| 288 |
+
self._offset = xy
|
| 289 |
+
self.stale = True
|
| 290 |
+
|
| 291 |
+
@_compat_get_offset
|
| 292 |
+
def get_offset(self, bbox, renderer):
|
| 293 |
+
"""
|
| 294 |
+
Return the offset as a tuple (x, y).
|
| 295 |
+
|
| 296 |
+
The extent parameters have to be provided to handle the case where the
|
| 297 |
+
offset is dynamically determined by a callable (see
|
| 298 |
+
`~.OffsetBox.set_offset`).
|
| 299 |
+
|
| 300 |
+
Parameters
|
| 301 |
+
----------
|
| 302 |
+
bbox : `.Bbox`
|
| 303 |
+
renderer : `.RendererBase` subclass
|
| 304 |
+
"""
|
| 305 |
+
return (
|
| 306 |
+
self._offset(bbox.width, bbox.height, -bbox.x0, -bbox.y0, renderer)
|
| 307 |
+
if callable(self._offset)
|
| 308 |
+
else self._offset)
|
| 309 |
+
|
| 310 |
+
def set_width(self, width):
|
| 311 |
+
"""
|
| 312 |
+
Set the width of the box.
|
| 313 |
+
|
| 314 |
+
Parameters
|
| 315 |
+
----------
|
| 316 |
+
width : float
|
| 317 |
+
"""
|
| 318 |
+
self.width = width
|
| 319 |
+
self.stale = True
|
| 320 |
+
|
| 321 |
+
def set_height(self, height):
|
| 322 |
+
"""
|
| 323 |
+
Set the height of the box.
|
| 324 |
+
|
| 325 |
+
Parameters
|
| 326 |
+
----------
|
| 327 |
+
height : float
|
| 328 |
+
"""
|
| 329 |
+
self.height = height
|
| 330 |
+
self.stale = True
|
| 331 |
+
|
| 332 |
+
def get_visible_children(self):
|
| 333 |
+
r"""Return a list of the visible child `.Artist`\s."""
|
| 334 |
+
return [c for c in self._children if c.get_visible()]
|
| 335 |
+
|
| 336 |
+
def get_children(self):
|
| 337 |
+
r"""Return a list of the child `.Artist`\s."""
|
| 338 |
+
return self._children
|
| 339 |
+
|
| 340 |
+
def _get_bbox_and_child_offsets(self, renderer):
|
| 341 |
+
"""
|
| 342 |
+
Return the bbox of the offsetbox and the child offsets.
|
| 343 |
+
|
| 344 |
+
The bbox should satisfy ``x0 <= x1 and y0 <= y1``.
|
| 345 |
+
|
| 346 |
+
Parameters
|
| 347 |
+
----------
|
| 348 |
+
renderer : `.RendererBase` subclass
|
| 349 |
+
|
| 350 |
+
Returns
|
| 351 |
+
-------
|
| 352 |
+
bbox
|
| 353 |
+
list of (xoffset, yoffset) pairs
|
| 354 |
+
"""
|
| 355 |
+
raise NotImplementedError(
|
| 356 |
+
"get_bbox_and_offsets must be overridden in derived classes")
|
| 357 |
+
|
| 358 |
+
def get_bbox(self, renderer):
|
| 359 |
+
"""Return the bbox of the offsetbox, ignoring parent offsets."""
|
| 360 |
+
bbox, offsets = self._get_bbox_and_child_offsets(renderer)
|
| 361 |
+
return bbox
|
| 362 |
+
|
| 363 |
+
def get_window_extent(self, renderer=None):
|
| 364 |
+
# docstring inherited
|
| 365 |
+
if renderer is None:
|
| 366 |
+
renderer = self.get_figure(root=True)._get_renderer()
|
| 367 |
+
bbox = self.get_bbox(renderer)
|
| 368 |
+
try: # Some subclasses redefine get_offset to take no args.
|
| 369 |
+
px, py = self.get_offset(bbox, renderer)
|
| 370 |
+
except TypeError:
|
| 371 |
+
px, py = self.get_offset()
|
| 372 |
+
return bbox.translated(px, py)
|
| 373 |
+
|
| 374 |
+
def draw(self, renderer):
|
| 375 |
+
"""
|
| 376 |
+
Update the location of children if necessary and draw them
|
| 377 |
+
to the given *renderer*.
|
| 378 |
+
"""
|
| 379 |
+
bbox, offsets = self._get_bbox_and_child_offsets(renderer)
|
| 380 |
+
px, py = self.get_offset(bbox, renderer)
|
| 381 |
+
for c, (ox, oy) in zip(self.get_visible_children(), offsets):
|
| 382 |
+
c.set_offset((px + ox, py + oy))
|
| 383 |
+
c.draw(renderer)
|
| 384 |
+
_bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 385 |
+
self.stale = False
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
class PackerBase(OffsetBox):
|
| 389 |
+
def __init__(self, pad=0., sep=0., width=None, height=None,
|
| 390 |
+
align="baseline", mode="fixed", children=None):
|
| 391 |
+
"""
|
| 392 |
+
Parameters
|
| 393 |
+
----------
|
| 394 |
+
pad : float, default: 0.0
|
| 395 |
+
The boundary padding in points.
|
| 396 |
+
|
| 397 |
+
sep : float, default: 0.0
|
| 398 |
+
The spacing between items in points.
|
| 399 |
+
|
| 400 |
+
width, height : float, optional
|
| 401 |
+
Width and height of the container box in pixels, calculated if
|
| 402 |
+
*None*.
|
| 403 |
+
|
| 404 |
+
align : {'top', 'bottom', 'left', 'right', 'center', 'baseline'}, \
|
| 405 |
+
default: 'baseline'
|
| 406 |
+
Alignment of boxes.
|
| 407 |
+
|
| 408 |
+
mode : {'fixed', 'expand', 'equal'}, default: 'fixed'
|
| 409 |
+
The packing mode.
|
| 410 |
+
|
| 411 |
+
- 'fixed' packs the given `.Artist`\\s tight with *sep* spacing.
|
| 412 |
+
- 'expand' uses the maximal available space to distribute the
|
| 413 |
+
artists with equal spacing in between.
|
| 414 |
+
- 'equal': Each artist an equal fraction of the available space
|
| 415 |
+
and is left-aligned (or top-aligned) therein.
|
| 416 |
+
|
| 417 |
+
children : list of `.Artist`
|
| 418 |
+
The artists to pack.
|
| 419 |
+
|
| 420 |
+
Notes
|
| 421 |
+
-----
|
| 422 |
+
*pad* and *sep* are in points and will be scaled with the renderer
|
| 423 |
+
dpi, while *width* and *height* are in pixels.
|
| 424 |
+
"""
|
| 425 |
+
super().__init__()
|
| 426 |
+
self.height = height
|
| 427 |
+
self.width = width
|
| 428 |
+
self.sep = sep
|
| 429 |
+
self.pad = pad
|
| 430 |
+
self.mode = mode
|
| 431 |
+
self.align = align
|
| 432 |
+
self._children = children
|
| 433 |
+
|
| 434 |
+
|
| 435 |
+
class VPacker(PackerBase):
|
| 436 |
+
"""
|
| 437 |
+
VPacker packs its children vertically, automatically adjusting their
|
| 438 |
+
relative positions at draw time.
|
| 439 |
+
"""
|
| 440 |
+
|
| 441 |
+
def _get_bbox_and_child_offsets(self, renderer):
|
| 442 |
+
# docstring inherited
|
| 443 |
+
dpicor = renderer.points_to_pixels(1.)
|
| 444 |
+
pad = self.pad * dpicor
|
| 445 |
+
sep = self.sep * dpicor
|
| 446 |
+
|
| 447 |
+
if self.width is not None:
|
| 448 |
+
for c in self.get_visible_children():
|
| 449 |
+
if isinstance(c, PackerBase) and c.mode == "expand":
|
| 450 |
+
c.set_width(self.width)
|
| 451 |
+
|
| 452 |
+
bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
|
| 453 |
+
(x0, x1), xoffsets = _get_aligned_offsets(
|
| 454 |
+
[bbox.intervalx for bbox in bboxes], self.width, self.align)
|
| 455 |
+
height, yoffsets = _get_packed_offsets(
|
| 456 |
+
[bbox.height for bbox in bboxes], self.height, sep, self.mode)
|
| 457 |
+
|
| 458 |
+
yoffsets = height - (yoffsets + [bbox.y1 for bbox in bboxes])
|
| 459 |
+
ydescent = yoffsets[0]
|
| 460 |
+
yoffsets = yoffsets - ydescent
|
| 461 |
+
|
| 462 |
+
return (
|
| 463 |
+
Bbox.from_bounds(x0, -ydescent, x1 - x0, height).padded(pad),
|
| 464 |
+
[*zip(xoffsets, yoffsets)])
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
class HPacker(PackerBase):
|
| 468 |
+
"""
|
| 469 |
+
HPacker packs its children horizontally, automatically adjusting their
|
| 470 |
+
relative positions at draw time.
|
| 471 |
+
"""
|
| 472 |
+
|
| 473 |
+
def _get_bbox_and_child_offsets(self, renderer):
|
| 474 |
+
# docstring inherited
|
| 475 |
+
dpicor = renderer.points_to_pixels(1.)
|
| 476 |
+
pad = self.pad * dpicor
|
| 477 |
+
sep = self.sep * dpicor
|
| 478 |
+
|
| 479 |
+
bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
|
| 480 |
+
if not bboxes:
|
| 481 |
+
return Bbox.from_bounds(0, 0, 0, 0).padded(pad), []
|
| 482 |
+
|
| 483 |
+
(y0, y1), yoffsets = _get_aligned_offsets(
|
| 484 |
+
[bbox.intervaly for bbox in bboxes], self.height, self.align)
|
| 485 |
+
width, xoffsets = _get_packed_offsets(
|
| 486 |
+
[bbox.width for bbox in bboxes], self.width, sep, self.mode)
|
| 487 |
+
|
| 488 |
+
x0 = bboxes[0].x0
|
| 489 |
+
xoffsets -= ([bbox.x0 for bbox in bboxes] - x0)
|
| 490 |
+
|
| 491 |
+
return (Bbox.from_bounds(x0, y0, width, y1 - y0).padded(pad),
|
| 492 |
+
[*zip(xoffsets, yoffsets)])
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
class PaddedBox(OffsetBox):
|
| 496 |
+
"""
|
| 497 |
+
A container to add a padding around an `.Artist`.
|
| 498 |
+
|
| 499 |
+
The `.PaddedBox` contains a `.FancyBboxPatch` that is used to visualize
|
| 500 |
+
it when rendering.
|
| 501 |
+
"""
|
| 502 |
+
|
| 503 |
+
def __init__(self, child, pad=0., *, draw_frame=False, patch_attrs=None):
|
| 504 |
+
"""
|
| 505 |
+
Parameters
|
| 506 |
+
----------
|
| 507 |
+
child : `~matplotlib.artist.Artist`
|
| 508 |
+
The contained `.Artist`.
|
| 509 |
+
pad : float, default: 0.0
|
| 510 |
+
The padding in points. This will be scaled with the renderer dpi.
|
| 511 |
+
In contrast, *width* and *height* are in *pixels* and thus not
|
| 512 |
+
scaled.
|
| 513 |
+
draw_frame : bool
|
| 514 |
+
Whether to draw the contained `.FancyBboxPatch`.
|
| 515 |
+
patch_attrs : dict or None
|
| 516 |
+
Additional parameters passed to the contained `.FancyBboxPatch`.
|
| 517 |
+
"""
|
| 518 |
+
super().__init__()
|
| 519 |
+
self.pad = pad
|
| 520 |
+
self._children = [child]
|
| 521 |
+
self.patch = FancyBboxPatch(
|
| 522 |
+
xy=(0.0, 0.0), width=1., height=1.,
|
| 523 |
+
facecolor='w', edgecolor='k',
|
| 524 |
+
mutation_scale=1, # self.prop.get_size_in_points(),
|
| 525 |
+
snap=True,
|
| 526 |
+
visible=draw_frame,
|
| 527 |
+
boxstyle="square,pad=0",
|
| 528 |
+
)
|
| 529 |
+
if patch_attrs is not None:
|
| 530 |
+
self.patch.update(patch_attrs)
|
| 531 |
+
|
| 532 |
+
def _get_bbox_and_child_offsets(self, renderer):
|
| 533 |
+
# docstring inherited.
|
| 534 |
+
pad = self.pad * renderer.points_to_pixels(1.)
|
| 535 |
+
return (self._children[0].get_bbox(renderer).padded(pad), [(0, 0)])
|
| 536 |
+
|
| 537 |
+
def draw(self, renderer):
|
| 538 |
+
# docstring inherited
|
| 539 |
+
bbox, offsets = self._get_bbox_and_child_offsets(renderer)
|
| 540 |
+
px, py = self.get_offset(bbox, renderer)
|
| 541 |
+
for c, (ox, oy) in zip(self.get_visible_children(), offsets):
|
| 542 |
+
c.set_offset((px + ox, py + oy))
|
| 543 |
+
|
| 544 |
+
self.draw_frame(renderer)
|
| 545 |
+
|
| 546 |
+
for c in self.get_visible_children():
|
| 547 |
+
c.draw(renderer)
|
| 548 |
+
|
| 549 |
+
self.stale = False
|
| 550 |
+
|
| 551 |
+
def update_frame(self, bbox, fontsize=None):
|
| 552 |
+
self.patch.set_bounds(bbox.bounds)
|
| 553 |
+
if fontsize:
|
| 554 |
+
self.patch.set_mutation_scale(fontsize)
|
| 555 |
+
self.stale = True
|
| 556 |
+
|
| 557 |
+
def draw_frame(self, renderer):
|
| 558 |
+
# update the location and size of the legend
|
| 559 |
+
self.update_frame(self.get_window_extent(renderer))
|
| 560 |
+
self.patch.draw(renderer)
|
| 561 |
+
|
| 562 |
+
|
| 563 |
+
class DrawingArea(OffsetBox):
|
| 564 |
+
"""
|
| 565 |
+
The DrawingArea can contain any Artist as a child. The DrawingArea
|
| 566 |
+
has a fixed width and height. The position of children relative to
|
| 567 |
+
the parent is fixed. The children can be clipped at the
|
| 568 |
+
boundaries of the parent.
|
| 569 |
+
"""
|
| 570 |
+
|
| 571 |
+
def __init__(self, width, height, xdescent=0., ydescent=0., clip=False):
|
| 572 |
+
"""
|
| 573 |
+
Parameters
|
| 574 |
+
----------
|
| 575 |
+
width, height : float
|
| 576 |
+
Width and height of the container box.
|
| 577 |
+
xdescent, ydescent : float
|
| 578 |
+
Descent of the box in x- and y-direction.
|
| 579 |
+
clip : bool
|
| 580 |
+
Whether to clip the children to the box.
|
| 581 |
+
"""
|
| 582 |
+
super().__init__()
|
| 583 |
+
self.width = width
|
| 584 |
+
self.height = height
|
| 585 |
+
self.xdescent = xdescent
|
| 586 |
+
self.ydescent = ydescent
|
| 587 |
+
self._clip_children = clip
|
| 588 |
+
self.offset_transform = mtransforms.Affine2D()
|
| 589 |
+
self.dpi_transform = mtransforms.Affine2D()
|
| 590 |
+
|
| 591 |
+
@property
|
| 592 |
+
def clip_children(self):
|
| 593 |
+
"""
|
| 594 |
+
If the children of this DrawingArea should be clipped
|
| 595 |
+
by DrawingArea bounding box.
|
| 596 |
+
"""
|
| 597 |
+
return self._clip_children
|
| 598 |
+
|
| 599 |
+
@clip_children.setter
|
| 600 |
+
def clip_children(self, val):
|
| 601 |
+
self._clip_children = bool(val)
|
| 602 |
+
self.stale = True
|
| 603 |
+
|
| 604 |
+
def get_transform(self):
|
| 605 |
+
"""
|
| 606 |
+
Return the `~matplotlib.transforms.Transform` applied to the children.
|
| 607 |
+
"""
|
| 608 |
+
return self.dpi_transform + self.offset_transform
|
| 609 |
+
|
| 610 |
+
def set_transform(self, t):
|
| 611 |
+
"""
|
| 612 |
+
set_transform is ignored.
|
| 613 |
+
"""
|
| 614 |
+
|
| 615 |
+
def set_offset(self, xy):
|
| 616 |
+
"""
|
| 617 |
+
Set the offset of the container.
|
| 618 |
+
|
| 619 |
+
Parameters
|
| 620 |
+
----------
|
| 621 |
+
xy : (float, float)
|
| 622 |
+
The (x, y) coordinates of the offset in display units.
|
| 623 |
+
"""
|
| 624 |
+
self._offset = xy
|
| 625 |
+
self.offset_transform.clear()
|
| 626 |
+
self.offset_transform.translate(xy[0], xy[1])
|
| 627 |
+
self.stale = True
|
| 628 |
+
|
| 629 |
+
def get_offset(self):
|
| 630 |
+
"""Return offset of the container."""
|
| 631 |
+
return self._offset
|
| 632 |
+
|
| 633 |
+
def get_bbox(self, renderer):
|
| 634 |
+
# docstring inherited
|
| 635 |
+
dpi_cor = renderer.points_to_pixels(1.)
|
| 636 |
+
return Bbox.from_bounds(
|
| 637 |
+
-self.xdescent * dpi_cor, -self.ydescent * dpi_cor,
|
| 638 |
+
self.width * dpi_cor, self.height * dpi_cor)
|
| 639 |
+
|
| 640 |
+
def add_artist(self, a):
|
| 641 |
+
"""Add an `.Artist` to the container box."""
|
| 642 |
+
self._children.append(a)
|
| 643 |
+
if not a.is_transform_set():
|
| 644 |
+
a.set_transform(self.get_transform())
|
| 645 |
+
if self.axes is not None:
|
| 646 |
+
a.axes = self.axes
|
| 647 |
+
fig = self.get_figure(root=False)
|
| 648 |
+
if fig is not None:
|
| 649 |
+
a.set_figure(fig)
|
| 650 |
+
|
| 651 |
+
def draw(self, renderer):
|
| 652 |
+
# docstring inherited
|
| 653 |
+
|
| 654 |
+
dpi_cor = renderer.points_to_pixels(1.)
|
| 655 |
+
self.dpi_transform.clear()
|
| 656 |
+
self.dpi_transform.scale(dpi_cor)
|
| 657 |
+
|
| 658 |
+
# At this point the DrawingArea has a transform
|
| 659 |
+
# to the display space so the path created is
|
| 660 |
+
# good for clipping children
|
| 661 |
+
tpath = mtransforms.TransformedPath(
|
| 662 |
+
mpath.Path([[0, 0], [0, self.height],
|
| 663 |
+
[self.width, self.height],
|
| 664 |
+
[self.width, 0]]),
|
| 665 |
+
self.get_transform())
|
| 666 |
+
for c in self._children:
|
| 667 |
+
if self._clip_children and not (c.clipbox or c._clippath):
|
| 668 |
+
c.set_clip_path(tpath)
|
| 669 |
+
c.draw(renderer)
|
| 670 |
+
|
| 671 |
+
_bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 672 |
+
self.stale = False
|
| 673 |
+
|
| 674 |
+
|
| 675 |
+
class TextArea(OffsetBox):
|
| 676 |
+
"""
|
| 677 |
+
The TextArea is a container artist for a single Text instance.
|
| 678 |
+
|
| 679 |
+
The text is placed at (0, 0) with baseline+left alignment, by default. The
|
| 680 |
+
width and height of the TextArea instance is the width and height of its
|
| 681 |
+
child text.
|
| 682 |
+
"""
|
| 683 |
+
|
| 684 |
+
def __init__(self, s,
|
| 685 |
+
*,
|
| 686 |
+
textprops=None,
|
| 687 |
+
multilinebaseline=False,
|
| 688 |
+
):
|
| 689 |
+
"""
|
| 690 |
+
Parameters
|
| 691 |
+
----------
|
| 692 |
+
s : str
|
| 693 |
+
The text to be displayed.
|
| 694 |
+
textprops : dict, default: {}
|
| 695 |
+
Dictionary of keyword parameters to be passed to the `.Text`
|
| 696 |
+
instance in the TextArea.
|
| 697 |
+
multilinebaseline : bool, default: False
|
| 698 |
+
Whether the baseline for multiline text is adjusted so that it
|
| 699 |
+
is (approximately) center-aligned with single-line text.
|
| 700 |
+
"""
|
| 701 |
+
if textprops is None:
|
| 702 |
+
textprops = {}
|
| 703 |
+
self._text = mtext.Text(0, 0, s, **textprops)
|
| 704 |
+
super().__init__()
|
| 705 |
+
self._children = [self._text]
|
| 706 |
+
self.offset_transform = mtransforms.Affine2D()
|
| 707 |
+
self._baseline_transform = mtransforms.Affine2D()
|
| 708 |
+
self._text.set_transform(self.offset_transform +
|
| 709 |
+
self._baseline_transform)
|
| 710 |
+
self._multilinebaseline = multilinebaseline
|
| 711 |
+
|
| 712 |
+
def set_text(self, s):
|
| 713 |
+
"""Set the text of this area as a string."""
|
| 714 |
+
self._text.set_text(s)
|
| 715 |
+
self.stale = True
|
| 716 |
+
|
| 717 |
+
def get_text(self):
|
| 718 |
+
"""Return the string representation of this area's text."""
|
| 719 |
+
return self._text.get_text()
|
| 720 |
+
|
| 721 |
+
def set_multilinebaseline(self, t):
|
| 722 |
+
"""
|
| 723 |
+
Set multilinebaseline.
|
| 724 |
+
|
| 725 |
+
If True, the baseline for multiline text is adjusted so that it is
|
| 726 |
+
(approximately) center-aligned with single-line text. This is used
|
| 727 |
+
e.g. by the legend implementation so that single-line labels are
|
| 728 |
+
baseline-aligned, but multiline labels are "center"-aligned with them.
|
| 729 |
+
"""
|
| 730 |
+
self._multilinebaseline = t
|
| 731 |
+
self.stale = True
|
| 732 |
+
|
| 733 |
+
def get_multilinebaseline(self):
|
| 734 |
+
"""
|
| 735 |
+
Get multilinebaseline.
|
| 736 |
+
"""
|
| 737 |
+
return self._multilinebaseline
|
| 738 |
+
|
| 739 |
+
def set_transform(self, t):
|
| 740 |
+
"""
|
| 741 |
+
set_transform is ignored.
|
| 742 |
+
"""
|
| 743 |
+
|
| 744 |
+
def set_offset(self, xy):
|
| 745 |
+
"""
|
| 746 |
+
Set the offset of the container.
|
| 747 |
+
|
| 748 |
+
Parameters
|
| 749 |
+
----------
|
| 750 |
+
xy : (float, float)
|
| 751 |
+
The (x, y) coordinates of the offset in display units.
|
| 752 |
+
"""
|
| 753 |
+
self._offset = xy
|
| 754 |
+
self.offset_transform.clear()
|
| 755 |
+
self.offset_transform.translate(xy[0], xy[1])
|
| 756 |
+
self.stale = True
|
| 757 |
+
|
| 758 |
+
def get_offset(self):
|
| 759 |
+
"""Return offset of the container."""
|
| 760 |
+
return self._offset
|
| 761 |
+
|
| 762 |
+
def get_bbox(self, renderer):
|
| 763 |
+
_, h_, d_ = renderer.get_text_width_height_descent(
|
| 764 |
+
"lp", self._text._fontproperties,
|
| 765 |
+
ismath="TeX" if self._text.get_usetex() else False)
|
| 766 |
+
|
| 767 |
+
bbox, info, yd = self._text._get_layout(renderer)
|
| 768 |
+
w, h = bbox.size
|
| 769 |
+
|
| 770 |
+
self._baseline_transform.clear()
|
| 771 |
+
|
| 772 |
+
if len(info) > 1 and self._multilinebaseline:
|
| 773 |
+
yd_new = 0.5 * h - 0.5 * (h_ - d_)
|
| 774 |
+
self._baseline_transform.translate(0, yd - yd_new)
|
| 775 |
+
yd = yd_new
|
| 776 |
+
else: # single line
|
| 777 |
+
h_d = max(h_ - d_, h - yd)
|
| 778 |
+
h = h_d + yd
|
| 779 |
+
|
| 780 |
+
ha = self._text.get_horizontalalignment()
|
| 781 |
+
x0 = {"left": 0, "center": -w / 2, "right": -w}[ha]
|
| 782 |
+
|
| 783 |
+
return Bbox.from_bounds(x0, -yd, w, h)
|
| 784 |
+
|
| 785 |
+
def draw(self, renderer):
|
| 786 |
+
# docstring inherited
|
| 787 |
+
self._text.draw(renderer)
|
| 788 |
+
_bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 789 |
+
self.stale = False
|
| 790 |
+
|
| 791 |
+
|
| 792 |
+
class AuxTransformBox(OffsetBox):
|
| 793 |
+
"""
|
| 794 |
+
Offset Box with the aux_transform. Its children will be
|
| 795 |
+
transformed with the aux_transform first then will be
|
| 796 |
+
offsetted. The absolute coordinate of the aux_transform is meaning
|
| 797 |
+
as it will be automatically adjust so that the left-lower corner
|
| 798 |
+
of the bounding box of children will be set to (0, 0) before the
|
| 799 |
+
offset transform.
|
| 800 |
+
|
| 801 |
+
It is similar to drawing area, except that the extent of the box
|
| 802 |
+
is not predetermined but calculated from the window extent of its
|
| 803 |
+
children. Furthermore, the extent of the children will be
|
| 804 |
+
calculated in the transformed coordinate.
|
| 805 |
+
"""
|
| 806 |
+
def __init__(self, aux_transform):
|
| 807 |
+
self.aux_transform = aux_transform
|
| 808 |
+
super().__init__()
|
| 809 |
+
self.offset_transform = mtransforms.Affine2D()
|
| 810 |
+
# ref_offset_transform makes offset_transform always relative to the
|
| 811 |
+
# lower-left corner of the bbox of its children.
|
| 812 |
+
self.ref_offset_transform = mtransforms.Affine2D()
|
| 813 |
+
|
| 814 |
+
def add_artist(self, a):
|
| 815 |
+
"""Add an `.Artist` to the container box."""
|
| 816 |
+
self._children.append(a)
|
| 817 |
+
a.set_transform(self.get_transform())
|
| 818 |
+
self.stale = True
|
| 819 |
+
|
| 820 |
+
def get_transform(self):
|
| 821 |
+
"""
|
| 822 |
+
Return the :class:`~matplotlib.transforms.Transform` applied
|
| 823 |
+
to the children
|
| 824 |
+
"""
|
| 825 |
+
return (self.aux_transform
|
| 826 |
+
+ self.ref_offset_transform
|
| 827 |
+
+ self.offset_transform)
|
| 828 |
+
|
| 829 |
+
def set_transform(self, t):
|
| 830 |
+
"""
|
| 831 |
+
set_transform is ignored.
|
| 832 |
+
"""
|
| 833 |
+
|
| 834 |
+
def set_offset(self, xy):
|
| 835 |
+
"""
|
| 836 |
+
Set the offset of the container.
|
| 837 |
+
|
| 838 |
+
Parameters
|
| 839 |
+
----------
|
| 840 |
+
xy : (float, float)
|
| 841 |
+
The (x, y) coordinates of the offset in display units.
|
| 842 |
+
"""
|
| 843 |
+
self._offset = xy
|
| 844 |
+
self.offset_transform.clear()
|
| 845 |
+
self.offset_transform.translate(xy[0], xy[1])
|
| 846 |
+
self.stale = True
|
| 847 |
+
|
| 848 |
+
def get_offset(self):
|
| 849 |
+
"""Return offset of the container."""
|
| 850 |
+
return self._offset
|
| 851 |
+
|
| 852 |
+
def get_bbox(self, renderer):
|
| 853 |
+
# clear the offset transforms
|
| 854 |
+
_off = self.offset_transform.get_matrix() # to be restored later
|
| 855 |
+
self.ref_offset_transform.clear()
|
| 856 |
+
self.offset_transform.clear()
|
| 857 |
+
# calculate the extent
|
| 858 |
+
bboxes = [c.get_window_extent(renderer) for c in self._children]
|
| 859 |
+
ub = Bbox.union(bboxes)
|
| 860 |
+
# adjust ref_offset_transform
|
| 861 |
+
self.ref_offset_transform.translate(-ub.x0, -ub.y0)
|
| 862 |
+
# restore offset transform
|
| 863 |
+
self.offset_transform.set_matrix(_off)
|
| 864 |
+
return Bbox.from_bounds(0, 0, ub.width, ub.height)
|
| 865 |
+
|
| 866 |
+
def draw(self, renderer):
|
| 867 |
+
# docstring inherited
|
| 868 |
+
for c in self._children:
|
| 869 |
+
c.draw(renderer)
|
| 870 |
+
_bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 871 |
+
self.stale = False
|
| 872 |
+
|
| 873 |
+
|
| 874 |
+
class AnchoredOffsetbox(OffsetBox):
|
| 875 |
+
"""
|
| 876 |
+
An offset box placed according to location *loc*.
|
| 877 |
+
|
| 878 |
+
AnchoredOffsetbox has a single child. When multiple children are needed,
|
| 879 |
+
use an extra OffsetBox to enclose them. By default, the offset box is
|
| 880 |
+
anchored against its parent Axes. You may explicitly specify the
|
| 881 |
+
*bbox_to_anchor*.
|
| 882 |
+
"""
|
| 883 |
+
zorder = 5 # zorder of the legend
|
| 884 |
+
|
| 885 |
+
# Location codes
|
| 886 |
+
codes = {'upper right': 1,
|
| 887 |
+
'upper left': 2,
|
| 888 |
+
'lower left': 3,
|
| 889 |
+
'lower right': 4,
|
| 890 |
+
'right': 5,
|
| 891 |
+
'center left': 6,
|
| 892 |
+
'center right': 7,
|
| 893 |
+
'lower center': 8,
|
| 894 |
+
'upper center': 9,
|
| 895 |
+
'center': 10,
|
| 896 |
+
}
|
| 897 |
+
|
| 898 |
+
def __init__(self, loc, *,
|
| 899 |
+
pad=0.4, borderpad=0.5,
|
| 900 |
+
child=None, prop=None, frameon=True,
|
| 901 |
+
bbox_to_anchor=None,
|
| 902 |
+
bbox_transform=None,
|
| 903 |
+
**kwargs):
|
| 904 |
+
"""
|
| 905 |
+
Parameters
|
| 906 |
+
----------
|
| 907 |
+
loc : str
|
| 908 |
+
The box location. Valid locations are
|
| 909 |
+
'upper left', 'upper center', 'upper right',
|
| 910 |
+
'center left', 'center', 'center right',
|
| 911 |
+
'lower left', 'lower center', 'lower right'.
|
| 912 |
+
For backward compatibility, numeric values are accepted as well.
|
| 913 |
+
See the parameter *loc* of `.Legend` for details.
|
| 914 |
+
pad : float, default: 0.4
|
| 915 |
+
Padding around the child as fraction of the fontsize.
|
| 916 |
+
borderpad : float, default: 0.5
|
| 917 |
+
Padding between the offsetbox frame and the *bbox_to_anchor*.
|
| 918 |
+
child : `.OffsetBox`
|
| 919 |
+
The box that will be anchored.
|
| 920 |
+
prop : `.FontProperties`
|
| 921 |
+
This is only used as a reference for paddings. If not given,
|
| 922 |
+
:rc:`legend.fontsize` is used.
|
| 923 |
+
frameon : bool
|
| 924 |
+
Whether to draw a frame around the box.
|
| 925 |
+
bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
|
| 926 |
+
Box that is used to position the legend in conjunction with *loc*.
|
| 927 |
+
bbox_transform : None or :class:`matplotlib.transforms.Transform`
|
| 928 |
+
The transform for the bounding box (*bbox_to_anchor*).
|
| 929 |
+
**kwargs
|
| 930 |
+
All other parameters are passed on to `.OffsetBox`.
|
| 931 |
+
|
| 932 |
+
Notes
|
| 933 |
+
-----
|
| 934 |
+
See `.Legend` for a detailed description of the anchoring mechanism.
|
| 935 |
+
"""
|
| 936 |
+
super().__init__(**kwargs)
|
| 937 |
+
|
| 938 |
+
self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform)
|
| 939 |
+
self.set_child(child)
|
| 940 |
+
|
| 941 |
+
if isinstance(loc, str):
|
| 942 |
+
loc = _api.check_getitem(self.codes, loc=loc)
|
| 943 |
+
|
| 944 |
+
self.loc = loc
|
| 945 |
+
self.borderpad = borderpad
|
| 946 |
+
self.pad = pad
|
| 947 |
+
|
| 948 |
+
if prop is None:
|
| 949 |
+
self.prop = FontProperties(size=mpl.rcParams["legend.fontsize"])
|
| 950 |
+
else:
|
| 951 |
+
self.prop = FontProperties._from_any(prop)
|
| 952 |
+
if isinstance(prop, dict) and "size" not in prop:
|
| 953 |
+
self.prop.set_size(mpl.rcParams["legend.fontsize"])
|
| 954 |
+
|
| 955 |
+
self.patch = FancyBboxPatch(
|
| 956 |
+
xy=(0.0, 0.0), width=1., height=1.,
|
| 957 |
+
facecolor='w', edgecolor='k',
|
| 958 |
+
mutation_scale=self.prop.get_size_in_points(),
|
| 959 |
+
snap=True,
|
| 960 |
+
visible=frameon,
|
| 961 |
+
boxstyle="square,pad=0",
|
| 962 |
+
)
|
| 963 |
+
|
| 964 |
+
def set_child(self, child):
|
| 965 |
+
"""Set the child to be anchored."""
|
| 966 |
+
self._child = child
|
| 967 |
+
if child is not None:
|
| 968 |
+
child.axes = self.axes
|
| 969 |
+
self.stale = True
|
| 970 |
+
|
| 971 |
+
def get_child(self):
|
| 972 |
+
"""Return the child."""
|
| 973 |
+
return self._child
|
| 974 |
+
|
| 975 |
+
def get_children(self):
|
| 976 |
+
"""Return the list of children."""
|
| 977 |
+
return [self._child]
|
| 978 |
+
|
| 979 |
+
def get_bbox(self, renderer):
|
| 980 |
+
# docstring inherited
|
| 981 |
+
fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
|
| 982 |
+
pad = self.pad * fontsize
|
| 983 |
+
return self.get_child().get_bbox(renderer).padded(pad)
|
| 984 |
+
|
| 985 |
+
def get_bbox_to_anchor(self):
|
| 986 |
+
"""Return the bbox that the box is anchored to."""
|
| 987 |
+
if self._bbox_to_anchor is None:
|
| 988 |
+
return self.axes.bbox
|
| 989 |
+
else:
|
| 990 |
+
transform = self._bbox_to_anchor_transform
|
| 991 |
+
if transform is None:
|
| 992 |
+
return self._bbox_to_anchor
|
| 993 |
+
else:
|
| 994 |
+
return TransformedBbox(self._bbox_to_anchor, transform)
|
| 995 |
+
|
| 996 |
+
def set_bbox_to_anchor(self, bbox, transform=None):
|
| 997 |
+
"""
|
| 998 |
+
Set the bbox that the box is anchored to.
|
| 999 |
+
|
| 1000 |
+
*bbox* can be a Bbox instance, a list of [left, bottom, width,
|
| 1001 |
+
height], or a list of [left, bottom] where the width and
|
| 1002 |
+
height will be assumed to be zero. The bbox will be
|
| 1003 |
+
transformed to display coordinate by the given transform.
|
| 1004 |
+
"""
|
| 1005 |
+
if bbox is None or isinstance(bbox, BboxBase):
|
| 1006 |
+
self._bbox_to_anchor = bbox
|
| 1007 |
+
else:
|
| 1008 |
+
try:
|
| 1009 |
+
l = len(bbox)
|
| 1010 |
+
except TypeError as err:
|
| 1011 |
+
raise ValueError(f"Invalid bbox: {bbox}") from err
|
| 1012 |
+
|
| 1013 |
+
if l == 2:
|
| 1014 |
+
bbox = [bbox[0], bbox[1], 0, 0]
|
| 1015 |
+
|
| 1016 |
+
self._bbox_to_anchor = Bbox.from_bounds(*bbox)
|
| 1017 |
+
|
| 1018 |
+
self._bbox_to_anchor_transform = transform
|
| 1019 |
+
self.stale = True
|
| 1020 |
+
|
| 1021 |
+
@_compat_get_offset
|
| 1022 |
+
def get_offset(self, bbox, renderer):
|
| 1023 |
+
# docstring inherited
|
| 1024 |
+
pad = (self.borderpad
|
| 1025 |
+
* renderer.points_to_pixels(self.prop.get_size_in_points()))
|
| 1026 |
+
bbox_to_anchor = self.get_bbox_to_anchor()
|
| 1027 |
+
x0, y0 = _get_anchored_bbox(
|
| 1028 |
+
self.loc, Bbox.from_bounds(0, 0, bbox.width, bbox.height),
|
| 1029 |
+
bbox_to_anchor, pad)
|
| 1030 |
+
return x0 - bbox.x0, y0 - bbox.y0
|
| 1031 |
+
|
| 1032 |
+
def update_frame(self, bbox, fontsize=None):
|
| 1033 |
+
self.patch.set_bounds(bbox.bounds)
|
| 1034 |
+
if fontsize:
|
| 1035 |
+
self.patch.set_mutation_scale(fontsize)
|
| 1036 |
+
|
| 1037 |
+
def draw(self, renderer):
|
| 1038 |
+
# docstring inherited
|
| 1039 |
+
if not self.get_visible():
|
| 1040 |
+
return
|
| 1041 |
+
|
| 1042 |
+
# update the location and size of the legend
|
| 1043 |
+
bbox = self.get_window_extent(renderer)
|
| 1044 |
+
fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
|
| 1045 |
+
self.update_frame(bbox, fontsize)
|
| 1046 |
+
self.patch.draw(renderer)
|
| 1047 |
+
|
| 1048 |
+
px, py = self.get_offset(self.get_bbox(renderer), renderer)
|
| 1049 |
+
self.get_child().set_offset((px, py))
|
| 1050 |
+
self.get_child().draw(renderer)
|
| 1051 |
+
self.stale = False
|
| 1052 |
+
|
| 1053 |
+
|
| 1054 |
+
def _get_anchored_bbox(loc, bbox, parentbbox, borderpad):
|
| 1055 |
+
"""
|
| 1056 |
+
Return the (x, y) position of the *bbox* anchored at the *parentbbox* with
|
| 1057 |
+
the *loc* code with the *borderpad*.
|
| 1058 |
+
"""
|
| 1059 |
+
# This is only called internally and *loc* should already have been
|
| 1060 |
+
# validated. If 0 (None), we just let ``bbox.anchored`` raise.
|
| 1061 |
+
c = [None, "NE", "NW", "SW", "SE", "E", "W", "E", "S", "N", "C"][loc]
|
| 1062 |
+
container = parentbbox.padded(-borderpad)
|
| 1063 |
+
return bbox.anchored(c, container=container).p0
|
| 1064 |
+
|
| 1065 |
+
|
| 1066 |
+
class AnchoredText(AnchoredOffsetbox):
|
| 1067 |
+
"""
|
| 1068 |
+
AnchoredOffsetbox with Text.
|
| 1069 |
+
"""
|
| 1070 |
+
|
| 1071 |
+
def __init__(self, s, loc, *, pad=0.4, borderpad=0.5, prop=None, **kwargs):
|
| 1072 |
+
"""
|
| 1073 |
+
Parameters
|
| 1074 |
+
----------
|
| 1075 |
+
s : str
|
| 1076 |
+
Text.
|
| 1077 |
+
|
| 1078 |
+
loc : str
|
| 1079 |
+
Location code. See `AnchoredOffsetbox`.
|
| 1080 |
+
|
| 1081 |
+
pad : float, default: 0.4
|
| 1082 |
+
Padding around the text as fraction of the fontsize.
|
| 1083 |
+
|
| 1084 |
+
borderpad : float, default: 0.5
|
| 1085 |
+
Spacing between the offsetbox frame and the *bbox_to_anchor*.
|
| 1086 |
+
|
| 1087 |
+
prop : dict, optional
|
| 1088 |
+
Dictionary of keyword parameters to be passed to the
|
| 1089 |
+
`~matplotlib.text.Text` instance contained inside AnchoredText.
|
| 1090 |
+
|
| 1091 |
+
**kwargs
|
| 1092 |
+
All other parameters are passed to `AnchoredOffsetbox`.
|
| 1093 |
+
"""
|
| 1094 |
+
|
| 1095 |
+
if prop is None:
|
| 1096 |
+
prop = {}
|
| 1097 |
+
badkwargs = {'va', 'verticalalignment'}
|
| 1098 |
+
if badkwargs & set(prop):
|
| 1099 |
+
raise ValueError(
|
| 1100 |
+
'Mixing verticalalignment with AnchoredText is not supported.')
|
| 1101 |
+
|
| 1102 |
+
self.txt = TextArea(s, textprops=prop)
|
| 1103 |
+
fp = self.txt._text.get_fontproperties()
|
| 1104 |
+
super().__init__(
|
| 1105 |
+
loc, pad=pad, borderpad=borderpad, child=self.txt, prop=fp,
|
| 1106 |
+
**kwargs)
|
| 1107 |
+
|
| 1108 |
+
|
| 1109 |
+
class OffsetImage(OffsetBox):
|
| 1110 |
+
|
| 1111 |
+
def __init__(self, arr, *,
|
| 1112 |
+
zoom=1,
|
| 1113 |
+
cmap=None,
|
| 1114 |
+
norm=None,
|
| 1115 |
+
interpolation=None,
|
| 1116 |
+
origin=None,
|
| 1117 |
+
filternorm=True,
|
| 1118 |
+
filterrad=4.0,
|
| 1119 |
+
resample=False,
|
| 1120 |
+
dpi_cor=True,
|
| 1121 |
+
**kwargs
|
| 1122 |
+
):
|
| 1123 |
+
|
| 1124 |
+
super().__init__()
|
| 1125 |
+
self._dpi_cor = dpi_cor
|
| 1126 |
+
|
| 1127 |
+
self.image = BboxImage(bbox=self.get_window_extent,
|
| 1128 |
+
cmap=cmap,
|
| 1129 |
+
norm=norm,
|
| 1130 |
+
interpolation=interpolation,
|
| 1131 |
+
origin=origin,
|
| 1132 |
+
filternorm=filternorm,
|
| 1133 |
+
filterrad=filterrad,
|
| 1134 |
+
resample=resample,
|
| 1135 |
+
**kwargs
|
| 1136 |
+
)
|
| 1137 |
+
|
| 1138 |
+
self._children = [self.image]
|
| 1139 |
+
|
| 1140 |
+
self.set_zoom(zoom)
|
| 1141 |
+
self.set_data(arr)
|
| 1142 |
+
|
| 1143 |
+
def set_data(self, arr):
|
| 1144 |
+
self._data = np.asarray(arr)
|
| 1145 |
+
self.image.set_data(self._data)
|
| 1146 |
+
self.stale = True
|
| 1147 |
+
|
| 1148 |
+
def get_data(self):
|
| 1149 |
+
return self._data
|
| 1150 |
+
|
| 1151 |
+
def set_zoom(self, zoom):
|
| 1152 |
+
self._zoom = zoom
|
| 1153 |
+
self.stale = True
|
| 1154 |
+
|
| 1155 |
+
def get_zoom(self):
|
| 1156 |
+
return self._zoom
|
| 1157 |
+
|
| 1158 |
+
def get_offset(self):
|
| 1159 |
+
"""Return offset of the container."""
|
| 1160 |
+
return self._offset
|
| 1161 |
+
|
| 1162 |
+
def get_children(self):
|
| 1163 |
+
return [self.image]
|
| 1164 |
+
|
| 1165 |
+
def get_bbox(self, renderer):
|
| 1166 |
+
dpi_cor = renderer.points_to_pixels(1.) if self._dpi_cor else 1.
|
| 1167 |
+
zoom = self.get_zoom()
|
| 1168 |
+
data = self.get_data()
|
| 1169 |
+
ny, nx = data.shape[:2]
|
| 1170 |
+
w, h = dpi_cor * nx * zoom, dpi_cor * ny * zoom
|
| 1171 |
+
return Bbox.from_bounds(0, 0, w, h)
|
| 1172 |
+
|
| 1173 |
+
def draw(self, renderer):
|
| 1174 |
+
# docstring inherited
|
| 1175 |
+
self.image.draw(renderer)
|
| 1176 |
+
# bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 1177 |
+
self.stale = False
|
| 1178 |
+
|
| 1179 |
+
|
| 1180 |
+
class AnnotationBbox(martist.Artist, mtext._AnnotationBase):
|
| 1181 |
+
"""
|
| 1182 |
+
Container for an `OffsetBox` referring to a specific position *xy*.
|
| 1183 |
+
|
| 1184 |
+
Optionally an arrow pointing from the offsetbox to *xy* can be drawn.
|
| 1185 |
+
|
| 1186 |
+
This is like `.Annotation`, but with `OffsetBox` instead of `.Text`.
|
| 1187 |
+
"""
|
| 1188 |
+
|
| 1189 |
+
zorder = 3
|
| 1190 |
+
|
| 1191 |
+
def __str__(self):
|
| 1192 |
+
return f"AnnotationBbox({self.xy[0]:g},{self.xy[1]:g})"
|
| 1193 |
+
|
| 1194 |
+
@_docstring.interpd
|
| 1195 |
+
def __init__(self, offsetbox, xy, xybox=None, xycoords='data', boxcoords=None, *,
|
| 1196 |
+
frameon=True, pad=0.4, # FancyBboxPatch boxstyle.
|
| 1197 |
+
annotation_clip=None,
|
| 1198 |
+
box_alignment=(0.5, 0.5),
|
| 1199 |
+
bboxprops=None,
|
| 1200 |
+
arrowprops=None,
|
| 1201 |
+
fontsize=None,
|
| 1202 |
+
**kwargs):
|
| 1203 |
+
"""
|
| 1204 |
+
Parameters
|
| 1205 |
+
----------
|
| 1206 |
+
offsetbox : `OffsetBox`
|
| 1207 |
+
|
| 1208 |
+
xy : (float, float)
|
| 1209 |
+
The point *(x, y)* to annotate. The coordinate system is determined
|
| 1210 |
+
by *xycoords*.
|
| 1211 |
+
|
| 1212 |
+
xybox : (float, float), default: *xy*
|
| 1213 |
+
The position *(x, y)* to place the text at. The coordinate system
|
| 1214 |
+
is determined by *boxcoords*.
|
| 1215 |
+
|
| 1216 |
+
xycoords : single or two-tuple of str or `.Artist` or `.Transform` or \
|
| 1217 |
+
callable, default: 'data'
|
| 1218 |
+
The coordinate system that *xy* is given in. See the parameter
|
| 1219 |
+
*xycoords* in `.Annotation` for a detailed description.
|
| 1220 |
+
|
| 1221 |
+
boxcoords : single or two-tuple of str or `.Artist` or `.Transform` \
|
| 1222 |
+
or callable, default: value of *xycoords*
|
| 1223 |
+
The coordinate system that *xybox* is given in. See the parameter
|
| 1224 |
+
*textcoords* in `.Annotation` for a detailed description.
|
| 1225 |
+
|
| 1226 |
+
frameon : bool, default: True
|
| 1227 |
+
By default, the text is surrounded by a white `.FancyBboxPatch`
|
| 1228 |
+
(accessible as the ``patch`` attribute of the `.AnnotationBbox`).
|
| 1229 |
+
If *frameon* is set to False, this patch is made invisible.
|
| 1230 |
+
|
| 1231 |
+
annotation_clip: bool or None, default: None
|
| 1232 |
+
Whether to clip (i.e. not draw) the annotation when the annotation
|
| 1233 |
+
point *xy* is outside the Axes area.
|
| 1234 |
+
|
| 1235 |
+
- If *True*, the annotation will be clipped when *xy* is outside
|
| 1236 |
+
the Axes.
|
| 1237 |
+
- If *False*, the annotation will always be drawn.
|
| 1238 |
+
- If *None*, the annotation will be clipped when *xy* is outside
|
| 1239 |
+
the Axes and *xycoords* is 'data'.
|
| 1240 |
+
|
| 1241 |
+
pad : float, default: 0.4
|
| 1242 |
+
Padding around the offsetbox.
|
| 1243 |
+
|
| 1244 |
+
box_alignment : (float, float)
|
| 1245 |
+
A tuple of two floats for a vertical and horizontal alignment of
|
| 1246 |
+
the offset box w.r.t. the *boxcoords*.
|
| 1247 |
+
The lower-left corner is (0, 0) and upper-right corner is (1, 1).
|
| 1248 |
+
|
| 1249 |
+
bboxprops : dict, optional
|
| 1250 |
+
A dictionary of properties to set for the annotation bounding box,
|
| 1251 |
+
for example *boxstyle* and *alpha*. See `.FancyBboxPatch` for
|
| 1252 |
+
details.
|
| 1253 |
+
|
| 1254 |
+
arrowprops: dict, optional
|
| 1255 |
+
Arrow properties, see `.Annotation` for description.
|
| 1256 |
+
|
| 1257 |
+
fontsize: float or str, optional
|
| 1258 |
+
Translated to points and passed as *mutation_scale* into
|
| 1259 |
+
`.FancyBboxPatch` to scale attributes of the box style (e.g. pad
|
| 1260 |
+
or rounding_size). The name is chosen in analogy to `.Text` where
|
| 1261 |
+
*fontsize* defines the mutation scale as well. If not given,
|
| 1262 |
+
:rc:`legend.fontsize` is used. See `.Text.set_fontsize` for valid
|
| 1263 |
+
values.
|
| 1264 |
+
|
| 1265 |
+
**kwargs
|
| 1266 |
+
Other `AnnotationBbox` properties. See `.AnnotationBbox.set` for
|
| 1267 |
+
a list.
|
| 1268 |
+
"""
|
| 1269 |
+
|
| 1270 |
+
martist.Artist.__init__(self)
|
| 1271 |
+
mtext._AnnotationBase.__init__(
|
| 1272 |
+
self, xy, xycoords=xycoords, annotation_clip=annotation_clip)
|
| 1273 |
+
|
| 1274 |
+
self.offsetbox = offsetbox
|
| 1275 |
+
self.arrowprops = arrowprops.copy() if arrowprops is not None else None
|
| 1276 |
+
self.set_fontsize(fontsize)
|
| 1277 |
+
self.xybox = xybox if xybox is not None else xy
|
| 1278 |
+
self.boxcoords = boxcoords if boxcoords is not None else xycoords
|
| 1279 |
+
self._box_alignment = box_alignment
|
| 1280 |
+
|
| 1281 |
+
if arrowprops is not None:
|
| 1282 |
+
self._arrow_relpos = self.arrowprops.pop("relpos", (0.5, 0.5))
|
| 1283 |
+
self.arrow_patch = FancyArrowPatch((0, 0), (1, 1),
|
| 1284 |
+
**self.arrowprops)
|
| 1285 |
+
else:
|
| 1286 |
+
self._arrow_relpos = None
|
| 1287 |
+
self.arrow_patch = None
|
| 1288 |
+
|
| 1289 |
+
self.patch = FancyBboxPatch( # frame
|
| 1290 |
+
xy=(0.0, 0.0), width=1., height=1.,
|
| 1291 |
+
facecolor='w', edgecolor='k',
|
| 1292 |
+
mutation_scale=self.prop.get_size_in_points(),
|
| 1293 |
+
snap=True,
|
| 1294 |
+
visible=frameon,
|
| 1295 |
+
)
|
| 1296 |
+
self.patch.set_boxstyle("square", pad=pad)
|
| 1297 |
+
if bboxprops:
|
| 1298 |
+
self.patch.set(**bboxprops)
|
| 1299 |
+
|
| 1300 |
+
self._internal_update(kwargs)
|
| 1301 |
+
|
| 1302 |
+
@property
|
| 1303 |
+
def xyann(self):
|
| 1304 |
+
return self.xybox
|
| 1305 |
+
|
| 1306 |
+
@xyann.setter
|
| 1307 |
+
def xyann(self, xyann):
|
| 1308 |
+
self.xybox = xyann
|
| 1309 |
+
self.stale = True
|
| 1310 |
+
|
| 1311 |
+
@property
|
| 1312 |
+
def anncoords(self):
|
| 1313 |
+
return self.boxcoords
|
| 1314 |
+
|
| 1315 |
+
@anncoords.setter
|
| 1316 |
+
def anncoords(self, coords):
|
| 1317 |
+
self.boxcoords = coords
|
| 1318 |
+
self.stale = True
|
| 1319 |
+
|
| 1320 |
+
def contains(self, mouseevent):
|
| 1321 |
+
if self._different_canvas(mouseevent):
|
| 1322 |
+
return False, {}
|
| 1323 |
+
if not self._check_xy(None):
|
| 1324 |
+
return False, {}
|
| 1325 |
+
return self.offsetbox.contains(mouseevent)
|
| 1326 |
+
# self.arrow_patch is currently not checked as this can be a line - JJ
|
| 1327 |
+
|
| 1328 |
+
def get_children(self):
|
| 1329 |
+
children = [self.offsetbox, self.patch]
|
| 1330 |
+
if self.arrow_patch:
|
| 1331 |
+
children.append(self.arrow_patch)
|
| 1332 |
+
return children
|
| 1333 |
+
|
| 1334 |
+
def set_figure(self, fig):
|
| 1335 |
+
if self.arrow_patch is not None:
|
| 1336 |
+
self.arrow_patch.set_figure(fig)
|
| 1337 |
+
self.offsetbox.set_figure(fig)
|
| 1338 |
+
martist.Artist.set_figure(self, fig)
|
| 1339 |
+
|
| 1340 |
+
def set_fontsize(self, s=None):
|
| 1341 |
+
"""
|
| 1342 |
+
Set the fontsize in points.
|
| 1343 |
+
|
| 1344 |
+
If *s* is not given, reset to :rc:`legend.fontsize`.
|
| 1345 |
+
"""
|
| 1346 |
+
if s is None:
|
| 1347 |
+
s = mpl.rcParams["legend.fontsize"]
|
| 1348 |
+
|
| 1349 |
+
self.prop = FontProperties(size=s)
|
| 1350 |
+
self.stale = True
|
| 1351 |
+
|
| 1352 |
+
def get_fontsize(self):
|
| 1353 |
+
"""Return the fontsize in points."""
|
| 1354 |
+
return self.prop.get_size_in_points()
|
| 1355 |
+
|
| 1356 |
+
def get_window_extent(self, renderer=None):
|
| 1357 |
+
# docstring inherited
|
| 1358 |
+
if renderer is None:
|
| 1359 |
+
renderer = self.get_figure(root=True)._get_renderer()
|
| 1360 |
+
self.update_positions(renderer)
|
| 1361 |
+
return Bbox.union([child.get_window_extent(renderer)
|
| 1362 |
+
for child in self.get_children()])
|
| 1363 |
+
|
| 1364 |
+
def get_tightbbox(self, renderer=None):
|
| 1365 |
+
# docstring inherited
|
| 1366 |
+
if renderer is None:
|
| 1367 |
+
renderer = self.get_figure(root=True)._get_renderer()
|
| 1368 |
+
self.update_positions(renderer)
|
| 1369 |
+
return Bbox.union([child.get_tightbbox(renderer)
|
| 1370 |
+
for child in self.get_children()])
|
| 1371 |
+
|
| 1372 |
+
def update_positions(self, renderer):
|
| 1373 |
+
"""Update pixel positions for the annotated point, the text, and the arrow."""
|
| 1374 |
+
|
| 1375 |
+
ox0, oy0 = self._get_xy(renderer, self.xybox, self.boxcoords)
|
| 1376 |
+
bbox = self.offsetbox.get_bbox(renderer)
|
| 1377 |
+
fw, fh = self._box_alignment
|
| 1378 |
+
self.offsetbox.set_offset(
|
| 1379 |
+
(ox0 - fw*bbox.width - bbox.x0, oy0 - fh*bbox.height - bbox.y0))
|
| 1380 |
+
|
| 1381 |
+
bbox = self.offsetbox.get_window_extent(renderer)
|
| 1382 |
+
self.patch.set_bounds(bbox.bounds)
|
| 1383 |
+
|
| 1384 |
+
mutation_scale = renderer.points_to_pixels(self.get_fontsize())
|
| 1385 |
+
self.patch.set_mutation_scale(mutation_scale)
|
| 1386 |
+
|
| 1387 |
+
if self.arrowprops:
|
| 1388 |
+
# Use FancyArrowPatch if self.arrowprops has "arrowstyle" key.
|
| 1389 |
+
|
| 1390 |
+
# Adjust the starting point of the arrow relative to the textbox.
|
| 1391 |
+
# TODO: Rotation needs to be accounted.
|
| 1392 |
+
arrow_begin = bbox.p0 + bbox.size * self._arrow_relpos
|
| 1393 |
+
arrow_end = self._get_position_xy(renderer)
|
| 1394 |
+
# The arrow (from arrow_begin to arrow_end) will be first clipped
|
| 1395 |
+
# by patchA and patchB, then shrunk by shrinkA and shrinkB (in
|
| 1396 |
+
# points). If patch A is not set, self.bbox_patch is used.
|
| 1397 |
+
self.arrow_patch.set_positions(arrow_begin, arrow_end)
|
| 1398 |
+
|
| 1399 |
+
if "mutation_scale" in self.arrowprops:
|
| 1400 |
+
mutation_scale = renderer.points_to_pixels(
|
| 1401 |
+
self.arrowprops["mutation_scale"])
|
| 1402 |
+
# Else, use fontsize-based mutation_scale defined above.
|
| 1403 |
+
self.arrow_patch.set_mutation_scale(mutation_scale)
|
| 1404 |
+
|
| 1405 |
+
patchA = self.arrowprops.get("patchA", self.patch)
|
| 1406 |
+
self.arrow_patch.set_patchA(patchA)
|
| 1407 |
+
|
| 1408 |
+
def draw(self, renderer):
|
| 1409 |
+
# docstring inherited
|
| 1410 |
+
if not self.get_visible() or not self._check_xy(renderer):
|
| 1411 |
+
return
|
| 1412 |
+
renderer.open_group(self.__class__.__name__, gid=self.get_gid())
|
| 1413 |
+
self.update_positions(renderer)
|
| 1414 |
+
if self.arrow_patch is not None:
|
| 1415 |
+
if (self.arrow_patch.get_figure(root=False) is None and
|
| 1416 |
+
(fig := self.get_figure(root=False)) is not None):
|
| 1417 |
+
self.arrow_patch.set_figure(fig)
|
| 1418 |
+
self.arrow_patch.draw(renderer)
|
| 1419 |
+
self.patch.draw(renderer)
|
| 1420 |
+
self.offsetbox.draw(renderer)
|
| 1421 |
+
renderer.close_group(self.__class__.__name__)
|
| 1422 |
+
self.stale = False
|
| 1423 |
+
|
| 1424 |
+
|
| 1425 |
+
class DraggableBase:
|
| 1426 |
+
"""
|
| 1427 |
+
Helper base class for a draggable artist (legend, offsetbox).
|
| 1428 |
+
|
| 1429 |
+
Derived classes must override the following methods::
|
| 1430 |
+
|
| 1431 |
+
def save_offset(self):
|
| 1432 |
+
'''
|
| 1433 |
+
Called when the object is picked for dragging; should save the
|
| 1434 |
+
reference position of the artist.
|
| 1435 |
+
'''
|
| 1436 |
+
|
| 1437 |
+
def update_offset(self, dx, dy):
|
| 1438 |
+
'''
|
| 1439 |
+
Called during the dragging; (*dx*, *dy*) is the pixel offset from
|
| 1440 |
+
the point where the mouse drag started.
|
| 1441 |
+
'''
|
| 1442 |
+
|
| 1443 |
+
Optionally, you may override the following method::
|
| 1444 |
+
|
| 1445 |
+
def finalize_offset(self):
|
| 1446 |
+
'''Called when the mouse is released.'''
|
| 1447 |
+
|
| 1448 |
+
In the current implementation of `.DraggableLegend` and
|
| 1449 |
+
`DraggableAnnotation`, `update_offset` places the artists in display
|
| 1450 |
+
coordinates, and `finalize_offset` recalculates their position in axes
|
| 1451 |
+
coordinate and set a relevant attribute.
|
| 1452 |
+
"""
|
| 1453 |
+
|
| 1454 |
+
def __init__(self, ref_artist, use_blit=False):
|
| 1455 |
+
self.ref_artist = ref_artist
|
| 1456 |
+
if not ref_artist.pickable():
|
| 1457 |
+
ref_artist.set_picker(True)
|
| 1458 |
+
self.got_artist = False
|
| 1459 |
+
self._use_blit = use_blit and self.canvas.supports_blit
|
| 1460 |
+
callbacks = self.canvas.callbacks
|
| 1461 |
+
self._disconnectors = [
|
| 1462 |
+
functools.partial(
|
| 1463 |
+
callbacks.disconnect, callbacks._connect_picklable(name, func))
|
| 1464 |
+
for name, func in [
|
| 1465 |
+
("pick_event", self.on_pick),
|
| 1466 |
+
("button_release_event", self.on_release),
|
| 1467 |
+
("motion_notify_event", self.on_motion),
|
| 1468 |
+
]
|
| 1469 |
+
]
|
| 1470 |
+
|
| 1471 |
+
# A property, not an attribute, to maintain picklability.
|
| 1472 |
+
canvas = property(lambda self: self.ref_artist.get_figure(root=True).canvas)
|
| 1473 |
+
cids = property(lambda self: [
|
| 1474 |
+
disconnect.args[0] for disconnect in self._disconnectors[:2]])
|
| 1475 |
+
|
| 1476 |
+
def on_motion(self, evt):
|
| 1477 |
+
if self._check_still_parented() and self.got_artist:
|
| 1478 |
+
dx = evt.x - self.mouse_x
|
| 1479 |
+
dy = evt.y - self.mouse_y
|
| 1480 |
+
self.update_offset(dx, dy)
|
| 1481 |
+
if self._use_blit:
|
| 1482 |
+
self.canvas.restore_region(self.background)
|
| 1483 |
+
self.ref_artist.draw(
|
| 1484 |
+
self.ref_artist.get_figure(root=True)._get_renderer())
|
| 1485 |
+
self.canvas.blit()
|
| 1486 |
+
else:
|
| 1487 |
+
self.canvas.draw()
|
| 1488 |
+
|
| 1489 |
+
def on_pick(self, evt):
|
| 1490 |
+
if self._check_still_parented():
|
| 1491 |
+
if evt.artist == self.ref_artist:
|
| 1492 |
+
self.mouse_x = evt.mouseevent.x
|
| 1493 |
+
self.mouse_y = evt.mouseevent.y
|
| 1494 |
+
self.save_offset()
|
| 1495 |
+
self.got_artist = True
|
| 1496 |
+
if self.got_artist and self._use_blit:
|
| 1497 |
+
self.ref_artist.set_animated(True)
|
| 1498 |
+
self.canvas.draw()
|
| 1499 |
+
fig = self.ref_artist.get_figure(root=False)
|
| 1500 |
+
self.background = self.canvas.copy_from_bbox(fig.bbox)
|
| 1501 |
+
self.ref_artist.draw(fig._get_renderer())
|
| 1502 |
+
self.canvas.blit()
|
| 1503 |
+
|
| 1504 |
+
def on_release(self, event):
|
| 1505 |
+
if self._check_still_parented() and self.got_artist:
|
| 1506 |
+
self.finalize_offset()
|
| 1507 |
+
self.got_artist = False
|
| 1508 |
+
if self._use_blit:
|
| 1509 |
+
self.canvas.restore_region(self.background)
|
| 1510 |
+
self.ref_artist.draw(self.ref_artist.figure._get_renderer())
|
| 1511 |
+
self.canvas.blit()
|
| 1512 |
+
self.ref_artist.set_animated(False)
|
| 1513 |
+
|
| 1514 |
+
def _check_still_parented(self):
|
| 1515 |
+
if self.ref_artist.get_figure(root=False) is None:
|
| 1516 |
+
self.disconnect()
|
| 1517 |
+
return False
|
| 1518 |
+
else:
|
| 1519 |
+
return True
|
| 1520 |
+
|
| 1521 |
+
def disconnect(self):
|
| 1522 |
+
"""Disconnect the callbacks."""
|
| 1523 |
+
for disconnector in self._disconnectors:
|
| 1524 |
+
disconnector()
|
| 1525 |
+
|
| 1526 |
+
def save_offset(self):
|
| 1527 |
+
pass
|
| 1528 |
+
|
| 1529 |
+
def update_offset(self, dx, dy):
|
| 1530 |
+
pass
|
| 1531 |
+
|
| 1532 |
+
def finalize_offset(self):
|
| 1533 |
+
pass
|
| 1534 |
+
|
| 1535 |
+
|
| 1536 |
+
class DraggableOffsetBox(DraggableBase):
|
| 1537 |
+
def __init__(self, ref_artist, offsetbox, use_blit=False):
|
| 1538 |
+
super().__init__(ref_artist, use_blit=use_blit)
|
| 1539 |
+
self.offsetbox = offsetbox
|
| 1540 |
+
|
| 1541 |
+
def save_offset(self):
|
| 1542 |
+
offsetbox = self.offsetbox
|
| 1543 |
+
renderer = offsetbox.get_figure(root=True)._get_renderer()
|
| 1544 |
+
offset = offsetbox.get_offset(offsetbox.get_bbox(renderer), renderer)
|
| 1545 |
+
self.offsetbox_x, self.offsetbox_y = offset
|
| 1546 |
+
self.offsetbox.set_offset(offset)
|
| 1547 |
+
|
| 1548 |
+
def update_offset(self, dx, dy):
|
| 1549 |
+
loc_in_canvas = self.offsetbox_x + dx, self.offsetbox_y + dy
|
| 1550 |
+
self.offsetbox.set_offset(loc_in_canvas)
|
| 1551 |
+
|
| 1552 |
+
def get_loc_in_canvas(self):
|
| 1553 |
+
offsetbox = self.offsetbox
|
| 1554 |
+
renderer = offsetbox.get_figure(root=True)._get_renderer()
|
| 1555 |
+
bbox = offsetbox.get_bbox(renderer)
|
| 1556 |
+
ox, oy = offsetbox._offset
|
| 1557 |
+
loc_in_canvas = (ox + bbox.x0, oy + bbox.y0)
|
| 1558 |
+
return loc_in_canvas
|
| 1559 |
+
|
| 1560 |
+
|
| 1561 |
+
class DraggableAnnotation(DraggableBase):
|
| 1562 |
+
def __init__(self, annotation, use_blit=False):
|
| 1563 |
+
super().__init__(annotation, use_blit=use_blit)
|
| 1564 |
+
self.annotation = annotation
|
| 1565 |
+
|
| 1566 |
+
def save_offset(self):
|
| 1567 |
+
ann = self.annotation
|
| 1568 |
+
self.ox, self.oy = ann.get_transform().transform(ann.xyann)
|
| 1569 |
+
|
| 1570 |
+
def update_offset(self, dx, dy):
|
| 1571 |
+
ann = self.annotation
|
| 1572 |
+
ann.xyann = ann.get_transform().inverted().transform(
|
| 1573 |
+
(self.ox + dx, self.oy + dy))
|
llava_video/lib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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from . import artist
|
| 2 |
+
from .axes import Axes
|
| 3 |
+
from .backend_bases import RendererBase, MouseEvent
|
| 4 |
+
from .path import Path
|
| 5 |
+
from .transforms import Transform, Bbox
|
| 6 |
+
|
| 7 |
+
from typing import Any, Literal, overload
|
| 8 |
+
|
| 9 |
+
import numpy as np
|
| 10 |
+
from numpy.typing import ArrayLike
|
| 11 |
+
from .typing import ColorType, LineStyleType, CapStyleType, JoinStyleType
|
| 12 |
+
|
| 13 |
+
class Patch(artist.Artist):
|
| 14 |
+
zorder: float
|
| 15 |
+
def __init__(
|
| 16 |
+
self,
|
| 17 |
+
*,
|
| 18 |
+
edgecolor: ColorType | None = ...,
|
| 19 |
+
facecolor: ColorType | None = ...,
|
| 20 |
+
color: ColorType | None = ...,
|
| 21 |
+
linewidth: float | None = ...,
|
| 22 |
+
linestyle: LineStyleType | None = ...,
|
| 23 |
+
antialiased: bool | None = ...,
|
| 24 |
+
hatch: str | None = ...,
|
| 25 |
+
fill: bool = ...,
|
| 26 |
+
capstyle: CapStyleType | None = ...,
|
| 27 |
+
joinstyle: JoinStyleType | None = ...,
|
| 28 |
+
**kwargs,
|
| 29 |
+
) -> None: ...
|
| 30 |
+
def get_verts(self) -> ArrayLike: ...
|
| 31 |
+
def contains(self, mouseevent: MouseEvent, radius: float | None = None) -> tuple[bool, dict[Any, Any]]: ...
|
| 32 |
+
def contains_point(
|
| 33 |
+
self, point: tuple[float, float], radius: float | None = ...
|
| 34 |
+
) -> bool: ...
|
| 35 |
+
def contains_points(
|
| 36 |
+
self, points: ArrayLike, radius: float | None = ...
|
| 37 |
+
) -> np.ndarray: ...
|
| 38 |
+
def get_extents(self) -> Bbox: ...
|
| 39 |
+
def get_transform(self) -> Transform: ...
|
| 40 |
+
def get_data_transform(self) -> Transform: ...
|
| 41 |
+
def get_patch_transform(self) -> Transform: ...
|
| 42 |
+
def get_antialiased(self) -> bool: ...
|
| 43 |
+
def get_edgecolor(self) -> ColorType: ...
|
| 44 |
+
def get_facecolor(self) -> ColorType: ...
|
| 45 |
+
def get_linewidth(self) -> float: ...
|
| 46 |
+
def get_linestyle(self) -> LineStyleType: ...
|
| 47 |
+
def set_antialiased(self, aa: bool | None) -> None: ...
|
| 48 |
+
def set_edgecolor(self, color: ColorType | None) -> None: ...
|
| 49 |
+
def set_facecolor(self, color: ColorType | None) -> None: ...
|
| 50 |
+
def set_color(self, c: ColorType | None) -> None: ...
|
| 51 |
+
def set_alpha(self, alpha: float | None) -> None: ...
|
| 52 |
+
def set_linewidth(self, w: float | None) -> None: ...
|
| 53 |
+
def set_linestyle(self, ls: LineStyleType | None) -> None: ...
|
| 54 |
+
def set_fill(self, b: bool) -> None: ...
|
| 55 |
+
def get_fill(self) -> bool: ...
|
| 56 |
+
fill = property(get_fill, set_fill)
|
| 57 |
+
def set_capstyle(self, s: CapStyleType) -> None: ...
|
| 58 |
+
def get_capstyle(self) -> Literal["butt", "projecting", "round"]: ...
|
| 59 |
+
def set_joinstyle(self, s: JoinStyleType) -> None: ...
|
| 60 |
+
def get_joinstyle(self) -> Literal["miter", "round", "bevel"]: ...
|
| 61 |
+
def set_hatch(self, hatch: str) -> None: ...
|
| 62 |
+
def set_hatch_linewidth(self, lw: float) -> None: ...
|
| 63 |
+
def get_hatch_linewidth(self) -> float: ...
|
| 64 |
+
def get_hatch(self) -> str: ...
|
| 65 |
+
def get_path(self) -> Path: ...
|
| 66 |
+
|
| 67 |
+
class Shadow(Patch):
|
| 68 |
+
patch: Patch
|
| 69 |
+
def __init__(self, patch: Patch, ox: float, oy: float, *, shade: float = ..., **kwargs) -> None: ...
|
| 70 |
+
|
| 71 |
+
class Rectangle(Patch):
|
| 72 |
+
angle: float
|
| 73 |
+
def __init__(
|
| 74 |
+
self,
|
| 75 |
+
xy: tuple[float, float],
|
| 76 |
+
width: float,
|
| 77 |
+
height: float,
|
| 78 |
+
*,
|
| 79 |
+
angle: float = ...,
|
| 80 |
+
rotation_point: Literal["xy", "center"] | tuple[float, float] = ...,
|
| 81 |
+
**kwargs,
|
| 82 |
+
) -> None: ...
|
| 83 |
+
@property
|
| 84 |
+
def rotation_point(self) -> Literal["xy", "center"] | tuple[float, float]: ...
|
| 85 |
+
@rotation_point.setter
|
| 86 |
+
def rotation_point(
|
| 87 |
+
self, value: Literal["xy", "center"] | tuple[float, float]
|
| 88 |
+
) -> None: ...
|
| 89 |
+
def get_x(self) -> float: ...
|
| 90 |
+
def get_y(self) -> float: ...
|
| 91 |
+
def get_xy(self) -> tuple[float, float]: ...
|
| 92 |
+
def get_corners(self) -> np.ndarray: ...
|
| 93 |
+
def get_center(self) -> np.ndarray: ...
|
| 94 |
+
def get_width(self) -> float: ...
|
| 95 |
+
def get_height(self) -> float: ...
|
| 96 |
+
def get_angle(self) -> float: ...
|
| 97 |
+
def set_x(self, x: float) -> None: ...
|
| 98 |
+
def set_y(self, y: float) -> None: ...
|
| 99 |
+
def set_angle(self, angle: float) -> None: ...
|
| 100 |
+
def set_xy(self, xy: tuple[float, float]) -> None: ...
|
| 101 |
+
def set_width(self, w: float) -> None: ...
|
| 102 |
+
def set_height(self, h: float) -> None: ...
|
| 103 |
+
@overload
|
| 104 |
+
def set_bounds(self, args: tuple[float, float, float, float], /) -> None: ...
|
| 105 |
+
@overload
|
| 106 |
+
def set_bounds(
|
| 107 |
+
self, left: float, bottom: float, width: float, height: float, /
|
| 108 |
+
) -> None: ...
|
| 109 |
+
def get_bbox(self) -> Bbox: ...
|
| 110 |
+
xy = property(get_xy, set_xy)
|
| 111 |
+
|
| 112 |
+
class RegularPolygon(Patch):
|
| 113 |
+
xy: tuple[float, float]
|
| 114 |
+
numvertices: int
|
| 115 |
+
orientation: float
|
| 116 |
+
radius: float
|
| 117 |
+
def __init__(
|
| 118 |
+
self,
|
| 119 |
+
xy: tuple[float, float],
|
| 120 |
+
numVertices: int,
|
| 121 |
+
*,
|
| 122 |
+
radius: float = ...,
|
| 123 |
+
orientation: float = ...,
|
| 124 |
+
**kwargs,
|
| 125 |
+
) -> None: ...
|
| 126 |
+
|
| 127 |
+
class PathPatch(Patch):
|
| 128 |
+
def __init__(self, path: Path, **kwargs) -> None: ...
|
| 129 |
+
def set_path(self, path: Path) -> None: ...
|
| 130 |
+
|
| 131 |
+
class StepPatch(PathPatch):
|
| 132 |
+
orientation: Literal["vertical", "horizontal"]
|
| 133 |
+
def __init__(
|
| 134 |
+
self,
|
| 135 |
+
values: ArrayLike,
|
| 136 |
+
edges: ArrayLike,
|
| 137 |
+
*,
|
| 138 |
+
orientation: Literal["vertical", "horizontal"] = ...,
|
| 139 |
+
baseline: float = ...,
|
| 140 |
+
**kwargs,
|
| 141 |
+
) -> None: ...
|
| 142 |
+
|
| 143 |
+
# NamedTuple StairData, defined in body of method
|
| 144 |
+
def get_data(self) -> tuple[np.ndarray, np.ndarray, float]: ...
|
| 145 |
+
def set_data(
|
| 146 |
+
self,
|
| 147 |
+
values: ArrayLike | None = ...,
|
| 148 |
+
edges: ArrayLike | None = ...,
|
| 149 |
+
baseline: float | None = ...,
|
| 150 |
+
) -> None: ...
|
| 151 |
+
|
| 152 |
+
class Polygon(Patch):
|
| 153 |
+
def __init__(self, xy: ArrayLike, *, closed: bool = ..., **kwargs) -> None: ...
|
| 154 |
+
def get_closed(self) -> bool: ...
|
| 155 |
+
def set_closed(self, closed: bool) -> None: ...
|
| 156 |
+
def get_xy(self) -> np.ndarray: ...
|
| 157 |
+
def set_xy(self, xy: ArrayLike) -> None: ...
|
| 158 |
+
xy = property(get_xy, set_xy)
|
| 159 |
+
|
| 160 |
+
class Wedge(Patch):
|
| 161 |
+
center: tuple[float, float]
|
| 162 |
+
r: float
|
| 163 |
+
theta1: float
|
| 164 |
+
theta2: float
|
| 165 |
+
width: float | None
|
| 166 |
+
def __init__(
|
| 167 |
+
self,
|
| 168 |
+
center: tuple[float, float],
|
| 169 |
+
r: float,
|
| 170 |
+
theta1: float,
|
| 171 |
+
theta2: float,
|
| 172 |
+
*,
|
| 173 |
+
width: float | None = ...,
|
| 174 |
+
**kwargs,
|
| 175 |
+
) -> None: ...
|
| 176 |
+
def set_center(self, center: tuple[float, float]) -> None: ...
|
| 177 |
+
def set_radius(self, radius: float) -> None: ...
|
| 178 |
+
def set_theta1(self, theta1: float) -> None: ...
|
| 179 |
+
def set_theta2(self, theta2: float) -> None: ...
|
| 180 |
+
def set_width(self, width: float | None) -> None: ...
|
| 181 |
+
|
| 182 |
+
class Arrow(Patch):
|
| 183 |
+
def __init__(
|
| 184 |
+
self, x: float, y: float, dx: float, dy: float, *, width: float = ..., **kwargs
|
| 185 |
+
) -> None: ...
|
| 186 |
+
def set_data(
|
| 187 |
+
self,
|
| 188 |
+
x: float | None = ...,
|
| 189 |
+
y: float | None = ...,
|
| 190 |
+
dx: float | None = ...,
|
| 191 |
+
dy: float | None = ...,
|
| 192 |
+
width: float | None = ...,
|
| 193 |
+
) -> None: ...
|
| 194 |
+
class FancyArrow(Polygon):
|
| 195 |
+
def __init__(
|
| 196 |
+
self,
|
| 197 |
+
x: float,
|
| 198 |
+
y: float,
|
| 199 |
+
dx: float,
|
| 200 |
+
dy: float,
|
| 201 |
+
*,
|
| 202 |
+
width: float = ...,
|
| 203 |
+
length_includes_head: bool = ...,
|
| 204 |
+
head_width: float | None = ...,
|
| 205 |
+
head_length: float | None = ...,
|
| 206 |
+
shape: Literal["full", "left", "right"] = ...,
|
| 207 |
+
overhang: float = ...,
|
| 208 |
+
head_starts_at_zero: bool = ...,
|
| 209 |
+
**kwargs,
|
| 210 |
+
) -> None: ...
|
| 211 |
+
def set_data(
|
| 212 |
+
self,
|
| 213 |
+
*,
|
| 214 |
+
x: float | None = ...,
|
| 215 |
+
y: float | None = ...,
|
| 216 |
+
dx: float | None = ...,
|
| 217 |
+
dy: float | None = ...,
|
| 218 |
+
width: float | None = ...,
|
| 219 |
+
head_width: float | None = ...,
|
| 220 |
+
head_length: float | None = ...,
|
| 221 |
+
) -> None: ...
|
| 222 |
+
|
| 223 |
+
class CirclePolygon(RegularPolygon):
|
| 224 |
+
def __init__(
|
| 225 |
+
self,
|
| 226 |
+
xy: tuple[float, float],
|
| 227 |
+
radius: float = ...,
|
| 228 |
+
*,
|
| 229 |
+
resolution: int = ...,
|
| 230 |
+
**kwargs,
|
| 231 |
+
) -> None: ...
|
| 232 |
+
|
| 233 |
+
class Ellipse(Patch):
|
| 234 |
+
def __init__(
|
| 235 |
+
self,
|
| 236 |
+
xy: tuple[float, float],
|
| 237 |
+
width: float,
|
| 238 |
+
height: float,
|
| 239 |
+
*,
|
| 240 |
+
angle: float = ...,
|
| 241 |
+
**kwargs,
|
| 242 |
+
) -> None: ...
|
| 243 |
+
def set_center(self, xy: tuple[float, float]) -> None: ...
|
| 244 |
+
def get_center(self) -> float: ...
|
| 245 |
+
center = property(get_center, set_center)
|
| 246 |
+
|
| 247 |
+
def set_width(self, width: float) -> None: ...
|
| 248 |
+
def get_width(self) -> float: ...
|
| 249 |
+
width = property(get_width, set_width)
|
| 250 |
+
|
| 251 |
+
def set_height(self, height: float) -> None: ...
|
| 252 |
+
def get_height(self) -> float: ...
|
| 253 |
+
height = property(get_height, set_height)
|
| 254 |
+
|
| 255 |
+
def set_angle(self, angle: float) -> None: ...
|
| 256 |
+
def get_angle(self) -> float: ...
|
| 257 |
+
angle = property(get_angle, set_angle)
|
| 258 |
+
|
| 259 |
+
def get_corners(self) -> np.ndarray: ...
|
| 260 |
+
|
| 261 |
+
def get_vertices(self) -> list[tuple[float, float]]: ...
|
| 262 |
+
def get_co_vertices(self) -> list[tuple[float, float]]: ...
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
class Annulus(Patch):
|
| 266 |
+
a: float
|
| 267 |
+
b: float
|
| 268 |
+
def __init__(
|
| 269 |
+
self,
|
| 270 |
+
xy: tuple[float, float],
|
| 271 |
+
r: float | tuple[float, float],
|
| 272 |
+
width: float,
|
| 273 |
+
angle: float = ...,
|
| 274 |
+
**kwargs,
|
| 275 |
+
) -> None: ...
|
| 276 |
+
def set_center(self, xy: tuple[float, float]) -> None: ...
|
| 277 |
+
def get_center(self) -> tuple[float, float]: ...
|
| 278 |
+
center = property(get_center, set_center)
|
| 279 |
+
|
| 280 |
+
def set_width(self, width: float) -> None: ...
|
| 281 |
+
def get_width(self) -> float: ...
|
| 282 |
+
width = property(get_width, set_width)
|
| 283 |
+
|
| 284 |
+
def set_angle(self, angle: float) -> None: ...
|
| 285 |
+
def get_angle(self) -> float: ...
|
| 286 |
+
angle = property(get_angle, set_angle)
|
| 287 |
+
|
| 288 |
+
def set_semimajor(self, a: float) -> None: ...
|
| 289 |
+
def set_semiminor(self, b: float) -> None: ...
|
| 290 |
+
def set_radii(self, r: float | tuple[float, float]) -> None: ...
|
| 291 |
+
def get_radii(self) -> tuple[float, float]: ...
|
| 292 |
+
radii = property(get_radii, set_radii)
|
| 293 |
+
|
| 294 |
+
class Circle(Ellipse):
|
| 295 |
+
def __init__(
|
| 296 |
+
self, xy: tuple[float, float], radius: float = ..., **kwargs
|
| 297 |
+
) -> None: ...
|
| 298 |
+
def set_radius(self, radius: float) -> None: ...
|
| 299 |
+
def get_radius(self) -> float: ...
|
| 300 |
+
radius = property(get_radius, set_radius)
|
| 301 |
+
|
| 302 |
+
class Arc(Ellipse):
|
| 303 |
+
theta1: float
|
| 304 |
+
theta2: float
|
| 305 |
+
def __init__(
|
| 306 |
+
self,
|
| 307 |
+
xy: tuple[float, float],
|
| 308 |
+
width: float,
|
| 309 |
+
height: float,
|
| 310 |
+
*,
|
| 311 |
+
angle: float = ...,
|
| 312 |
+
theta1: float = ...,
|
| 313 |
+
theta2: float = ...,
|
| 314 |
+
**kwargs,
|
| 315 |
+
) -> None: ...
|
| 316 |
+
|
| 317 |
+
def bbox_artist(
|
| 318 |
+
artist: artist.Artist,
|
| 319 |
+
renderer: RendererBase,
|
| 320 |
+
props: dict[str, Any] | None = ...,
|
| 321 |
+
fill: bool = ...,
|
| 322 |
+
) -> None: ...
|
| 323 |
+
def draw_bbox(
|
| 324 |
+
bbox: Bbox,
|
| 325 |
+
renderer: RendererBase,
|
| 326 |
+
color: ColorType = ...,
|
| 327 |
+
trans: Transform | None = ...,
|
| 328 |
+
) -> None: ...
|
| 329 |
+
|
| 330 |
+
class _Style:
|
| 331 |
+
def __new__(cls, stylename, **kwargs): ...
|
| 332 |
+
@classmethod
|
| 333 |
+
def get_styles(cls) -> dict[str, type]: ...
|
| 334 |
+
@classmethod
|
| 335 |
+
def pprint_styles(cls) -> str: ...
|
| 336 |
+
@classmethod
|
| 337 |
+
def register(cls, name: str, style: type) -> None: ...
|
| 338 |
+
|
| 339 |
+
class BoxStyle(_Style):
|
| 340 |
+
class Square(BoxStyle):
|
| 341 |
+
pad: float
|
| 342 |
+
def __init__(self, pad: float = ...) -> None: ...
|
| 343 |
+
def __call__(
|
| 344 |
+
self,
|
| 345 |
+
x0: float,
|
| 346 |
+
y0: float,
|
| 347 |
+
width: float,
|
| 348 |
+
height: float,
|
| 349 |
+
mutation_size: float,
|
| 350 |
+
) -> Path: ...
|
| 351 |
+
|
| 352 |
+
class Circle(BoxStyle):
|
| 353 |
+
pad: float
|
| 354 |
+
def __init__(self, pad: float = ...) -> None: ...
|
| 355 |
+
def __call__(
|
| 356 |
+
self,
|
| 357 |
+
x0: float,
|
| 358 |
+
y0: float,
|
| 359 |
+
width: float,
|
| 360 |
+
height: float,
|
| 361 |
+
mutation_size: float,
|
| 362 |
+
) -> Path: ...
|
| 363 |
+
|
| 364 |
+
class Ellipse(BoxStyle):
|
| 365 |
+
pad: float
|
| 366 |
+
def __init__(self, pad: float = ...) -> None: ...
|
| 367 |
+
def __call__(
|
| 368 |
+
self,
|
| 369 |
+
x0: float,
|
| 370 |
+
y0: float,
|
| 371 |
+
width: float,
|
| 372 |
+
height: float,
|
| 373 |
+
mutation_size: float,
|
| 374 |
+
) -> Path: ...
|
| 375 |
+
|
| 376 |
+
class LArrow(BoxStyle):
|
| 377 |
+
pad: float
|
| 378 |
+
def __init__(self, pad: float = ...) -> None: ...
|
| 379 |
+
def __call__(
|
| 380 |
+
self,
|
| 381 |
+
x0: float,
|
| 382 |
+
y0: float,
|
| 383 |
+
width: float,
|
| 384 |
+
height: float,
|
| 385 |
+
mutation_size: float,
|
| 386 |
+
) -> Path: ...
|
| 387 |
+
|
| 388 |
+
class RArrow(LArrow):
|
| 389 |
+
def __call__(
|
| 390 |
+
self,
|
| 391 |
+
x0: float,
|
| 392 |
+
y0: float,
|
| 393 |
+
width: float,
|
| 394 |
+
height: float,
|
| 395 |
+
mutation_size: float,
|
| 396 |
+
) -> Path: ...
|
| 397 |
+
|
| 398 |
+
class DArrow(BoxStyle):
|
| 399 |
+
pad: float
|
| 400 |
+
def __init__(self, pad: float = ...) -> None: ...
|
| 401 |
+
def __call__(
|
| 402 |
+
self,
|
| 403 |
+
x0: float,
|
| 404 |
+
y0: float,
|
| 405 |
+
width: float,
|
| 406 |
+
height: float,
|
| 407 |
+
mutation_size: float,
|
| 408 |
+
) -> Path: ...
|
| 409 |
+
|
| 410 |
+
class Round(BoxStyle):
|
| 411 |
+
pad: float
|
| 412 |
+
rounding_size: float | None
|
| 413 |
+
def __init__(
|
| 414 |
+
self, pad: float = ..., rounding_size: float | None = ...
|
| 415 |
+
) -> None: ...
|
| 416 |
+
def __call__(
|
| 417 |
+
self,
|
| 418 |
+
x0: float,
|
| 419 |
+
y0: float,
|
| 420 |
+
width: float,
|
| 421 |
+
height: float,
|
| 422 |
+
mutation_size: float,
|
| 423 |
+
) -> Path: ...
|
| 424 |
+
|
| 425 |
+
class Round4(BoxStyle):
|
| 426 |
+
pad: float
|
| 427 |
+
rounding_size: float | None
|
| 428 |
+
def __init__(
|
| 429 |
+
self, pad: float = ..., rounding_size: float | None = ...
|
| 430 |
+
) -> None: ...
|
| 431 |
+
def __call__(
|
| 432 |
+
self,
|
| 433 |
+
x0: float,
|
| 434 |
+
y0: float,
|
| 435 |
+
width: float,
|
| 436 |
+
height: float,
|
| 437 |
+
mutation_size: float,
|
| 438 |
+
) -> Path: ...
|
| 439 |
+
|
| 440 |
+
class Sawtooth(BoxStyle):
|
| 441 |
+
pad: float
|
| 442 |
+
tooth_size: float | None
|
| 443 |
+
def __init__(
|
| 444 |
+
self, pad: float = ..., tooth_size: float | None = ...
|
| 445 |
+
) -> None: ...
|
| 446 |
+
def __call__(
|
| 447 |
+
self,
|
| 448 |
+
x0: float,
|
| 449 |
+
y0: float,
|
| 450 |
+
width: float,
|
| 451 |
+
height: float,
|
| 452 |
+
mutation_size: float,
|
| 453 |
+
) -> Path: ...
|
| 454 |
+
|
| 455 |
+
class Roundtooth(Sawtooth):
|
| 456 |
+
def __call__(
|
| 457 |
+
self,
|
| 458 |
+
x0: float,
|
| 459 |
+
y0: float,
|
| 460 |
+
width: float,
|
| 461 |
+
height: float,
|
| 462 |
+
mutation_size: float,
|
| 463 |
+
) -> Path: ...
|
| 464 |
+
|
| 465 |
+
class ConnectionStyle(_Style):
|
| 466 |
+
class _Base(ConnectionStyle):
|
| 467 |
+
def __call__(
|
| 468 |
+
self,
|
| 469 |
+
posA: tuple[float, float],
|
| 470 |
+
posB: tuple[float, float],
|
| 471 |
+
shrinkA: float = ...,
|
| 472 |
+
shrinkB: float = ...,
|
| 473 |
+
patchA: Patch | None = ...,
|
| 474 |
+
patchB: Patch | None = ...,
|
| 475 |
+
) -> Path: ...
|
| 476 |
+
|
| 477 |
+
class Arc3(_Base):
|
| 478 |
+
rad: float
|
| 479 |
+
def __init__(self, rad: float = ...) -> None: ...
|
| 480 |
+
def connect(
|
| 481 |
+
self, posA: tuple[float, float], posB: tuple[float, float]
|
| 482 |
+
) -> Path: ...
|
| 483 |
+
|
| 484 |
+
class Angle3(_Base):
|
| 485 |
+
angleA: float
|
| 486 |
+
angleB: float
|
| 487 |
+
def __init__(self, angleA: float = ..., angleB: float = ...) -> None: ...
|
| 488 |
+
def connect(
|
| 489 |
+
self, posA: tuple[float, float], posB: tuple[float, float]
|
| 490 |
+
) -> Path: ...
|
| 491 |
+
|
| 492 |
+
class Angle(_Base):
|
| 493 |
+
angleA: float
|
| 494 |
+
angleB: float
|
| 495 |
+
rad: float
|
| 496 |
+
def __init__(
|
| 497 |
+
self, angleA: float = ..., angleB: float = ..., rad: float = ...
|
| 498 |
+
) -> None: ...
|
| 499 |
+
def connect(
|
| 500 |
+
self, posA: tuple[float, float], posB: tuple[float, float]
|
| 501 |
+
) -> Path: ...
|
| 502 |
+
|
| 503 |
+
class Arc(_Base):
|
| 504 |
+
angleA: float
|
| 505 |
+
angleB: float
|
| 506 |
+
armA: float | None
|
| 507 |
+
armB: float | None
|
| 508 |
+
rad: float
|
| 509 |
+
def __init__(
|
| 510 |
+
self,
|
| 511 |
+
angleA: float = ...,
|
| 512 |
+
angleB: float = ...,
|
| 513 |
+
armA: float | None = ...,
|
| 514 |
+
armB: float | None = ...,
|
| 515 |
+
rad: float = ...,
|
| 516 |
+
) -> None: ...
|
| 517 |
+
def connect(
|
| 518 |
+
self, posA: tuple[float, float], posB: tuple[float, float]
|
| 519 |
+
) -> Path: ...
|
| 520 |
+
|
| 521 |
+
class Bar(_Base):
|
| 522 |
+
armA: float
|
| 523 |
+
armB: float
|
| 524 |
+
fraction: float
|
| 525 |
+
angle: float | None
|
| 526 |
+
def __init__(
|
| 527 |
+
self,
|
| 528 |
+
armA: float = ...,
|
| 529 |
+
armB: float = ...,
|
| 530 |
+
fraction: float = ...,
|
| 531 |
+
angle: float | None = ...,
|
| 532 |
+
) -> None: ...
|
| 533 |
+
def connect(
|
| 534 |
+
self, posA: tuple[float, float], posB: tuple[float, float]
|
| 535 |
+
) -> Path: ...
|
| 536 |
+
|
| 537 |
+
class ArrowStyle(_Style):
|
| 538 |
+
class _Base(ArrowStyle):
|
| 539 |
+
@staticmethod
|
| 540 |
+
def ensure_quadratic_bezier(path: Path) -> list[float]: ...
|
| 541 |
+
def transmute(
|
| 542 |
+
self, path: Path, mutation_size: float, linewidth: float
|
| 543 |
+
) -> tuple[Path, bool]: ...
|
| 544 |
+
def __call__(
|
| 545 |
+
self,
|
| 546 |
+
path: Path,
|
| 547 |
+
mutation_size: float,
|
| 548 |
+
linewidth: float,
|
| 549 |
+
aspect_ratio: float = ...,
|
| 550 |
+
) -> tuple[Path, bool]: ...
|
| 551 |
+
|
| 552 |
+
class _Curve(_Base):
|
| 553 |
+
arrow: str
|
| 554 |
+
fillbegin: bool
|
| 555 |
+
fillend: bool
|
| 556 |
+
def __init__(
|
| 557 |
+
self,
|
| 558 |
+
head_length: float = ...,
|
| 559 |
+
head_width: float = ...,
|
| 560 |
+
widthA: float = ...,
|
| 561 |
+
widthB: float = ...,
|
| 562 |
+
lengthA: float = ...,
|
| 563 |
+
lengthB: float = ...,
|
| 564 |
+
angleA: float | None = ...,
|
| 565 |
+
angleB: float | None = ...,
|
| 566 |
+
scaleA: float | None = ...,
|
| 567 |
+
scaleB: float | None = ...,
|
| 568 |
+
) -> None: ...
|
| 569 |
+
|
| 570 |
+
class Curve(_Curve):
|
| 571 |
+
def __init__(self) -> None: ...
|
| 572 |
+
|
| 573 |
+
class CurveA(_Curve):
|
| 574 |
+
arrow: str
|
| 575 |
+
|
| 576 |
+
class CurveB(_Curve):
|
| 577 |
+
arrow: str
|
| 578 |
+
|
| 579 |
+
class CurveAB(_Curve):
|
| 580 |
+
arrow: str
|
| 581 |
+
|
| 582 |
+
class CurveFilledA(_Curve):
|
| 583 |
+
arrow: str
|
| 584 |
+
|
| 585 |
+
class CurveFilledB(_Curve):
|
| 586 |
+
arrow: str
|
| 587 |
+
|
| 588 |
+
class CurveFilledAB(_Curve):
|
| 589 |
+
arrow: str
|
| 590 |
+
|
| 591 |
+
class BracketA(_Curve):
|
| 592 |
+
arrow: str
|
| 593 |
+
def __init__(
|
| 594 |
+
self, widthA: float = ..., lengthA: float = ..., angleA: float = ...
|
| 595 |
+
) -> None: ...
|
| 596 |
+
|
| 597 |
+
class BracketB(_Curve):
|
| 598 |
+
arrow: str
|
| 599 |
+
def __init__(
|
| 600 |
+
self, widthB: float = ..., lengthB: float = ..., angleB: float = ...
|
| 601 |
+
) -> None: ...
|
| 602 |
+
|
| 603 |
+
class BracketAB(_Curve):
|
| 604 |
+
arrow: str
|
| 605 |
+
def __init__(
|
| 606 |
+
self,
|
| 607 |
+
widthA: float = ...,
|
| 608 |
+
lengthA: float = ...,
|
| 609 |
+
angleA: float = ...,
|
| 610 |
+
widthB: float = ...,
|
| 611 |
+
lengthB: float = ...,
|
| 612 |
+
angleB: float = ...,
|
| 613 |
+
) -> None: ...
|
| 614 |
+
|
| 615 |
+
class BarAB(_Curve):
|
| 616 |
+
arrow: str
|
| 617 |
+
def __init__(
|
| 618 |
+
self,
|
| 619 |
+
widthA: float = ...,
|
| 620 |
+
angleA: float = ...,
|
| 621 |
+
widthB: float = ...,
|
| 622 |
+
angleB: float = ...,
|
| 623 |
+
) -> None: ...
|
| 624 |
+
|
| 625 |
+
class BracketCurve(_Curve):
|
| 626 |
+
arrow: str
|
| 627 |
+
def __init__(
|
| 628 |
+
self, widthA: float = ..., lengthA: float = ..., angleA: float | None = ...
|
| 629 |
+
) -> None: ...
|
| 630 |
+
|
| 631 |
+
class CurveBracket(_Curve):
|
| 632 |
+
arrow: str
|
| 633 |
+
def __init__(
|
| 634 |
+
self, widthB: float = ..., lengthB: float = ..., angleB: float | None = ...
|
| 635 |
+
) -> None: ...
|
| 636 |
+
|
| 637 |
+
class Simple(_Base):
|
| 638 |
+
def __init__(
|
| 639 |
+
self,
|
| 640 |
+
head_length: float = ...,
|
| 641 |
+
head_width: float = ...,
|
| 642 |
+
tail_width: float = ...,
|
| 643 |
+
) -> None: ...
|
| 644 |
+
|
| 645 |
+
class Fancy(_Base):
|
| 646 |
+
def __init__(
|
| 647 |
+
self,
|
| 648 |
+
head_length: float = ...,
|
| 649 |
+
head_width: float = ...,
|
| 650 |
+
tail_width: float = ...,
|
| 651 |
+
) -> None: ...
|
| 652 |
+
|
| 653 |
+
class Wedge(_Base):
|
| 654 |
+
tail_width: float
|
| 655 |
+
shrink_factor: float
|
| 656 |
+
def __init__(
|
| 657 |
+
self, tail_width: float = ..., shrink_factor: float = ...
|
| 658 |
+
) -> None: ...
|
| 659 |
+
|
| 660 |
+
class FancyBboxPatch(Patch):
|
| 661 |
+
def __init__(
|
| 662 |
+
self,
|
| 663 |
+
xy: tuple[float, float],
|
| 664 |
+
width: float,
|
| 665 |
+
height: float,
|
| 666 |
+
boxstyle: str | BoxStyle = ...,
|
| 667 |
+
*,
|
| 668 |
+
mutation_scale: float = ...,
|
| 669 |
+
mutation_aspect: float = ...,
|
| 670 |
+
**kwargs,
|
| 671 |
+
) -> None: ...
|
| 672 |
+
def set_boxstyle(self, boxstyle: str | BoxStyle | None = ..., **kwargs) -> None: ...
|
| 673 |
+
def get_boxstyle(self) -> BoxStyle: ...
|
| 674 |
+
def set_mutation_scale(self, scale: float) -> None: ...
|
| 675 |
+
def get_mutation_scale(self) -> float: ...
|
| 676 |
+
def set_mutation_aspect(self, aspect: float) -> None: ...
|
| 677 |
+
def get_mutation_aspect(self) -> float: ...
|
| 678 |
+
def get_x(self) -> float: ...
|
| 679 |
+
def get_y(self) -> float: ...
|
| 680 |
+
def get_width(self) -> float: ...
|
| 681 |
+
def get_height(self) -> float: ...
|
| 682 |
+
def set_x(self, x: float) -> None: ...
|
| 683 |
+
def set_y(self, y: float) -> None: ...
|
| 684 |
+
def set_width(self, w: float) -> None: ...
|
| 685 |
+
def set_height(self, h: float) -> None: ...
|
| 686 |
+
@overload
|
| 687 |
+
def set_bounds(self, args: tuple[float, float, float, float], /) -> None: ...
|
| 688 |
+
@overload
|
| 689 |
+
def set_bounds(
|
| 690 |
+
self, left: float, bottom: float, width: float, height: float, /
|
| 691 |
+
) -> None: ...
|
| 692 |
+
def get_bbox(self) -> Bbox: ...
|
| 693 |
+
|
| 694 |
+
class FancyArrowPatch(Patch):
|
| 695 |
+
patchA: Patch
|
| 696 |
+
patchB: Patch
|
| 697 |
+
shrinkA: float
|
| 698 |
+
shrinkB: float
|
| 699 |
+
def __init__(
|
| 700 |
+
self,
|
| 701 |
+
posA: tuple[float, float] | None = ...,
|
| 702 |
+
posB: tuple[float, float] | None = ...,
|
| 703 |
+
*,
|
| 704 |
+
path: Path | None = ...,
|
| 705 |
+
arrowstyle: str | ArrowStyle = ...,
|
| 706 |
+
connectionstyle: str | ConnectionStyle = ...,
|
| 707 |
+
patchA: Patch | None = ...,
|
| 708 |
+
patchB: Patch | None = ...,
|
| 709 |
+
shrinkA: float = ...,
|
| 710 |
+
shrinkB: float = ...,
|
| 711 |
+
mutation_scale: float = ...,
|
| 712 |
+
mutation_aspect: float | None = ...,
|
| 713 |
+
**kwargs,
|
| 714 |
+
) -> None: ...
|
| 715 |
+
def set_positions(
|
| 716 |
+
self, posA: tuple[float, float], posB: tuple[float, float]
|
| 717 |
+
) -> None: ...
|
| 718 |
+
def set_patchA(self, patchA: Patch) -> None: ...
|
| 719 |
+
def set_patchB(self, patchB: Patch) -> None: ...
|
| 720 |
+
def set_connectionstyle(self, connectionstyle: str | ConnectionStyle | None = ..., **kwargs) -> None: ...
|
| 721 |
+
def get_connectionstyle(self) -> ConnectionStyle: ...
|
| 722 |
+
def set_arrowstyle(self, arrowstyle: str | ArrowStyle | None = ..., **kwargs) -> None: ...
|
| 723 |
+
def get_arrowstyle(self) -> ArrowStyle: ...
|
| 724 |
+
def set_mutation_scale(self, scale: float) -> None: ...
|
| 725 |
+
def get_mutation_scale(self) -> float: ...
|
| 726 |
+
def set_mutation_aspect(self, aspect: float | None) -> None: ...
|
| 727 |
+
def get_mutation_aspect(self) -> float: ...
|
| 728 |
+
|
| 729 |
+
class ConnectionPatch(FancyArrowPatch):
|
| 730 |
+
xy1: tuple[float, float]
|
| 731 |
+
xy2: tuple[float, float]
|
| 732 |
+
coords1: str | Transform
|
| 733 |
+
coords2: str | Transform | None
|
| 734 |
+
axesA: Axes | None
|
| 735 |
+
axesB: Axes | None
|
| 736 |
+
def __init__(
|
| 737 |
+
self,
|
| 738 |
+
xyA: tuple[float, float],
|
| 739 |
+
xyB: tuple[float, float],
|
| 740 |
+
coordsA: str | Transform,
|
| 741 |
+
coordsB: str | Transform | None = ...,
|
| 742 |
+
*,
|
| 743 |
+
axesA: Axes | None = ...,
|
| 744 |
+
axesB: Axes | None = ...,
|
| 745 |
+
arrowstyle: str | ArrowStyle = ...,
|
| 746 |
+
connectionstyle: str | ConnectionStyle = ...,
|
| 747 |
+
patchA: Patch | None = ...,
|
| 748 |
+
patchB: Patch | None = ...,
|
| 749 |
+
shrinkA: float = ...,
|
| 750 |
+
shrinkB: float = ...,
|
| 751 |
+
mutation_scale: float = ...,
|
| 752 |
+
mutation_aspect: float | None = ...,
|
| 753 |
+
clip_on: bool = ...,
|
| 754 |
+
**kwargs,
|
| 755 |
+
) -> None: ...
|
| 756 |
+
def set_annotation_clip(self, b: bool | None) -> None: ...
|
| 757 |
+
def get_annotation_clip(self) -> bool | None: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/path.py
ADDED
|
@@ -0,0 +1,1093 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
r"""
|
| 2 |
+
A module for dealing with the polylines used throughout Matplotlib.
|
| 3 |
+
|
| 4 |
+
The primary class for polyline handling in Matplotlib is `Path`. Almost all
|
| 5 |
+
vector drawing makes use of `Path`\s somewhere in the drawing pipeline.
|
| 6 |
+
|
| 7 |
+
Whilst a `Path` instance itself cannot be drawn, some `.Artist` subclasses,
|
| 8 |
+
such as `.PathPatch` and `.PathCollection`, can be used for convenient `Path`
|
| 9 |
+
visualisation.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
import copy
|
| 13 |
+
from functools import lru_cache
|
| 14 |
+
from weakref import WeakValueDictionary
|
| 15 |
+
|
| 16 |
+
import numpy as np
|
| 17 |
+
|
| 18 |
+
import matplotlib as mpl
|
| 19 |
+
from . import _api, _path
|
| 20 |
+
from .cbook import _to_unmasked_float_array, simple_linear_interpolation
|
| 21 |
+
from .bezier import BezierSegment
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Path:
|
| 25 |
+
"""
|
| 26 |
+
A series of possibly disconnected, possibly closed, line and curve
|
| 27 |
+
segments.
|
| 28 |
+
|
| 29 |
+
The underlying storage is made up of two parallel numpy arrays:
|
| 30 |
+
|
| 31 |
+
- *vertices*: an (N, 2) float array of vertices
|
| 32 |
+
- *codes*: an N-length `numpy.uint8` array of path codes, or None
|
| 33 |
+
|
| 34 |
+
These two arrays always have the same length in the first
|
| 35 |
+
dimension. For example, to represent a cubic curve, you must
|
| 36 |
+
provide three vertices and three `CURVE4` codes.
|
| 37 |
+
|
| 38 |
+
The code types are:
|
| 39 |
+
|
| 40 |
+
- `STOP` : 1 vertex (ignored)
|
| 41 |
+
A marker for the end of the entire path (currently not required and
|
| 42 |
+
ignored)
|
| 43 |
+
|
| 44 |
+
- `MOVETO` : 1 vertex
|
| 45 |
+
Pick up the pen and move to the given vertex.
|
| 46 |
+
|
| 47 |
+
- `LINETO` : 1 vertex
|
| 48 |
+
Draw a line from the current position to the given vertex.
|
| 49 |
+
|
| 50 |
+
- `CURVE3` : 1 control point, 1 endpoint
|
| 51 |
+
Draw a quadratic Bézier curve from the current position, with the given
|
| 52 |
+
control point, to the given end point.
|
| 53 |
+
|
| 54 |
+
- `CURVE4` : 2 control points, 1 endpoint
|
| 55 |
+
Draw a cubic Bézier curve from the current position, with the given
|
| 56 |
+
control points, to the given end point.
|
| 57 |
+
|
| 58 |
+
- `CLOSEPOLY` : 1 vertex (ignored)
|
| 59 |
+
Draw a line segment to the start point of the current polyline.
|
| 60 |
+
|
| 61 |
+
If *codes* is None, it is interpreted as a `MOVETO` followed by a series
|
| 62 |
+
of `LINETO`.
|
| 63 |
+
|
| 64 |
+
Users of Path objects should not access the vertices and codes arrays
|
| 65 |
+
directly. Instead, they should use `iter_segments` or `cleaned` to get the
|
| 66 |
+
vertex/code pairs. This helps, in particular, to consistently handle the
|
| 67 |
+
case of *codes* being None.
|
| 68 |
+
|
| 69 |
+
Some behavior of Path objects can be controlled by rcParams. See the
|
| 70 |
+
rcParams whose keys start with 'path.'.
|
| 71 |
+
|
| 72 |
+
.. note::
|
| 73 |
+
|
| 74 |
+
The vertices and codes arrays should be treated as
|
| 75 |
+
immutable -- there are a number of optimizations and assumptions
|
| 76 |
+
made up front in the constructor that will not change when the
|
| 77 |
+
data changes.
|
| 78 |
+
"""
|
| 79 |
+
|
| 80 |
+
code_type = np.uint8
|
| 81 |
+
|
| 82 |
+
# Path codes
|
| 83 |
+
STOP = code_type(0) # 1 vertex
|
| 84 |
+
MOVETO = code_type(1) # 1 vertex
|
| 85 |
+
LINETO = code_type(2) # 1 vertex
|
| 86 |
+
CURVE3 = code_type(3) # 2 vertices
|
| 87 |
+
CURVE4 = code_type(4) # 3 vertices
|
| 88 |
+
CLOSEPOLY = code_type(79) # 1 vertex
|
| 89 |
+
|
| 90 |
+
#: A dictionary mapping Path codes to the number of vertices that the
|
| 91 |
+
#: code expects.
|
| 92 |
+
NUM_VERTICES_FOR_CODE = {STOP: 1,
|
| 93 |
+
MOVETO: 1,
|
| 94 |
+
LINETO: 1,
|
| 95 |
+
CURVE3: 2,
|
| 96 |
+
CURVE4: 3,
|
| 97 |
+
CLOSEPOLY: 1}
|
| 98 |
+
|
| 99 |
+
def __init__(self, vertices, codes=None, _interpolation_steps=1,
|
| 100 |
+
closed=False, readonly=False):
|
| 101 |
+
"""
|
| 102 |
+
Create a new path with the given vertices and codes.
|
| 103 |
+
|
| 104 |
+
Parameters
|
| 105 |
+
----------
|
| 106 |
+
vertices : (N, 2) array-like
|
| 107 |
+
The path vertices, as an array, masked array or sequence of pairs.
|
| 108 |
+
Masked values, if any, will be converted to NaNs, which are then
|
| 109 |
+
handled correctly by the Agg PathIterator and other consumers of
|
| 110 |
+
path data, such as :meth:`iter_segments`.
|
| 111 |
+
codes : array-like or None, optional
|
| 112 |
+
N-length array of integers representing the codes of the path.
|
| 113 |
+
If not None, codes must be the same length as vertices.
|
| 114 |
+
If None, *vertices* will be treated as a series of line segments.
|
| 115 |
+
_interpolation_steps : int, optional
|
| 116 |
+
Used as a hint to certain projections, such as Polar, that this
|
| 117 |
+
path should be linearly interpolated immediately before drawing.
|
| 118 |
+
This attribute is primarily an implementation detail and is not
|
| 119 |
+
intended for public use.
|
| 120 |
+
closed : bool, optional
|
| 121 |
+
If *codes* is None and closed is True, vertices will be treated as
|
| 122 |
+
line segments of a closed polygon. Note that the last vertex will
|
| 123 |
+
then be ignored (as the corresponding code will be set to
|
| 124 |
+
`CLOSEPOLY`).
|
| 125 |
+
readonly : bool, optional
|
| 126 |
+
Makes the path behave in an immutable way and sets the vertices
|
| 127 |
+
and codes as read-only arrays.
|
| 128 |
+
"""
|
| 129 |
+
vertices = _to_unmasked_float_array(vertices)
|
| 130 |
+
_api.check_shape((None, 2), vertices=vertices)
|
| 131 |
+
|
| 132 |
+
if codes is not None and len(vertices):
|
| 133 |
+
codes = np.asarray(codes, self.code_type)
|
| 134 |
+
if codes.ndim != 1 or len(codes) != len(vertices):
|
| 135 |
+
raise ValueError("'codes' must be a 1D list or array with the "
|
| 136 |
+
"same length of 'vertices'. "
|
| 137 |
+
f"Your vertices have shape {vertices.shape} "
|
| 138 |
+
f"but your codes have shape {codes.shape}")
|
| 139 |
+
if len(codes) and codes[0] != self.MOVETO:
|
| 140 |
+
raise ValueError("The first element of 'code' must be equal "
|
| 141 |
+
f"to 'MOVETO' ({self.MOVETO}). "
|
| 142 |
+
f"Your first code is {codes[0]}")
|
| 143 |
+
elif closed and len(vertices):
|
| 144 |
+
codes = np.empty(len(vertices), dtype=self.code_type)
|
| 145 |
+
codes[0] = self.MOVETO
|
| 146 |
+
codes[1:-1] = self.LINETO
|
| 147 |
+
codes[-1] = self.CLOSEPOLY
|
| 148 |
+
|
| 149 |
+
self._vertices = vertices
|
| 150 |
+
self._codes = codes
|
| 151 |
+
self._interpolation_steps = _interpolation_steps
|
| 152 |
+
self._update_values()
|
| 153 |
+
|
| 154 |
+
if readonly:
|
| 155 |
+
self._vertices.flags.writeable = False
|
| 156 |
+
if self._codes is not None:
|
| 157 |
+
self._codes.flags.writeable = False
|
| 158 |
+
self._readonly = True
|
| 159 |
+
else:
|
| 160 |
+
self._readonly = False
|
| 161 |
+
|
| 162 |
+
@classmethod
|
| 163 |
+
def _fast_from_codes_and_verts(cls, verts, codes, internals_from=None):
|
| 164 |
+
"""
|
| 165 |
+
Create a Path instance without the expense of calling the constructor.
|
| 166 |
+
|
| 167 |
+
Parameters
|
| 168 |
+
----------
|
| 169 |
+
verts : array-like
|
| 170 |
+
codes : array
|
| 171 |
+
internals_from : Path or None
|
| 172 |
+
If not None, another `Path` from which the attributes
|
| 173 |
+
``should_simplify``, ``simplify_threshold``, and
|
| 174 |
+
``interpolation_steps`` will be copied. Note that ``readonly`` is
|
| 175 |
+
never copied, and always set to ``False`` by this constructor.
|
| 176 |
+
"""
|
| 177 |
+
pth = cls.__new__(cls)
|
| 178 |
+
pth._vertices = _to_unmasked_float_array(verts)
|
| 179 |
+
pth._codes = codes
|
| 180 |
+
pth._readonly = False
|
| 181 |
+
if internals_from is not None:
|
| 182 |
+
pth._should_simplify = internals_from._should_simplify
|
| 183 |
+
pth._simplify_threshold = internals_from._simplify_threshold
|
| 184 |
+
pth._interpolation_steps = internals_from._interpolation_steps
|
| 185 |
+
else:
|
| 186 |
+
pth._should_simplify = True
|
| 187 |
+
pth._simplify_threshold = mpl.rcParams['path.simplify_threshold']
|
| 188 |
+
pth._interpolation_steps = 1
|
| 189 |
+
return pth
|
| 190 |
+
|
| 191 |
+
@classmethod
|
| 192 |
+
def _create_closed(cls, vertices):
|
| 193 |
+
"""
|
| 194 |
+
Create a closed polygonal path going through *vertices*.
|
| 195 |
+
|
| 196 |
+
Unlike ``Path(..., closed=True)``, *vertices* should **not** end with
|
| 197 |
+
an entry for the CLOSEPATH; this entry is added by `._create_closed`.
|
| 198 |
+
"""
|
| 199 |
+
v = _to_unmasked_float_array(vertices)
|
| 200 |
+
return cls(np.concatenate([v, v[:1]]), closed=True)
|
| 201 |
+
|
| 202 |
+
def _update_values(self):
|
| 203 |
+
self._simplify_threshold = mpl.rcParams['path.simplify_threshold']
|
| 204 |
+
self._should_simplify = (
|
| 205 |
+
self._simplify_threshold > 0 and
|
| 206 |
+
mpl.rcParams['path.simplify'] and
|
| 207 |
+
len(self._vertices) >= 128 and
|
| 208 |
+
(self._codes is None or np.all(self._codes <= Path.LINETO))
|
| 209 |
+
)
|
| 210 |
+
|
| 211 |
+
@property
|
| 212 |
+
def vertices(self):
|
| 213 |
+
"""The vertices of the `Path` as an (N, 2) array."""
|
| 214 |
+
return self._vertices
|
| 215 |
+
|
| 216 |
+
@vertices.setter
|
| 217 |
+
def vertices(self, vertices):
|
| 218 |
+
if self._readonly:
|
| 219 |
+
raise AttributeError("Can't set vertices on a readonly Path")
|
| 220 |
+
self._vertices = vertices
|
| 221 |
+
self._update_values()
|
| 222 |
+
|
| 223 |
+
@property
|
| 224 |
+
def codes(self):
|
| 225 |
+
"""
|
| 226 |
+
The list of codes in the `Path` as a 1D array.
|
| 227 |
+
|
| 228 |
+
Each code is one of `STOP`, `MOVETO`, `LINETO`, `CURVE3`, `CURVE4` or
|
| 229 |
+
`CLOSEPOLY`. For codes that correspond to more than one vertex
|
| 230 |
+
(`CURVE3` and `CURVE4`), that code will be repeated so that the length
|
| 231 |
+
of `vertices` and `codes` is always the same.
|
| 232 |
+
"""
|
| 233 |
+
return self._codes
|
| 234 |
+
|
| 235 |
+
@codes.setter
|
| 236 |
+
def codes(self, codes):
|
| 237 |
+
if self._readonly:
|
| 238 |
+
raise AttributeError("Can't set codes on a readonly Path")
|
| 239 |
+
self._codes = codes
|
| 240 |
+
self._update_values()
|
| 241 |
+
|
| 242 |
+
@property
|
| 243 |
+
def simplify_threshold(self):
|
| 244 |
+
"""
|
| 245 |
+
The fraction of a pixel difference below which vertices will
|
| 246 |
+
be simplified out.
|
| 247 |
+
"""
|
| 248 |
+
return self._simplify_threshold
|
| 249 |
+
|
| 250 |
+
@simplify_threshold.setter
|
| 251 |
+
def simplify_threshold(self, threshold):
|
| 252 |
+
self._simplify_threshold = threshold
|
| 253 |
+
|
| 254 |
+
@property
|
| 255 |
+
def should_simplify(self):
|
| 256 |
+
"""
|
| 257 |
+
`True` if the vertices array should be simplified.
|
| 258 |
+
"""
|
| 259 |
+
return self._should_simplify
|
| 260 |
+
|
| 261 |
+
@should_simplify.setter
|
| 262 |
+
def should_simplify(self, should_simplify):
|
| 263 |
+
self._should_simplify = should_simplify
|
| 264 |
+
|
| 265 |
+
@property
|
| 266 |
+
def readonly(self):
|
| 267 |
+
"""
|
| 268 |
+
`True` if the `Path` is read-only.
|
| 269 |
+
"""
|
| 270 |
+
return self._readonly
|
| 271 |
+
|
| 272 |
+
def copy(self):
|
| 273 |
+
"""
|
| 274 |
+
Return a shallow copy of the `Path`, which will share the
|
| 275 |
+
vertices and codes with the source `Path`.
|
| 276 |
+
"""
|
| 277 |
+
return copy.copy(self)
|
| 278 |
+
|
| 279 |
+
def __deepcopy__(self, memo=None):
|
| 280 |
+
"""
|
| 281 |
+
Return a deepcopy of the `Path`. The `Path` will not be
|
| 282 |
+
readonly, even if the source `Path` is.
|
| 283 |
+
"""
|
| 284 |
+
# Deepcopying arrays (vertices, codes) strips the writeable=False flag.
|
| 285 |
+
p = copy.deepcopy(super(), memo)
|
| 286 |
+
p._readonly = False
|
| 287 |
+
return p
|
| 288 |
+
|
| 289 |
+
deepcopy = __deepcopy__
|
| 290 |
+
|
| 291 |
+
@classmethod
|
| 292 |
+
def make_compound_path_from_polys(cls, XY):
|
| 293 |
+
"""
|
| 294 |
+
Make a compound `Path` object to draw a number of polygons with equal
|
| 295 |
+
numbers of sides.
|
| 296 |
+
|
| 297 |
+
.. plot:: gallery/misc/histogram_path.py
|
| 298 |
+
|
| 299 |
+
Parameters
|
| 300 |
+
----------
|
| 301 |
+
XY : (numpolys, numsides, 2) array
|
| 302 |
+
"""
|
| 303 |
+
# for each poly: 1 for the MOVETO, (numsides-1) for the LINETO, 1 for
|
| 304 |
+
# the CLOSEPOLY; the vert for the closepoly is ignored but we still
|
| 305 |
+
# need it to keep the codes aligned with the vertices
|
| 306 |
+
numpolys, numsides, two = XY.shape
|
| 307 |
+
if two != 2:
|
| 308 |
+
raise ValueError("The third dimension of 'XY' must be 2")
|
| 309 |
+
stride = numsides + 1
|
| 310 |
+
nverts = numpolys * stride
|
| 311 |
+
verts = np.zeros((nverts, 2))
|
| 312 |
+
codes = np.full(nverts, cls.LINETO, dtype=cls.code_type)
|
| 313 |
+
codes[0::stride] = cls.MOVETO
|
| 314 |
+
codes[numsides::stride] = cls.CLOSEPOLY
|
| 315 |
+
for i in range(numsides):
|
| 316 |
+
verts[i::stride] = XY[:, i]
|
| 317 |
+
return cls(verts, codes)
|
| 318 |
+
|
| 319 |
+
@classmethod
|
| 320 |
+
def make_compound_path(cls, *args):
|
| 321 |
+
r"""
|
| 322 |
+
Concatenate a list of `Path`\s into a single `Path`, removing all `STOP`\s.
|
| 323 |
+
"""
|
| 324 |
+
if not args:
|
| 325 |
+
return Path(np.empty([0, 2], dtype=np.float32))
|
| 326 |
+
vertices = np.concatenate([path.vertices for path in args])
|
| 327 |
+
codes = np.empty(len(vertices), dtype=cls.code_type)
|
| 328 |
+
i = 0
|
| 329 |
+
for path in args:
|
| 330 |
+
size = len(path.vertices)
|
| 331 |
+
if path.codes is None:
|
| 332 |
+
if size:
|
| 333 |
+
codes[i] = cls.MOVETO
|
| 334 |
+
codes[i+1:i+size] = cls.LINETO
|
| 335 |
+
else:
|
| 336 |
+
codes[i:i+size] = path.codes
|
| 337 |
+
i += size
|
| 338 |
+
not_stop_mask = codes != cls.STOP # Remove STOPs, as internal STOPs are a bug.
|
| 339 |
+
return cls(vertices[not_stop_mask], codes[not_stop_mask])
|
| 340 |
+
|
| 341 |
+
def __repr__(self):
|
| 342 |
+
return f"Path({self.vertices!r}, {self.codes!r})"
|
| 343 |
+
|
| 344 |
+
def __len__(self):
|
| 345 |
+
return len(self.vertices)
|
| 346 |
+
|
| 347 |
+
def iter_segments(self, transform=None, remove_nans=True, clip=None,
|
| 348 |
+
snap=False, stroke_width=1.0, simplify=None,
|
| 349 |
+
curves=True, sketch=None):
|
| 350 |
+
"""
|
| 351 |
+
Iterate over all curve segments in the path.
|
| 352 |
+
|
| 353 |
+
Each iteration returns a pair ``(vertices, code)``, where ``vertices``
|
| 354 |
+
is a sequence of 1-3 coordinate pairs, and ``code`` is a `Path` code.
|
| 355 |
+
|
| 356 |
+
Additionally, this method can provide a number of standard cleanups and
|
| 357 |
+
conversions to the path.
|
| 358 |
+
|
| 359 |
+
Parameters
|
| 360 |
+
----------
|
| 361 |
+
transform : None or :class:`~matplotlib.transforms.Transform`
|
| 362 |
+
If not None, the given affine transformation will be applied to the
|
| 363 |
+
path.
|
| 364 |
+
remove_nans : bool, optional
|
| 365 |
+
Whether to remove all NaNs from the path and skip over them using
|
| 366 |
+
MOVETO commands.
|
| 367 |
+
clip : None or (float, float, float, float), optional
|
| 368 |
+
If not None, must be a four-tuple (x1, y1, x2, y2)
|
| 369 |
+
defining a rectangle in which to clip the path.
|
| 370 |
+
snap : None or bool, optional
|
| 371 |
+
If True, snap all nodes to pixels; if False, don't snap them.
|
| 372 |
+
If None, snap if the path contains only segments
|
| 373 |
+
parallel to the x or y axes, and no more than 1024 of them.
|
| 374 |
+
stroke_width : float, optional
|
| 375 |
+
The width of the stroke being drawn (used for path snapping).
|
| 376 |
+
simplify : None or bool, optional
|
| 377 |
+
Whether to simplify the path by removing vertices
|
| 378 |
+
that do not affect its appearance. If None, use the
|
| 379 |
+
:attr:`should_simplify` attribute. See also :rc:`path.simplify`
|
| 380 |
+
and :rc:`path.simplify_threshold`.
|
| 381 |
+
curves : bool, optional
|
| 382 |
+
If True, curve segments will be returned as curve segments.
|
| 383 |
+
If False, all curves will be converted to line segments.
|
| 384 |
+
sketch : None or sequence, optional
|
| 385 |
+
If not None, must be a 3-tuple of the form
|
| 386 |
+
(scale, length, randomness), representing the sketch parameters.
|
| 387 |
+
"""
|
| 388 |
+
if not len(self):
|
| 389 |
+
return
|
| 390 |
+
|
| 391 |
+
cleaned = self.cleaned(transform=transform,
|
| 392 |
+
remove_nans=remove_nans, clip=clip,
|
| 393 |
+
snap=snap, stroke_width=stroke_width,
|
| 394 |
+
simplify=simplify, curves=curves,
|
| 395 |
+
sketch=sketch)
|
| 396 |
+
|
| 397 |
+
# Cache these object lookups for performance in the loop.
|
| 398 |
+
NUM_VERTICES_FOR_CODE = self.NUM_VERTICES_FOR_CODE
|
| 399 |
+
STOP = self.STOP
|
| 400 |
+
|
| 401 |
+
vertices = iter(cleaned.vertices)
|
| 402 |
+
codes = iter(cleaned.codes)
|
| 403 |
+
for curr_vertices, code in zip(vertices, codes):
|
| 404 |
+
if code == STOP:
|
| 405 |
+
break
|
| 406 |
+
extra_vertices = NUM_VERTICES_FOR_CODE[code] - 1
|
| 407 |
+
if extra_vertices:
|
| 408 |
+
for i in range(extra_vertices):
|
| 409 |
+
next(codes)
|
| 410 |
+
curr_vertices = np.append(curr_vertices, next(vertices))
|
| 411 |
+
yield curr_vertices, code
|
| 412 |
+
|
| 413 |
+
def iter_bezier(self, **kwargs):
|
| 414 |
+
"""
|
| 415 |
+
Iterate over each Bézier curve (lines included) in a `Path`.
|
| 416 |
+
|
| 417 |
+
Parameters
|
| 418 |
+
----------
|
| 419 |
+
**kwargs
|
| 420 |
+
Forwarded to `.iter_segments`.
|
| 421 |
+
|
| 422 |
+
Yields
|
| 423 |
+
------
|
| 424 |
+
B : `~matplotlib.bezier.BezierSegment`
|
| 425 |
+
The Bézier curves that make up the current path. Note in particular
|
| 426 |
+
that freestanding points are Bézier curves of order 0, and lines
|
| 427 |
+
are Bézier curves of order 1 (with two control points).
|
| 428 |
+
code : `~matplotlib.path.Path.code_type`
|
| 429 |
+
The code describing what kind of curve is being returned.
|
| 430 |
+
`MOVETO`, `LINETO`, `CURVE3`, and `CURVE4` correspond to
|
| 431 |
+
Bézier curves with 1, 2, 3, and 4 control points (respectively).
|
| 432 |
+
`CLOSEPOLY` is a `LINETO` with the control points correctly
|
| 433 |
+
chosen based on the start/end points of the current stroke.
|
| 434 |
+
"""
|
| 435 |
+
first_vert = None
|
| 436 |
+
prev_vert = None
|
| 437 |
+
for verts, code in self.iter_segments(**kwargs):
|
| 438 |
+
if first_vert is None:
|
| 439 |
+
if code != Path.MOVETO:
|
| 440 |
+
raise ValueError("Malformed path, must start with MOVETO.")
|
| 441 |
+
if code == Path.MOVETO: # a point is like "CURVE1"
|
| 442 |
+
first_vert = verts
|
| 443 |
+
yield BezierSegment(np.array([first_vert])), code
|
| 444 |
+
elif code == Path.LINETO: # "CURVE2"
|
| 445 |
+
yield BezierSegment(np.array([prev_vert, verts])), code
|
| 446 |
+
elif code == Path.CURVE3:
|
| 447 |
+
yield BezierSegment(np.array([prev_vert, verts[:2],
|
| 448 |
+
verts[2:]])), code
|
| 449 |
+
elif code == Path.CURVE4:
|
| 450 |
+
yield BezierSegment(np.array([prev_vert, verts[:2],
|
| 451 |
+
verts[2:4], verts[4:]])), code
|
| 452 |
+
elif code == Path.CLOSEPOLY:
|
| 453 |
+
yield BezierSegment(np.array([prev_vert, first_vert])), code
|
| 454 |
+
elif code == Path.STOP:
|
| 455 |
+
return
|
| 456 |
+
else:
|
| 457 |
+
raise ValueError(f"Invalid Path.code_type: {code}")
|
| 458 |
+
prev_vert = verts[-2:]
|
| 459 |
+
|
| 460 |
+
def _iter_connected_components(self):
|
| 461 |
+
"""Return subpaths split at MOVETOs."""
|
| 462 |
+
if self.codes is None:
|
| 463 |
+
yield self
|
| 464 |
+
else:
|
| 465 |
+
idxs = np.append((self.codes == Path.MOVETO).nonzero()[0], len(self.codes))
|
| 466 |
+
for sl in map(slice, idxs, idxs[1:]):
|
| 467 |
+
yield Path._fast_from_codes_and_verts(
|
| 468 |
+
self.vertices[sl], self.codes[sl], self)
|
| 469 |
+
|
| 470 |
+
def cleaned(self, transform=None, remove_nans=False, clip=None,
|
| 471 |
+
*, simplify=False, curves=False,
|
| 472 |
+
stroke_width=1.0, snap=False, sketch=None):
|
| 473 |
+
"""
|
| 474 |
+
Return a new `Path` with vertices and codes cleaned according to the
|
| 475 |
+
parameters.
|
| 476 |
+
|
| 477 |
+
See Also
|
| 478 |
+
--------
|
| 479 |
+
Path.iter_segments : for details of the keyword arguments.
|
| 480 |
+
"""
|
| 481 |
+
vertices, codes = _path.cleanup_path(
|
| 482 |
+
self, transform, remove_nans, clip, snap, stroke_width, simplify,
|
| 483 |
+
curves, sketch)
|
| 484 |
+
pth = Path._fast_from_codes_and_verts(vertices, codes, self)
|
| 485 |
+
if not simplify:
|
| 486 |
+
pth._should_simplify = False
|
| 487 |
+
return pth
|
| 488 |
+
|
| 489 |
+
def transformed(self, transform):
|
| 490 |
+
"""
|
| 491 |
+
Return a transformed copy of the path.
|
| 492 |
+
|
| 493 |
+
See Also
|
| 494 |
+
--------
|
| 495 |
+
matplotlib.transforms.TransformedPath
|
| 496 |
+
A specialized path class that will cache the transformed result and
|
| 497 |
+
automatically update when the transform changes.
|
| 498 |
+
"""
|
| 499 |
+
return Path(transform.transform(self.vertices), self.codes,
|
| 500 |
+
self._interpolation_steps)
|
| 501 |
+
|
| 502 |
+
def contains_point(self, point, transform=None, radius=0.0):
|
| 503 |
+
"""
|
| 504 |
+
Return whether the area enclosed by the path contains the given point.
|
| 505 |
+
|
| 506 |
+
The path is always treated as closed; i.e. if the last code is not
|
| 507 |
+
`CLOSEPOLY` an implicit segment connecting the last vertex to the first
|
| 508 |
+
vertex is assumed.
|
| 509 |
+
|
| 510 |
+
Parameters
|
| 511 |
+
----------
|
| 512 |
+
point : (float, float)
|
| 513 |
+
The point (x, y) to check.
|
| 514 |
+
transform : `~matplotlib.transforms.Transform`, optional
|
| 515 |
+
If not ``None``, *point* will be compared to ``self`` transformed
|
| 516 |
+
by *transform*; i.e. for a correct check, *transform* should
|
| 517 |
+
transform the path into the coordinate system of *point*.
|
| 518 |
+
radius : float, default: 0
|
| 519 |
+
Additional margin on the path in coordinates of *point*.
|
| 520 |
+
The path is extended tangentially by *radius/2*; i.e. if you would
|
| 521 |
+
draw the path with a linewidth of *radius*, all points on the line
|
| 522 |
+
would still be considered to be contained in the area. Conversely,
|
| 523 |
+
negative values shrink the area: Points on the imaginary line
|
| 524 |
+
will be considered outside the area.
|
| 525 |
+
|
| 526 |
+
Returns
|
| 527 |
+
-------
|
| 528 |
+
bool
|
| 529 |
+
|
| 530 |
+
Notes
|
| 531 |
+
-----
|
| 532 |
+
The current algorithm has some limitations:
|
| 533 |
+
|
| 534 |
+
- The result is undefined for points exactly at the boundary
|
| 535 |
+
(i.e. at the path shifted by *radius/2*).
|
| 536 |
+
- The result is undefined if there is no enclosed area, i.e. all
|
| 537 |
+
vertices are on a straight line.
|
| 538 |
+
- If bounding lines start to cross each other due to *radius* shift,
|
| 539 |
+
the result is not guaranteed to be correct.
|
| 540 |
+
"""
|
| 541 |
+
if transform is not None:
|
| 542 |
+
transform = transform.frozen()
|
| 543 |
+
# `point_in_path` does not handle nonlinear transforms, so we
|
| 544 |
+
# transform the path ourselves. If *transform* is affine, letting
|
| 545 |
+
# `point_in_path` handle the transform avoids allocating an extra
|
| 546 |
+
# buffer.
|
| 547 |
+
if transform and not transform.is_affine:
|
| 548 |
+
self = transform.transform_path(self)
|
| 549 |
+
transform = None
|
| 550 |
+
return _path.point_in_path(point[0], point[1], radius, self, transform)
|
| 551 |
+
|
| 552 |
+
def contains_points(self, points, transform=None, radius=0.0):
|
| 553 |
+
"""
|
| 554 |
+
Return whether the area enclosed by the path contains the given points.
|
| 555 |
+
|
| 556 |
+
The path is always treated as closed; i.e. if the last code is not
|
| 557 |
+
`CLOSEPOLY` an implicit segment connecting the last vertex to the first
|
| 558 |
+
vertex is assumed.
|
| 559 |
+
|
| 560 |
+
Parameters
|
| 561 |
+
----------
|
| 562 |
+
points : (N, 2) array
|
| 563 |
+
The points to check. Columns contain x and y values.
|
| 564 |
+
transform : `~matplotlib.transforms.Transform`, optional
|
| 565 |
+
If not ``None``, *points* will be compared to ``self`` transformed
|
| 566 |
+
by *transform*; i.e. for a correct check, *transform* should
|
| 567 |
+
transform the path into the coordinate system of *points*.
|
| 568 |
+
radius : float, default: 0
|
| 569 |
+
Additional margin on the path in coordinates of *points*.
|
| 570 |
+
The path is extended tangentially by *radius/2*; i.e. if you would
|
| 571 |
+
draw the path with a linewidth of *radius*, all points on the line
|
| 572 |
+
would still be considered to be contained in the area. Conversely,
|
| 573 |
+
negative values shrink the area: Points on the imaginary line
|
| 574 |
+
will be considered outside the area.
|
| 575 |
+
|
| 576 |
+
Returns
|
| 577 |
+
-------
|
| 578 |
+
length-N bool array
|
| 579 |
+
|
| 580 |
+
Notes
|
| 581 |
+
-----
|
| 582 |
+
The current algorithm has some limitations:
|
| 583 |
+
|
| 584 |
+
- The result is undefined for points exactly at the boundary
|
| 585 |
+
(i.e. at the path shifted by *radius/2*).
|
| 586 |
+
- The result is undefined if there is no enclosed area, i.e. all
|
| 587 |
+
vertices are on a straight line.
|
| 588 |
+
- If bounding lines start to cross each other due to *radius* shift,
|
| 589 |
+
the result is not guaranteed to be correct.
|
| 590 |
+
"""
|
| 591 |
+
if transform is not None:
|
| 592 |
+
transform = transform.frozen()
|
| 593 |
+
result = _path.points_in_path(points, radius, self, transform)
|
| 594 |
+
return result.astype('bool')
|
| 595 |
+
|
| 596 |
+
def contains_path(self, path, transform=None):
|
| 597 |
+
"""
|
| 598 |
+
Return whether this (closed) path completely contains the given path.
|
| 599 |
+
|
| 600 |
+
If *transform* is not ``None``, the path will be transformed before
|
| 601 |
+
checking for containment.
|
| 602 |
+
"""
|
| 603 |
+
if transform is not None:
|
| 604 |
+
transform = transform.frozen()
|
| 605 |
+
return _path.path_in_path(self, None, path, transform)
|
| 606 |
+
|
| 607 |
+
def get_extents(self, transform=None, **kwargs):
|
| 608 |
+
"""
|
| 609 |
+
Get Bbox of the path.
|
| 610 |
+
|
| 611 |
+
Parameters
|
| 612 |
+
----------
|
| 613 |
+
transform : `~matplotlib.transforms.Transform`, optional
|
| 614 |
+
Transform to apply to path before computing extents, if any.
|
| 615 |
+
**kwargs
|
| 616 |
+
Forwarded to `.iter_bezier`.
|
| 617 |
+
|
| 618 |
+
Returns
|
| 619 |
+
-------
|
| 620 |
+
matplotlib.transforms.Bbox
|
| 621 |
+
The extents of the path Bbox([[xmin, ymin], [xmax, ymax]])
|
| 622 |
+
"""
|
| 623 |
+
from .transforms import Bbox
|
| 624 |
+
if transform is not None:
|
| 625 |
+
self = transform.transform_path(self)
|
| 626 |
+
if self.codes is None:
|
| 627 |
+
xys = self.vertices
|
| 628 |
+
elif len(np.intersect1d(self.codes, [Path.CURVE3, Path.CURVE4])) == 0:
|
| 629 |
+
# Optimization for the straight line case.
|
| 630 |
+
# Instead of iterating through each curve, consider
|
| 631 |
+
# each line segment's end-points
|
| 632 |
+
# (recall that STOP and CLOSEPOLY vertices are ignored)
|
| 633 |
+
xys = self.vertices[np.isin(self.codes,
|
| 634 |
+
[Path.MOVETO, Path.LINETO])]
|
| 635 |
+
else:
|
| 636 |
+
xys = []
|
| 637 |
+
for curve, code in self.iter_bezier(**kwargs):
|
| 638 |
+
# places where the derivative is zero can be extrema
|
| 639 |
+
_, dzeros = curve.axis_aligned_extrema()
|
| 640 |
+
# as can the ends of the curve
|
| 641 |
+
xys.append(curve([0, *dzeros, 1]))
|
| 642 |
+
xys = np.concatenate(xys)
|
| 643 |
+
if len(xys):
|
| 644 |
+
return Bbox([xys.min(axis=0), xys.max(axis=0)])
|
| 645 |
+
else:
|
| 646 |
+
return Bbox.null()
|
| 647 |
+
|
| 648 |
+
def intersects_path(self, other, filled=True):
|
| 649 |
+
"""
|
| 650 |
+
Return whether if this path intersects another given path.
|
| 651 |
+
|
| 652 |
+
If *filled* is True, then this also returns True if one path completely
|
| 653 |
+
encloses the other (i.e., the paths are treated as filled).
|
| 654 |
+
"""
|
| 655 |
+
return _path.path_intersects_path(self, other, filled)
|
| 656 |
+
|
| 657 |
+
def intersects_bbox(self, bbox, filled=True):
|
| 658 |
+
"""
|
| 659 |
+
Return whether this path intersects a given `~.transforms.Bbox`.
|
| 660 |
+
|
| 661 |
+
If *filled* is True, then this also returns True if the path completely
|
| 662 |
+
encloses the `.Bbox` (i.e., the path is treated as filled).
|
| 663 |
+
|
| 664 |
+
The bounding box is always considered filled.
|
| 665 |
+
"""
|
| 666 |
+
return _path.path_intersects_rectangle(
|
| 667 |
+
self, bbox.x0, bbox.y0, bbox.x1, bbox.y1, filled)
|
| 668 |
+
|
| 669 |
+
def interpolated(self, steps):
|
| 670 |
+
"""
|
| 671 |
+
Return a new path resampled to length N x *steps*.
|
| 672 |
+
|
| 673 |
+
Codes other than `LINETO` are not handled correctly.
|
| 674 |
+
"""
|
| 675 |
+
if steps == 1:
|
| 676 |
+
return self
|
| 677 |
+
|
| 678 |
+
vertices = simple_linear_interpolation(self.vertices, steps)
|
| 679 |
+
codes = self.codes
|
| 680 |
+
if codes is not None:
|
| 681 |
+
new_codes = np.full((len(codes) - 1) * steps + 1, Path.LINETO,
|
| 682 |
+
dtype=self.code_type)
|
| 683 |
+
new_codes[0::steps] = codes
|
| 684 |
+
else:
|
| 685 |
+
new_codes = None
|
| 686 |
+
return Path(vertices, new_codes)
|
| 687 |
+
|
| 688 |
+
def to_polygons(self, transform=None, width=0, height=0, closed_only=True):
|
| 689 |
+
"""
|
| 690 |
+
Convert this path to a list of polygons or polylines. Each
|
| 691 |
+
polygon/polyline is an (N, 2) array of vertices. In other words,
|
| 692 |
+
each polygon has no `MOVETO` instructions or curves. This
|
| 693 |
+
is useful for displaying in backends that do not support
|
| 694 |
+
compound paths or Bézier curves.
|
| 695 |
+
|
| 696 |
+
If *width* and *height* are both non-zero then the lines will
|
| 697 |
+
be simplified so that vertices outside of (0, 0), (width,
|
| 698 |
+
height) will be clipped.
|
| 699 |
+
|
| 700 |
+
The resulting polygons will be simplified if the
|
| 701 |
+
:attr:`Path.should_simplify` attribute of the path is `True`.
|
| 702 |
+
|
| 703 |
+
If *closed_only* is `True` (default), only closed polygons,
|
| 704 |
+
with the last point being the same as the first point, will be
|
| 705 |
+
returned. Any unclosed polylines in the path will be
|
| 706 |
+
explicitly closed. If *closed_only* is `False`, any unclosed
|
| 707 |
+
polygons in the path will be returned as unclosed polygons,
|
| 708 |
+
and the closed polygons will be returned explicitly closed by
|
| 709 |
+
setting the last point to the same as the first point.
|
| 710 |
+
"""
|
| 711 |
+
if len(self.vertices) == 0:
|
| 712 |
+
return []
|
| 713 |
+
|
| 714 |
+
if transform is not None:
|
| 715 |
+
transform = transform.frozen()
|
| 716 |
+
|
| 717 |
+
if self.codes is None and (width == 0 or height == 0):
|
| 718 |
+
vertices = self.vertices
|
| 719 |
+
if closed_only:
|
| 720 |
+
if len(vertices) < 3:
|
| 721 |
+
return []
|
| 722 |
+
elif np.any(vertices[0] != vertices[-1]):
|
| 723 |
+
vertices = [*vertices, vertices[0]]
|
| 724 |
+
|
| 725 |
+
if transform is None:
|
| 726 |
+
return [vertices]
|
| 727 |
+
else:
|
| 728 |
+
return [transform.transform(vertices)]
|
| 729 |
+
|
| 730 |
+
# Deal with the case where there are curves and/or multiple
|
| 731 |
+
# subpaths (using extension code)
|
| 732 |
+
return _path.convert_path_to_polygons(
|
| 733 |
+
self, transform, width, height, closed_only)
|
| 734 |
+
|
| 735 |
+
_unit_rectangle = None
|
| 736 |
+
|
| 737 |
+
@classmethod
|
| 738 |
+
def unit_rectangle(cls):
|
| 739 |
+
"""
|
| 740 |
+
Return a `Path` instance of the unit rectangle from (0, 0) to (1, 1).
|
| 741 |
+
"""
|
| 742 |
+
if cls._unit_rectangle is None:
|
| 743 |
+
cls._unit_rectangle = cls([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]],
|
| 744 |
+
closed=True, readonly=True)
|
| 745 |
+
return cls._unit_rectangle
|
| 746 |
+
|
| 747 |
+
_unit_regular_polygons = WeakValueDictionary()
|
| 748 |
+
|
| 749 |
+
@classmethod
|
| 750 |
+
def unit_regular_polygon(cls, numVertices):
|
| 751 |
+
"""
|
| 752 |
+
Return a :class:`Path` instance for a unit regular polygon with the
|
| 753 |
+
given *numVertices* such that the circumscribing circle has radius 1.0,
|
| 754 |
+
centered at (0, 0).
|
| 755 |
+
"""
|
| 756 |
+
if numVertices <= 16:
|
| 757 |
+
path = cls._unit_regular_polygons.get(numVertices)
|
| 758 |
+
else:
|
| 759 |
+
path = None
|
| 760 |
+
if path is None:
|
| 761 |
+
theta = ((2 * np.pi / numVertices) * np.arange(numVertices + 1)
|
| 762 |
+
# This initial rotation is to make sure the polygon always
|
| 763 |
+
# "points-up".
|
| 764 |
+
+ np.pi / 2)
|
| 765 |
+
verts = np.column_stack((np.cos(theta), np.sin(theta)))
|
| 766 |
+
path = cls(verts, closed=True, readonly=True)
|
| 767 |
+
if numVertices <= 16:
|
| 768 |
+
cls._unit_regular_polygons[numVertices] = path
|
| 769 |
+
return path
|
| 770 |
+
|
| 771 |
+
_unit_regular_stars = WeakValueDictionary()
|
| 772 |
+
|
| 773 |
+
@classmethod
|
| 774 |
+
def unit_regular_star(cls, numVertices, innerCircle=0.5):
|
| 775 |
+
"""
|
| 776 |
+
Return a :class:`Path` for a unit regular star with the given
|
| 777 |
+
numVertices and radius of 1.0, centered at (0, 0).
|
| 778 |
+
"""
|
| 779 |
+
if numVertices <= 16:
|
| 780 |
+
path = cls._unit_regular_stars.get((numVertices, innerCircle))
|
| 781 |
+
else:
|
| 782 |
+
path = None
|
| 783 |
+
if path is None:
|
| 784 |
+
ns2 = numVertices * 2
|
| 785 |
+
theta = (2*np.pi/ns2 * np.arange(ns2 + 1))
|
| 786 |
+
# This initial rotation is to make sure the polygon always
|
| 787 |
+
# "points-up"
|
| 788 |
+
theta += np.pi / 2.0
|
| 789 |
+
r = np.ones(ns2 + 1)
|
| 790 |
+
r[1::2] = innerCircle
|
| 791 |
+
verts = (r * np.vstack((np.cos(theta), np.sin(theta)))).T
|
| 792 |
+
path = cls(verts, closed=True, readonly=True)
|
| 793 |
+
if numVertices <= 16:
|
| 794 |
+
cls._unit_regular_stars[(numVertices, innerCircle)] = path
|
| 795 |
+
return path
|
| 796 |
+
|
| 797 |
+
@classmethod
|
| 798 |
+
def unit_regular_asterisk(cls, numVertices):
|
| 799 |
+
"""
|
| 800 |
+
Return a :class:`Path` for a unit regular asterisk with the given
|
| 801 |
+
numVertices and radius of 1.0, centered at (0, 0).
|
| 802 |
+
"""
|
| 803 |
+
return cls.unit_regular_star(numVertices, 0.0)
|
| 804 |
+
|
| 805 |
+
_unit_circle = None
|
| 806 |
+
|
| 807 |
+
@classmethod
|
| 808 |
+
def unit_circle(cls):
|
| 809 |
+
"""
|
| 810 |
+
Return the readonly :class:`Path` of the unit circle.
|
| 811 |
+
|
| 812 |
+
For most cases, :func:`Path.circle` will be what you want.
|
| 813 |
+
"""
|
| 814 |
+
if cls._unit_circle is None:
|
| 815 |
+
cls._unit_circle = cls.circle(center=(0, 0), radius=1,
|
| 816 |
+
readonly=True)
|
| 817 |
+
return cls._unit_circle
|
| 818 |
+
|
| 819 |
+
@classmethod
|
| 820 |
+
def circle(cls, center=(0., 0.), radius=1., readonly=False):
|
| 821 |
+
"""
|
| 822 |
+
Return a `Path` representing a circle of a given radius and center.
|
| 823 |
+
|
| 824 |
+
Parameters
|
| 825 |
+
----------
|
| 826 |
+
center : (float, float), default: (0, 0)
|
| 827 |
+
The center of the circle.
|
| 828 |
+
radius : float, default: 1
|
| 829 |
+
The radius of the circle.
|
| 830 |
+
readonly : bool
|
| 831 |
+
Whether the created path should have the "readonly" argument
|
| 832 |
+
set when creating the Path instance.
|
| 833 |
+
|
| 834 |
+
Notes
|
| 835 |
+
-----
|
| 836 |
+
The circle is approximated using 8 cubic Bézier curves, as described in
|
| 837 |
+
|
| 838 |
+
Lancaster, Don. `Approximating a Circle or an Ellipse Using Four
|
| 839 |
+
Bezier Cubic Splines <https://www.tinaja.com/glib/ellipse4.pdf>`_.
|
| 840 |
+
"""
|
| 841 |
+
MAGIC = 0.2652031
|
| 842 |
+
SQRTHALF = np.sqrt(0.5)
|
| 843 |
+
MAGIC45 = SQRTHALF * MAGIC
|
| 844 |
+
|
| 845 |
+
vertices = np.array([[0.0, -1.0],
|
| 846 |
+
|
| 847 |
+
[MAGIC, -1.0],
|
| 848 |
+
[SQRTHALF-MAGIC45, -SQRTHALF-MAGIC45],
|
| 849 |
+
[SQRTHALF, -SQRTHALF],
|
| 850 |
+
|
| 851 |
+
[SQRTHALF+MAGIC45, -SQRTHALF+MAGIC45],
|
| 852 |
+
[1.0, -MAGIC],
|
| 853 |
+
[1.0, 0.0],
|
| 854 |
+
|
| 855 |
+
[1.0, MAGIC],
|
| 856 |
+
[SQRTHALF+MAGIC45, SQRTHALF-MAGIC45],
|
| 857 |
+
[SQRTHALF, SQRTHALF],
|
| 858 |
+
|
| 859 |
+
[SQRTHALF-MAGIC45, SQRTHALF+MAGIC45],
|
| 860 |
+
[MAGIC, 1.0],
|
| 861 |
+
[0.0, 1.0],
|
| 862 |
+
|
| 863 |
+
[-MAGIC, 1.0],
|
| 864 |
+
[-SQRTHALF+MAGIC45, SQRTHALF+MAGIC45],
|
| 865 |
+
[-SQRTHALF, SQRTHALF],
|
| 866 |
+
|
| 867 |
+
[-SQRTHALF-MAGIC45, SQRTHALF-MAGIC45],
|
| 868 |
+
[-1.0, MAGIC],
|
| 869 |
+
[-1.0, 0.0],
|
| 870 |
+
|
| 871 |
+
[-1.0, -MAGIC],
|
| 872 |
+
[-SQRTHALF-MAGIC45, -SQRTHALF+MAGIC45],
|
| 873 |
+
[-SQRTHALF, -SQRTHALF],
|
| 874 |
+
|
| 875 |
+
[-SQRTHALF+MAGIC45, -SQRTHALF-MAGIC45],
|
| 876 |
+
[-MAGIC, -1.0],
|
| 877 |
+
[0.0, -1.0],
|
| 878 |
+
|
| 879 |
+
[0.0, -1.0]],
|
| 880 |
+
dtype=float)
|
| 881 |
+
|
| 882 |
+
codes = [cls.CURVE4] * 26
|
| 883 |
+
codes[0] = cls.MOVETO
|
| 884 |
+
codes[-1] = cls.CLOSEPOLY
|
| 885 |
+
return Path(vertices * radius + center, codes, readonly=readonly)
|
| 886 |
+
|
| 887 |
+
_unit_circle_righthalf = None
|
| 888 |
+
|
| 889 |
+
@classmethod
|
| 890 |
+
def unit_circle_righthalf(cls):
|
| 891 |
+
"""
|
| 892 |
+
Return a `Path` of the right half of a unit circle.
|
| 893 |
+
|
| 894 |
+
See `Path.circle` for the reference on the approximation used.
|
| 895 |
+
"""
|
| 896 |
+
if cls._unit_circle_righthalf is None:
|
| 897 |
+
MAGIC = 0.2652031
|
| 898 |
+
SQRTHALF = np.sqrt(0.5)
|
| 899 |
+
MAGIC45 = SQRTHALF * MAGIC
|
| 900 |
+
|
| 901 |
+
vertices = np.array(
|
| 902 |
+
[[0.0, -1.0],
|
| 903 |
+
|
| 904 |
+
[MAGIC, -1.0],
|
| 905 |
+
[SQRTHALF-MAGIC45, -SQRTHALF-MAGIC45],
|
| 906 |
+
[SQRTHALF, -SQRTHALF],
|
| 907 |
+
|
| 908 |
+
[SQRTHALF+MAGIC45, -SQRTHALF+MAGIC45],
|
| 909 |
+
[1.0, -MAGIC],
|
| 910 |
+
[1.0, 0.0],
|
| 911 |
+
|
| 912 |
+
[1.0, MAGIC],
|
| 913 |
+
[SQRTHALF+MAGIC45, SQRTHALF-MAGIC45],
|
| 914 |
+
[SQRTHALF, SQRTHALF],
|
| 915 |
+
|
| 916 |
+
[SQRTHALF-MAGIC45, SQRTHALF+MAGIC45],
|
| 917 |
+
[MAGIC, 1.0],
|
| 918 |
+
[0.0, 1.0],
|
| 919 |
+
|
| 920 |
+
[0.0, -1.0]],
|
| 921 |
+
|
| 922 |
+
float)
|
| 923 |
+
|
| 924 |
+
codes = np.full(14, cls.CURVE4, dtype=cls.code_type)
|
| 925 |
+
codes[0] = cls.MOVETO
|
| 926 |
+
codes[-1] = cls.CLOSEPOLY
|
| 927 |
+
|
| 928 |
+
cls._unit_circle_righthalf = cls(vertices, codes, readonly=True)
|
| 929 |
+
return cls._unit_circle_righthalf
|
| 930 |
+
|
| 931 |
+
@classmethod
|
| 932 |
+
def arc(cls, theta1, theta2, n=None, is_wedge=False):
|
| 933 |
+
"""
|
| 934 |
+
Return a `Path` for the unit circle arc from angles *theta1* to
|
| 935 |
+
*theta2* (in degrees).
|
| 936 |
+
|
| 937 |
+
*theta2* is unwrapped to produce the shortest arc within 360 degrees.
|
| 938 |
+
That is, if *theta2* > *theta1* + 360, the arc will be from *theta1* to
|
| 939 |
+
*theta2* - 360 and not a full circle plus some extra overlap.
|
| 940 |
+
|
| 941 |
+
If *n* is provided, it is the number of spline segments to make.
|
| 942 |
+
If *n* is not provided, the number of spline segments is
|
| 943 |
+
determined based on the delta between *theta1* and *theta2*.
|
| 944 |
+
|
| 945 |
+
Masionobe, L. 2003. `Drawing an elliptical arc using
|
| 946 |
+
polylines, quadratic or cubic Bezier curves
|
| 947 |
+
<https://web.archive.org/web/20190318044212/http://www.spaceroots.org/documents/ellipse/index.html>`_.
|
| 948 |
+
"""
|
| 949 |
+
halfpi = np.pi * 0.5
|
| 950 |
+
|
| 951 |
+
eta1 = theta1
|
| 952 |
+
eta2 = theta2 - 360 * np.floor((theta2 - theta1) / 360)
|
| 953 |
+
# Ensure 2pi range is not flattened to 0 due to floating-point errors,
|
| 954 |
+
# but don't try to expand existing 0 range.
|
| 955 |
+
if theta2 != theta1 and eta2 <= eta1:
|
| 956 |
+
eta2 += 360
|
| 957 |
+
eta1, eta2 = np.deg2rad([eta1, eta2])
|
| 958 |
+
|
| 959 |
+
# number of curve segments to make
|
| 960 |
+
if n is None:
|
| 961 |
+
n = int(2 ** np.ceil((eta2 - eta1) / halfpi))
|
| 962 |
+
if n < 1:
|
| 963 |
+
raise ValueError("n must be >= 1 or None")
|
| 964 |
+
|
| 965 |
+
deta = (eta2 - eta1) / n
|
| 966 |
+
t = np.tan(0.5 * deta)
|
| 967 |
+
alpha = np.sin(deta) * (np.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0
|
| 968 |
+
|
| 969 |
+
steps = np.linspace(eta1, eta2, n + 1, True)
|
| 970 |
+
cos_eta = np.cos(steps)
|
| 971 |
+
sin_eta = np.sin(steps)
|
| 972 |
+
|
| 973 |
+
xA = cos_eta[:-1]
|
| 974 |
+
yA = sin_eta[:-1]
|
| 975 |
+
xA_dot = -yA
|
| 976 |
+
yA_dot = xA
|
| 977 |
+
|
| 978 |
+
xB = cos_eta[1:]
|
| 979 |
+
yB = sin_eta[1:]
|
| 980 |
+
xB_dot = -yB
|
| 981 |
+
yB_dot = xB
|
| 982 |
+
|
| 983 |
+
if is_wedge:
|
| 984 |
+
length = n * 3 + 4
|
| 985 |
+
vertices = np.zeros((length, 2), float)
|
| 986 |
+
codes = np.full(length, cls.CURVE4, dtype=cls.code_type)
|
| 987 |
+
vertices[1] = [xA[0], yA[0]]
|
| 988 |
+
codes[0:2] = [cls.MOVETO, cls.LINETO]
|
| 989 |
+
codes[-2:] = [cls.LINETO, cls.CLOSEPOLY]
|
| 990 |
+
vertex_offset = 2
|
| 991 |
+
end = length - 2
|
| 992 |
+
else:
|
| 993 |
+
length = n * 3 + 1
|
| 994 |
+
vertices = np.empty((length, 2), float)
|
| 995 |
+
codes = np.full(length, cls.CURVE4, dtype=cls.code_type)
|
| 996 |
+
vertices[0] = [xA[0], yA[0]]
|
| 997 |
+
codes[0] = cls.MOVETO
|
| 998 |
+
vertex_offset = 1
|
| 999 |
+
end = length
|
| 1000 |
+
|
| 1001 |
+
vertices[vertex_offset:end:3, 0] = xA + alpha * xA_dot
|
| 1002 |
+
vertices[vertex_offset:end:3, 1] = yA + alpha * yA_dot
|
| 1003 |
+
vertices[vertex_offset+1:end:3, 0] = xB - alpha * xB_dot
|
| 1004 |
+
vertices[vertex_offset+1:end:3, 1] = yB - alpha * yB_dot
|
| 1005 |
+
vertices[vertex_offset+2:end:3, 0] = xB
|
| 1006 |
+
vertices[vertex_offset+2:end:3, 1] = yB
|
| 1007 |
+
|
| 1008 |
+
return cls(vertices, codes, readonly=True)
|
| 1009 |
+
|
| 1010 |
+
@classmethod
|
| 1011 |
+
def wedge(cls, theta1, theta2, n=None):
|
| 1012 |
+
"""
|
| 1013 |
+
Return a `Path` for the unit circle wedge from angles *theta1* to
|
| 1014 |
+
*theta2* (in degrees).
|
| 1015 |
+
|
| 1016 |
+
*theta2* is unwrapped to produce the shortest wedge within 360 degrees.
|
| 1017 |
+
That is, if *theta2* > *theta1* + 360, the wedge will be from *theta1*
|
| 1018 |
+
to *theta2* - 360 and not a full circle plus some extra overlap.
|
| 1019 |
+
|
| 1020 |
+
If *n* is provided, it is the number of spline segments to make.
|
| 1021 |
+
If *n* is not provided, the number of spline segments is
|
| 1022 |
+
determined based on the delta between *theta1* and *theta2*.
|
| 1023 |
+
|
| 1024 |
+
See `Path.arc` for the reference on the approximation used.
|
| 1025 |
+
"""
|
| 1026 |
+
return cls.arc(theta1, theta2, n, True)
|
| 1027 |
+
|
| 1028 |
+
@staticmethod
|
| 1029 |
+
@lru_cache(8)
|
| 1030 |
+
def hatch(hatchpattern, density=6):
|
| 1031 |
+
"""
|
| 1032 |
+
Given a hatch specifier, *hatchpattern*, generates a `Path` that
|
| 1033 |
+
can be used in a repeated hatching pattern. *density* is the
|
| 1034 |
+
number of lines per unit square.
|
| 1035 |
+
"""
|
| 1036 |
+
from matplotlib.hatch import get_path
|
| 1037 |
+
return (get_path(hatchpattern, density)
|
| 1038 |
+
if hatchpattern is not None else None)
|
| 1039 |
+
|
| 1040 |
+
def clip_to_bbox(self, bbox, inside=True):
|
| 1041 |
+
"""
|
| 1042 |
+
Clip the path to the given bounding box.
|
| 1043 |
+
|
| 1044 |
+
The path must be made up of one or more closed polygons. This
|
| 1045 |
+
algorithm will not behave correctly for unclosed paths.
|
| 1046 |
+
|
| 1047 |
+
If *inside* is `True`, clip to the inside of the box, otherwise
|
| 1048 |
+
to the outside of the box.
|
| 1049 |
+
"""
|
| 1050 |
+
verts = _path.clip_path_to_rect(self, bbox, inside)
|
| 1051 |
+
paths = [Path(poly) for poly in verts]
|
| 1052 |
+
return self.make_compound_path(*paths)
|
| 1053 |
+
|
| 1054 |
+
|
| 1055 |
+
def get_path_collection_extents(
|
| 1056 |
+
master_transform, paths, transforms, offsets, offset_transform):
|
| 1057 |
+
r"""
|
| 1058 |
+
Get bounding box of a `.PathCollection`\s internal objects.
|
| 1059 |
+
|
| 1060 |
+
That is, given a sequence of `Path`\s, `.Transform`\s objects, and offsets, as found
|
| 1061 |
+
in a `.PathCollection`, return the bounding box that encapsulates all of them.
|
| 1062 |
+
|
| 1063 |
+
Parameters
|
| 1064 |
+
----------
|
| 1065 |
+
master_transform : `~matplotlib.transforms.Transform`
|
| 1066 |
+
Global transformation applied to all paths.
|
| 1067 |
+
paths : list of `Path`
|
| 1068 |
+
transforms : list of `~matplotlib.transforms.Affine2DBase`
|
| 1069 |
+
If non-empty, this overrides *master_transform*.
|
| 1070 |
+
offsets : (N, 2) array-like
|
| 1071 |
+
offset_transform : `~matplotlib.transforms.Affine2DBase`
|
| 1072 |
+
Transform applied to the offsets before offsetting the path.
|
| 1073 |
+
|
| 1074 |
+
Notes
|
| 1075 |
+
-----
|
| 1076 |
+
The way that *paths*, *transforms* and *offsets* are combined follows the same
|
| 1077 |
+
method as for collections: each is iterated over independently, so if you have 3
|
| 1078 |
+
paths (A, B, C), 2 transforms (α, β) and 1 offset (O), their combinations are as
|
| 1079 |
+
follows:
|
| 1080 |
+
|
| 1081 |
+
- (A, α, O)
|
| 1082 |
+
- (B, β, O)
|
| 1083 |
+
- (C, α, O)
|
| 1084 |
+
"""
|
| 1085 |
+
from .transforms import Bbox
|
| 1086 |
+
if len(paths) == 0:
|
| 1087 |
+
raise ValueError("No paths provided")
|
| 1088 |
+
if len(offsets) == 0:
|
| 1089 |
+
raise ValueError("No offsets provided")
|
| 1090 |
+
extents, minpos = _path.get_path_collection_extents(
|
| 1091 |
+
master_transform, paths, np.atleast_3d(transforms),
|
| 1092 |
+
offsets, offset_transform)
|
| 1093 |
+
return Bbox.from_extents(*extents, minpos=minpos)
|
llava_video/lib/python3.10/site-packages/matplotlib/path.pyi
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .bezier import BezierSegment
|
| 2 |
+
from .transforms import Affine2D, Transform, Bbox
|
| 3 |
+
from collections.abc import Generator, Iterable, Sequence
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
from numpy.typing import ArrayLike
|
| 7 |
+
|
| 8 |
+
from typing import Any, overload
|
| 9 |
+
|
| 10 |
+
class Path:
|
| 11 |
+
code_type: type[np.uint8]
|
| 12 |
+
STOP: np.uint8
|
| 13 |
+
MOVETO: np.uint8
|
| 14 |
+
LINETO: np.uint8
|
| 15 |
+
CURVE3: np.uint8
|
| 16 |
+
CURVE4: np.uint8
|
| 17 |
+
CLOSEPOLY: np.uint8
|
| 18 |
+
NUM_VERTICES_FOR_CODE: dict[np.uint8, int]
|
| 19 |
+
|
| 20 |
+
def __init__(
|
| 21 |
+
self,
|
| 22 |
+
vertices: ArrayLike,
|
| 23 |
+
codes: ArrayLike | None = ...,
|
| 24 |
+
_interpolation_steps: int = ...,
|
| 25 |
+
closed: bool = ...,
|
| 26 |
+
readonly: bool = ...,
|
| 27 |
+
) -> None: ...
|
| 28 |
+
@property
|
| 29 |
+
def vertices(self) -> ArrayLike: ...
|
| 30 |
+
@vertices.setter
|
| 31 |
+
def vertices(self, vertices: ArrayLike) -> None: ...
|
| 32 |
+
@property
|
| 33 |
+
def codes(self) -> ArrayLike | None: ...
|
| 34 |
+
@codes.setter
|
| 35 |
+
def codes(self, codes: ArrayLike) -> None: ...
|
| 36 |
+
@property
|
| 37 |
+
def simplify_threshold(self) -> float: ...
|
| 38 |
+
@simplify_threshold.setter
|
| 39 |
+
def simplify_threshold(self, threshold: float) -> None: ...
|
| 40 |
+
@property
|
| 41 |
+
def should_simplify(self) -> bool: ...
|
| 42 |
+
@should_simplify.setter
|
| 43 |
+
def should_simplify(self, should_simplify: bool) -> None: ...
|
| 44 |
+
@property
|
| 45 |
+
def readonly(self) -> bool: ...
|
| 46 |
+
def copy(self) -> Path: ...
|
| 47 |
+
def __deepcopy__(self, memo: dict[int, Any] | None = ...) -> Path: ...
|
| 48 |
+
deepcopy = __deepcopy__
|
| 49 |
+
|
| 50 |
+
@classmethod
|
| 51 |
+
def make_compound_path_from_polys(cls, XY: ArrayLike) -> Path: ...
|
| 52 |
+
@classmethod
|
| 53 |
+
def make_compound_path(cls, *args: Path) -> Path: ...
|
| 54 |
+
def __len__(self) -> int: ...
|
| 55 |
+
def iter_segments(
|
| 56 |
+
self,
|
| 57 |
+
transform: Transform | None = ...,
|
| 58 |
+
remove_nans: bool = ...,
|
| 59 |
+
clip: tuple[float, float, float, float] | None = ...,
|
| 60 |
+
snap: bool | None = ...,
|
| 61 |
+
stroke_width: float = ...,
|
| 62 |
+
simplify: bool | None = ...,
|
| 63 |
+
curves: bool = ...,
|
| 64 |
+
sketch: tuple[float, float, float] | None = ...,
|
| 65 |
+
) -> Generator[tuple[np.ndarray, np.uint8], None, None]: ...
|
| 66 |
+
def iter_bezier(self, **kwargs) -> Generator[BezierSegment, None, None]: ...
|
| 67 |
+
def cleaned(
|
| 68 |
+
self,
|
| 69 |
+
transform: Transform | None = ...,
|
| 70 |
+
remove_nans: bool = ...,
|
| 71 |
+
clip: tuple[float, float, float, float] | None = ...,
|
| 72 |
+
*,
|
| 73 |
+
simplify: bool | None = ...,
|
| 74 |
+
curves: bool = ...,
|
| 75 |
+
stroke_width: float = ...,
|
| 76 |
+
snap: bool | None = ...,
|
| 77 |
+
sketch: tuple[float, float, float] | None = ...
|
| 78 |
+
) -> Path: ...
|
| 79 |
+
def transformed(self, transform: Transform) -> Path: ...
|
| 80 |
+
def contains_point(
|
| 81 |
+
self,
|
| 82 |
+
point: tuple[float, float],
|
| 83 |
+
transform: Transform | None = ...,
|
| 84 |
+
radius: float = ...,
|
| 85 |
+
) -> bool: ...
|
| 86 |
+
def contains_points(
|
| 87 |
+
self, points: ArrayLike, transform: Transform | None = ..., radius: float = ...
|
| 88 |
+
) -> np.ndarray: ...
|
| 89 |
+
def contains_path(self, path: Path, transform: Transform | None = ...) -> bool: ...
|
| 90 |
+
def get_extents(self, transform: Transform | None = ..., **kwargs) -> Bbox: ...
|
| 91 |
+
def intersects_path(self, other: Path, filled: bool = ...) -> bool: ...
|
| 92 |
+
def intersects_bbox(self, bbox: Bbox, filled: bool = ...) -> bool: ...
|
| 93 |
+
def interpolated(self, steps: int) -> Path: ...
|
| 94 |
+
def to_polygons(
|
| 95 |
+
self,
|
| 96 |
+
transform: Transform | None = ...,
|
| 97 |
+
width: float = ...,
|
| 98 |
+
height: float = ...,
|
| 99 |
+
closed_only: bool = ...,
|
| 100 |
+
) -> list[ArrayLike]: ...
|
| 101 |
+
@classmethod
|
| 102 |
+
def unit_rectangle(cls) -> Path: ...
|
| 103 |
+
@classmethod
|
| 104 |
+
def unit_regular_polygon(cls, numVertices: int) -> Path: ...
|
| 105 |
+
@classmethod
|
| 106 |
+
def unit_regular_star(cls, numVertices: int, innerCircle: float = ...) -> Path: ...
|
| 107 |
+
@classmethod
|
| 108 |
+
def unit_regular_asterisk(cls, numVertices: int) -> Path: ...
|
| 109 |
+
@classmethod
|
| 110 |
+
def unit_circle(cls) -> Path: ...
|
| 111 |
+
@classmethod
|
| 112 |
+
def circle(
|
| 113 |
+
cls,
|
| 114 |
+
center: tuple[float, float] = ...,
|
| 115 |
+
radius: float = ...,
|
| 116 |
+
readonly: bool = ...,
|
| 117 |
+
) -> Path: ...
|
| 118 |
+
@classmethod
|
| 119 |
+
def unit_circle_righthalf(cls) -> Path: ...
|
| 120 |
+
@classmethod
|
| 121 |
+
def arc(
|
| 122 |
+
cls, theta1: float, theta2: float, n: int | None = ..., is_wedge: bool = ...
|
| 123 |
+
) -> Path: ...
|
| 124 |
+
@classmethod
|
| 125 |
+
def wedge(cls, theta1: float, theta2: float, n: int | None = ...) -> Path: ...
|
| 126 |
+
@overload
|
| 127 |
+
@staticmethod
|
| 128 |
+
def hatch(hatchpattern: str, density: float = ...) -> Path: ...
|
| 129 |
+
@overload
|
| 130 |
+
@staticmethod
|
| 131 |
+
def hatch(hatchpattern: None, density: float = ...) -> None: ...
|
| 132 |
+
def clip_to_bbox(self, bbox: Bbox, inside: bool = ...) -> Path: ...
|
| 133 |
+
|
| 134 |
+
def get_path_collection_extents(
|
| 135 |
+
master_transform: Transform,
|
| 136 |
+
paths: Sequence[Path],
|
| 137 |
+
transforms: Iterable[Affine2D],
|
| 138 |
+
offsets: ArrayLike,
|
| 139 |
+
offset_transform: Affine2D,
|
| 140 |
+
) -> Bbox: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/py.typed
ADDED
|
File without changes
|
llava_video/lib/python3.10/site-packages/matplotlib/pyplot.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llava_video/lib/python3.10/site-packages/matplotlib/quiver.pyi
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import matplotlib.artist as martist
|
| 2 |
+
import matplotlib.collections as mcollections
|
| 3 |
+
from matplotlib.axes import Axes
|
| 4 |
+
from matplotlib.figure import Figure, SubFigure
|
| 5 |
+
from matplotlib.text import Text
|
| 6 |
+
from matplotlib.transforms import Transform, Bbox
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
import numpy as np
|
| 10 |
+
from numpy.typing import ArrayLike
|
| 11 |
+
from collections.abc import Sequence
|
| 12 |
+
from typing import Any, Literal, overload
|
| 13 |
+
from matplotlib.typing import ColorType
|
| 14 |
+
|
| 15 |
+
class QuiverKey(martist.Artist):
|
| 16 |
+
halign: dict[Literal["N", "S", "E", "W"], Literal["left", "center", "right"]]
|
| 17 |
+
valign: dict[Literal["N", "S", "E", "W"], Literal["top", "center", "bottom"]]
|
| 18 |
+
pivot: dict[Literal["N", "S", "E", "W"], Literal["middle", "tip", "tail"]]
|
| 19 |
+
Q: Quiver
|
| 20 |
+
X: float
|
| 21 |
+
Y: float
|
| 22 |
+
U: float
|
| 23 |
+
angle: float
|
| 24 |
+
coord: Literal["axes", "figure", "data", "inches"]
|
| 25 |
+
color: ColorType | None
|
| 26 |
+
label: str
|
| 27 |
+
labelpos: Literal["N", "S", "E", "W"]
|
| 28 |
+
labelcolor: ColorType | None
|
| 29 |
+
fontproperties: dict[str, Any]
|
| 30 |
+
kw: dict[str, Any]
|
| 31 |
+
text: Text
|
| 32 |
+
zorder: float
|
| 33 |
+
def __init__(
|
| 34 |
+
self,
|
| 35 |
+
Q: Quiver,
|
| 36 |
+
X: float,
|
| 37 |
+
Y: float,
|
| 38 |
+
U: float,
|
| 39 |
+
label: str,
|
| 40 |
+
*,
|
| 41 |
+
angle: float = ...,
|
| 42 |
+
coordinates: Literal["axes", "figure", "data", "inches"] = ...,
|
| 43 |
+
color: ColorType | None = ...,
|
| 44 |
+
labelsep: float = ...,
|
| 45 |
+
labelpos: Literal["N", "S", "E", "W"] = ...,
|
| 46 |
+
labelcolor: ColorType | None = ...,
|
| 47 |
+
fontproperties: dict[str, Any] | None = ...,
|
| 48 |
+
zorder: float | None = ...,
|
| 49 |
+
**kwargs
|
| 50 |
+
) -> None: ...
|
| 51 |
+
@property
|
| 52 |
+
def labelsep(self) -> float: ...
|
| 53 |
+
def set_figure(self, fig: Figure | SubFigure) -> None: ...
|
| 54 |
+
|
| 55 |
+
class Quiver(mcollections.PolyCollection):
|
| 56 |
+
X: ArrayLike
|
| 57 |
+
Y: ArrayLike
|
| 58 |
+
XY: ArrayLike
|
| 59 |
+
U: ArrayLike
|
| 60 |
+
V: ArrayLike
|
| 61 |
+
Umask: ArrayLike
|
| 62 |
+
N: int
|
| 63 |
+
scale: float | None
|
| 64 |
+
headwidth: float
|
| 65 |
+
headlength: float
|
| 66 |
+
headaxislength: float
|
| 67 |
+
minshaft: float
|
| 68 |
+
minlength: float
|
| 69 |
+
units: Literal["width", "height", "dots", "inches", "x", "y", "xy"]
|
| 70 |
+
scale_units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] | None
|
| 71 |
+
angles: Literal["uv", "xy"] | ArrayLike
|
| 72 |
+
width: float | None
|
| 73 |
+
pivot: Literal["tail", "middle", "tip"]
|
| 74 |
+
transform: Transform
|
| 75 |
+
polykw: dict[str, Any]
|
| 76 |
+
|
| 77 |
+
@overload
|
| 78 |
+
def __init__(
|
| 79 |
+
self,
|
| 80 |
+
ax: Axes,
|
| 81 |
+
U: ArrayLike,
|
| 82 |
+
V: ArrayLike,
|
| 83 |
+
C: ArrayLike = ...,
|
| 84 |
+
*,
|
| 85 |
+
scale: float | None = ...,
|
| 86 |
+
headwidth: float = ...,
|
| 87 |
+
headlength: float = ...,
|
| 88 |
+
headaxislength: float = ...,
|
| 89 |
+
minshaft: float = ...,
|
| 90 |
+
minlength: float = ...,
|
| 91 |
+
units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] = ...,
|
| 92 |
+
scale_units: Literal["width", "height", "dots", "inches", "x", "y", "xy"]
|
| 93 |
+
| None = ...,
|
| 94 |
+
angles: Literal["uv", "xy"] | ArrayLike = ...,
|
| 95 |
+
width: float | None = ...,
|
| 96 |
+
color: ColorType | Sequence[ColorType] = ...,
|
| 97 |
+
pivot: Literal["tail", "mid", "middle", "tip"] = ...,
|
| 98 |
+
**kwargs
|
| 99 |
+
) -> None: ...
|
| 100 |
+
@overload
|
| 101 |
+
def __init__(
|
| 102 |
+
self,
|
| 103 |
+
ax: Axes,
|
| 104 |
+
X: ArrayLike,
|
| 105 |
+
Y: ArrayLike,
|
| 106 |
+
U: ArrayLike,
|
| 107 |
+
V: ArrayLike,
|
| 108 |
+
C: ArrayLike = ...,
|
| 109 |
+
*,
|
| 110 |
+
scale: float | None = ...,
|
| 111 |
+
headwidth: float = ...,
|
| 112 |
+
headlength: float = ...,
|
| 113 |
+
headaxislength: float = ...,
|
| 114 |
+
minshaft: float = ...,
|
| 115 |
+
minlength: float = ...,
|
| 116 |
+
units: Literal["width", "height", "dots", "inches", "x", "y", "xy"] = ...,
|
| 117 |
+
scale_units: Literal["width", "height", "dots", "inches", "x", "y", "xy"]
|
| 118 |
+
| None = ...,
|
| 119 |
+
angles: Literal["uv", "xy"] | ArrayLike = ...,
|
| 120 |
+
width: float | None = ...,
|
| 121 |
+
color: ColorType | Sequence[ColorType] = ...,
|
| 122 |
+
pivot: Literal["tail", "mid", "middle", "tip"] = ...,
|
| 123 |
+
**kwargs
|
| 124 |
+
) -> None: ...
|
| 125 |
+
def get_datalim(self, transData: Transform) -> Bbox: ...
|
| 126 |
+
def set_UVC(
|
| 127 |
+
self, U: ArrayLike, V: ArrayLike, C: ArrayLike | None = ...
|
| 128 |
+
) -> None: ...
|
| 129 |
+
|
| 130 |
+
class Barbs(mcollections.PolyCollection):
|
| 131 |
+
sizes: dict[str, float]
|
| 132 |
+
fill_empty: bool
|
| 133 |
+
barb_increments: dict[str, float]
|
| 134 |
+
rounding: bool
|
| 135 |
+
flip: np.ndarray
|
| 136 |
+
x: ArrayLike
|
| 137 |
+
y: ArrayLike
|
| 138 |
+
u: ArrayLike
|
| 139 |
+
v: ArrayLike
|
| 140 |
+
|
| 141 |
+
@overload
|
| 142 |
+
def __init__(
|
| 143 |
+
self,
|
| 144 |
+
ax: Axes,
|
| 145 |
+
U: ArrayLike,
|
| 146 |
+
V: ArrayLike,
|
| 147 |
+
C: ArrayLike = ...,
|
| 148 |
+
*,
|
| 149 |
+
pivot: str = ...,
|
| 150 |
+
length: int = ...,
|
| 151 |
+
barbcolor: ColorType | Sequence[ColorType] | None = ...,
|
| 152 |
+
flagcolor: ColorType | Sequence[ColorType] | None = ...,
|
| 153 |
+
sizes: dict[str, float] | None = ...,
|
| 154 |
+
fill_empty: bool = ...,
|
| 155 |
+
barb_increments: dict[str, float] | None = ...,
|
| 156 |
+
rounding: bool = ...,
|
| 157 |
+
flip_barb: bool | ArrayLike = ...,
|
| 158 |
+
**kwargs
|
| 159 |
+
) -> None: ...
|
| 160 |
+
@overload
|
| 161 |
+
def __init__(
|
| 162 |
+
self,
|
| 163 |
+
ax: Axes,
|
| 164 |
+
X: ArrayLike,
|
| 165 |
+
Y: ArrayLike,
|
| 166 |
+
U: ArrayLike,
|
| 167 |
+
V: ArrayLike,
|
| 168 |
+
C: ArrayLike = ...,
|
| 169 |
+
*,
|
| 170 |
+
pivot: str = ...,
|
| 171 |
+
length: int = ...,
|
| 172 |
+
barbcolor: ColorType | Sequence[ColorType] | None = ...,
|
| 173 |
+
flagcolor: ColorType | Sequence[ColorType] | None = ...,
|
| 174 |
+
sizes: dict[str, float] | None = ...,
|
| 175 |
+
fill_empty: bool = ...,
|
| 176 |
+
barb_increments: dict[str, float] | None = ...,
|
| 177 |
+
rounding: bool = ...,
|
| 178 |
+
flip_barb: bool | ArrayLike = ...,
|
| 179 |
+
**kwargs
|
| 180 |
+
) -> None: ...
|
| 181 |
+
def set_UVC(
|
| 182 |
+
self, U: ArrayLike, V: ArrayLike, C: ArrayLike | None = ...
|
| 183 |
+
) -> None: ...
|
| 184 |
+
def set_offsets(self, xy: ArrayLike) -> None: ...
|
llava_video/lib/python3.10/site-packages/matplotlib/rcsetup.py
ADDED
|
@@ -0,0 +1,1371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
The rcsetup module contains the validation code for customization using
|
| 3 |
+
Matplotlib's rc settings.
|
| 4 |
+
|
| 5 |
+
Each rc setting is assigned a function used to validate any attempted changes
|
| 6 |
+
to that setting. The validation functions are defined in the rcsetup module,
|
| 7 |
+
and are used to construct the rcParams global object which stores the settings
|
| 8 |
+
and is referenced throughout Matplotlib.
|
| 9 |
+
|
| 10 |
+
The default values of the rc settings are set in the default matplotlibrc file.
|
| 11 |
+
Any additions or deletions to the parameter set listed here should also be
|
| 12 |
+
propagated to the :file:`lib/matplotlib/mpl-data/matplotlibrc` in Matplotlib's
|
| 13 |
+
root source directory.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
import ast
|
| 17 |
+
from functools import lru_cache, reduce
|
| 18 |
+
from numbers import Real
|
| 19 |
+
import operator
|
| 20 |
+
import os
|
| 21 |
+
import re
|
| 22 |
+
|
| 23 |
+
import numpy as np
|
| 24 |
+
|
| 25 |
+
from matplotlib import _api, cbook
|
| 26 |
+
from matplotlib.backends import BackendFilter, backend_registry
|
| 27 |
+
from matplotlib.cbook import ls_mapper
|
| 28 |
+
from matplotlib.colors import Colormap, is_color_like
|
| 29 |
+
from matplotlib._fontconfig_pattern import parse_fontconfig_pattern
|
| 30 |
+
from matplotlib._enums import JoinStyle, CapStyle
|
| 31 |
+
|
| 32 |
+
# Don't let the original cycler collide with our validating cycler
|
| 33 |
+
from cycler import Cycler, cycler as ccycler
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
@_api.caching_module_getattr
|
| 37 |
+
class __getattr__:
|
| 38 |
+
@_api.deprecated(
|
| 39 |
+
"3.9",
|
| 40 |
+
alternative="``matplotlib.backends.backend_registry.list_builtin"
|
| 41 |
+
"(matplotlib.backends.BackendFilter.INTERACTIVE)``")
|
| 42 |
+
@property
|
| 43 |
+
def interactive_bk(self):
|
| 44 |
+
return backend_registry.list_builtin(BackendFilter.INTERACTIVE)
|
| 45 |
+
|
| 46 |
+
@_api.deprecated(
|
| 47 |
+
"3.9",
|
| 48 |
+
alternative="``matplotlib.backends.backend_registry.list_builtin"
|
| 49 |
+
"(matplotlib.backends.BackendFilter.NON_INTERACTIVE)``")
|
| 50 |
+
@property
|
| 51 |
+
def non_interactive_bk(self):
|
| 52 |
+
return backend_registry.list_builtin(BackendFilter.NON_INTERACTIVE)
|
| 53 |
+
|
| 54 |
+
@_api.deprecated(
|
| 55 |
+
"3.9",
|
| 56 |
+
alternative="``matplotlib.backends.backend_registry.list_builtin()``")
|
| 57 |
+
@property
|
| 58 |
+
def all_backends(self):
|
| 59 |
+
return backend_registry.list_builtin()
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
class ValidateInStrings:
|
| 63 |
+
def __init__(self, key, valid, ignorecase=False, *,
|
| 64 |
+
_deprecated_since=None):
|
| 65 |
+
"""*valid* is a list of legal strings."""
|
| 66 |
+
self.key = key
|
| 67 |
+
self.ignorecase = ignorecase
|
| 68 |
+
self._deprecated_since = _deprecated_since
|
| 69 |
+
|
| 70 |
+
def func(s):
|
| 71 |
+
if ignorecase:
|
| 72 |
+
return s.lower()
|
| 73 |
+
else:
|
| 74 |
+
return s
|
| 75 |
+
self.valid = {func(k): k for k in valid}
|
| 76 |
+
|
| 77 |
+
def __call__(self, s):
|
| 78 |
+
if self._deprecated_since:
|
| 79 |
+
name, = (k for k, v in globals().items() if v is self)
|
| 80 |
+
_api.warn_deprecated(
|
| 81 |
+
self._deprecated_since, name=name, obj_type="function")
|
| 82 |
+
if self.ignorecase and isinstance(s, str):
|
| 83 |
+
s = s.lower()
|
| 84 |
+
if s in self.valid:
|
| 85 |
+
return self.valid[s]
|
| 86 |
+
msg = (f"{s!r} is not a valid value for {self.key}; supported values "
|
| 87 |
+
f"are {[*self.valid.values()]}")
|
| 88 |
+
if (isinstance(s, str)
|
| 89 |
+
and (s.startswith('"') and s.endswith('"')
|
| 90 |
+
or s.startswith("'") and s.endswith("'"))
|
| 91 |
+
and s[1:-1] in self.valid):
|
| 92 |
+
msg += "; remove quotes surrounding your string"
|
| 93 |
+
raise ValueError(msg)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
@lru_cache
|
| 97 |
+
def _listify_validator(scalar_validator, allow_stringlist=False, *,
|
| 98 |
+
n=None, doc=None):
|
| 99 |
+
def f(s):
|
| 100 |
+
if isinstance(s, str):
|
| 101 |
+
try:
|
| 102 |
+
val = [scalar_validator(v.strip()) for v in s.split(',')
|
| 103 |
+
if v.strip()]
|
| 104 |
+
except Exception:
|
| 105 |
+
if allow_stringlist:
|
| 106 |
+
# Sometimes, a list of colors might be a single string
|
| 107 |
+
# of single-letter colornames. So give that a shot.
|
| 108 |
+
val = [scalar_validator(v.strip()) for v in s if v.strip()]
|
| 109 |
+
else:
|
| 110 |
+
raise
|
| 111 |
+
# Allow any ordered sequence type -- generators, np.ndarray, pd.Series
|
| 112 |
+
# -- but not sets, whose iteration order is non-deterministic.
|
| 113 |
+
elif np.iterable(s) and not isinstance(s, (set, frozenset)):
|
| 114 |
+
# The condition on this list comprehension will preserve the
|
| 115 |
+
# behavior of filtering out any empty strings (behavior was
|
| 116 |
+
# from the original validate_stringlist()), while allowing
|
| 117 |
+
# any non-string/text scalar values such as numbers and arrays.
|
| 118 |
+
val = [scalar_validator(v) for v in s
|
| 119 |
+
if not isinstance(v, str) or v]
|
| 120 |
+
else:
|
| 121 |
+
raise ValueError(
|
| 122 |
+
f"Expected str or other non-set iterable, but got {s}")
|
| 123 |
+
if n is not None and len(val) != n:
|
| 124 |
+
raise ValueError(
|
| 125 |
+
f"Expected {n} values, but there are {len(val)} values in {s}")
|
| 126 |
+
return val
|
| 127 |
+
|
| 128 |
+
try:
|
| 129 |
+
f.__name__ = f"{scalar_validator.__name__}list"
|
| 130 |
+
except AttributeError: # class instance.
|
| 131 |
+
f.__name__ = f"{type(scalar_validator).__name__}List"
|
| 132 |
+
f.__qualname__ = f.__qualname__.rsplit(".", 1)[0] + "." + f.__name__
|
| 133 |
+
f.__doc__ = doc if doc is not None else scalar_validator.__doc__
|
| 134 |
+
return f
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def validate_any(s):
|
| 138 |
+
return s
|
| 139 |
+
validate_anylist = _listify_validator(validate_any)
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def _validate_date(s):
|
| 143 |
+
try:
|
| 144 |
+
np.datetime64(s)
|
| 145 |
+
return s
|
| 146 |
+
except ValueError:
|
| 147 |
+
raise ValueError(
|
| 148 |
+
f'{s!r} should be a string that can be parsed by numpy.datetime64')
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def validate_bool(b):
|
| 152 |
+
"""Convert b to ``bool`` or raise."""
|
| 153 |
+
if isinstance(b, str):
|
| 154 |
+
b = b.lower()
|
| 155 |
+
if b in ('t', 'y', 'yes', 'on', 'true', '1', 1, True):
|
| 156 |
+
return True
|
| 157 |
+
elif b in ('f', 'n', 'no', 'off', 'false', '0', 0, False):
|
| 158 |
+
return False
|
| 159 |
+
else:
|
| 160 |
+
raise ValueError(f'Cannot convert {b!r} to bool')
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def validate_axisbelow(s):
|
| 164 |
+
try:
|
| 165 |
+
return validate_bool(s)
|
| 166 |
+
except ValueError:
|
| 167 |
+
if isinstance(s, str):
|
| 168 |
+
if s == 'line':
|
| 169 |
+
return 'line'
|
| 170 |
+
raise ValueError(f'{s!r} cannot be interpreted as'
|
| 171 |
+
' True, False, or "line"')
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def validate_dpi(s):
|
| 175 |
+
"""Confirm s is string 'figure' or convert s to float or raise."""
|
| 176 |
+
if s == 'figure':
|
| 177 |
+
return s
|
| 178 |
+
try:
|
| 179 |
+
return float(s)
|
| 180 |
+
except ValueError as e:
|
| 181 |
+
raise ValueError(f'{s!r} is not string "figure" and '
|
| 182 |
+
f'could not convert {s!r} to float') from e
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
def _make_type_validator(cls, *, allow_none=False):
|
| 186 |
+
"""
|
| 187 |
+
Return a validator that converts inputs to *cls* or raises (and possibly
|
| 188 |
+
allows ``None`` as well).
|
| 189 |
+
"""
|
| 190 |
+
|
| 191 |
+
def validator(s):
|
| 192 |
+
if (allow_none and
|
| 193 |
+
(s is None or cbook._str_lower_equal(s, "none"))):
|
| 194 |
+
return None
|
| 195 |
+
if cls is str and not isinstance(s, str):
|
| 196 |
+
raise ValueError(f'Could not convert {s!r} to str')
|
| 197 |
+
try:
|
| 198 |
+
return cls(s)
|
| 199 |
+
except (TypeError, ValueError) as e:
|
| 200 |
+
raise ValueError(
|
| 201 |
+
f'Could not convert {s!r} to {cls.__name__}') from e
|
| 202 |
+
|
| 203 |
+
validator.__name__ = f"validate_{cls.__name__}"
|
| 204 |
+
if allow_none:
|
| 205 |
+
validator.__name__ += "_or_None"
|
| 206 |
+
validator.__qualname__ = (
|
| 207 |
+
validator.__qualname__.rsplit(".", 1)[0] + "." + validator.__name__)
|
| 208 |
+
return validator
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
validate_string = _make_type_validator(str)
|
| 212 |
+
validate_string_or_None = _make_type_validator(str, allow_none=True)
|
| 213 |
+
validate_stringlist = _listify_validator(
|
| 214 |
+
validate_string, doc='return a list of strings')
|
| 215 |
+
validate_int = _make_type_validator(int)
|
| 216 |
+
validate_int_or_None = _make_type_validator(int, allow_none=True)
|
| 217 |
+
validate_float = _make_type_validator(float)
|
| 218 |
+
validate_float_or_None = _make_type_validator(float, allow_none=True)
|
| 219 |
+
validate_floatlist = _listify_validator(
|
| 220 |
+
validate_float, doc='return a list of floats')
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def _validate_marker(s):
|
| 224 |
+
try:
|
| 225 |
+
return validate_int(s)
|
| 226 |
+
except ValueError as e:
|
| 227 |
+
try:
|
| 228 |
+
return validate_string(s)
|
| 229 |
+
except ValueError as e:
|
| 230 |
+
raise ValueError('Supported markers are [string, int]') from e
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
_validate_markerlist = _listify_validator(
|
| 234 |
+
_validate_marker, doc='return a list of markers')
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def _validate_pathlike(s):
|
| 238 |
+
if isinstance(s, (str, os.PathLike)):
|
| 239 |
+
# Store value as str because savefig.directory needs to distinguish
|
| 240 |
+
# between "" (cwd) and "." (cwd, but gets updated by user selections).
|
| 241 |
+
return os.fsdecode(s)
|
| 242 |
+
else:
|
| 243 |
+
return validate_string(s)
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def validate_fonttype(s):
|
| 247 |
+
"""
|
| 248 |
+
Confirm that this is a Postscript or PDF font type that we know how to
|
| 249 |
+
convert to.
|
| 250 |
+
"""
|
| 251 |
+
fonttypes = {'type3': 3,
|
| 252 |
+
'truetype': 42}
|
| 253 |
+
try:
|
| 254 |
+
fonttype = validate_int(s)
|
| 255 |
+
except ValueError:
|
| 256 |
+
try:
|
| 257 |
+
return fonttypes[s.lower()]
|
| 258 |
+
except KeyError as e:
|
| 259 |
+
raise ValueError('Supported Postscript/PDF font types are %s'
|
| 260 |
+
% list(fonttypes)) from e
|
| 261 |
+
else:
|
| 262 |
+
if fonttype not in fonttypes.values():
|
| 263 |
+
raise ValueError(
|
| 264 |
+
'Supported Postscript/PDF font types are %s' %
|
| 265 |
+
list(fonttypes.values()))
|
| 266 |
+
return fonttype
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
_auto_backend_sentinel = object()
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
def validate_backend(s):
|
| 273 |
+
if s is _auto_backend_sentinel or backend_registry.is_valid_backend(s):
|
| 274 |
+
return s
|
| 275 |
+
else:
|
| 276 |
+
msg = (f"'{s}' is not a valid value for backend; supported values are "
|
| 277 |
+
f"{backend_registry.list_all()}")
|
| 278 |
+
raise ValueError(msg)
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
def _validate_toolbar(s):
|
| 282 |
+
s = ValidateInStrings(
|
| 283 |
+
'toolbar', ['None', 'toolbar2', 'toolmanager'], ignorecase=True)(s)
|
| 284 |
+
if s == 'toolmanager':
|
| 285 |
+
_api.warn_external(
|
| 286 |
+
"Treat the new Tool classes introduced in v1.5 as experimental "
|
| 287 |
+
"for now; the API and rcParam may change in future versions.")
|
| 288 |
+
return s
|
| 289 |
+
|
| 290 |
+
|
| 291 |
+
def validate_color_or_inherit(s):
|
| 292 |
+
"""Return a valid color arg."""
|
| 293 |
+
if cbook._str_equal(s, 'inherit'):
|
| 294 |
+
return s
|
| 295 |
+
return validate_color(s)
|
| 296 |
+
|
| 297 |
+
|
| 298 |
+
def validate_color_or_auto(s):
|
| 299 |
+
if cbook._str_equal(s, 'auto'):
|
| 300 |
+
return s
|
| 301 |
+
return validate_color(s)
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
def validate_color_for_prop_cycle(s):
|
| 305 |
+
# N-th color cycle syntax can't go into the color cycle.
|
| 306 |
+
if isinstance(s, str) and re.match("^C[0-9]$", s):
|
| 307 |
+
raise ValueError(f"Cannot put cycle reference ({s!r}) in prop_cycler")
|
| 308 |
+
return validate_color(s)
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
def _validate_color_or_linecolor(s):
|
| 312 |
+
if cbook._str_equal(s, 'linecolor'):
|
| 313 |
+
return s
|
| 314 |
+
elif cbook._str_equal(s, 'mfc') or cbook._str_equal(s, 'markerfacecolor'):
|
| 315 |
+
return 'markerfacecolor'
|
| 316 |
+
elif cbook._str_equal(s, 'mec') or cbook._str_equal(s, 'markeredgecolor'):
|
| 317 |
+
return 'markeredgecolor'
|
| 318 |
+
elif s is None:
|
| 319 |
+
return None
|
| 320 |
+
elif isinstance(s, str) and len(s) == 6 or len(s) == 8:
|
| 321 |
+
stmp = '#' + s
|
| 322 |
+
if is_color_like(stmp):
|
| 323 |
+
return stmp
|
| 324 |
+
if s.lower() == 'none':
|
| 325 |
+
return None
|
| 326 |
+
elif is_color_like(s):
|
| 327 |
+
return s
|
| 328 |
+
|
| 329 |
+
raise ValueError(f'{s!r} does not look like a color arg')
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
def validate_color(s):
|
| 333 |
+
"""Return a valid color arg."""
|
| 334 |
+
if isinstance(s, str):
|
| 335 |
+
if s.lower() == 'none':
|
| 336 |
+
return 'none'
|
| 337 |
+
if len(s) == 6 or len(s) == 8:
|
| 338 |
+
stmp = '#' + s
|
| 339 |
+
if is_color_like(stmp):
|
| 340 |
+
return stmp
|
| 341 |
+
|
| 342 |
+
if is_color_like(s):
|
| 343 |
+
return s
|
| 344 |
+
|
| 345 |
+
# If it is still valid, it must be a tuple (as a string from matplotlibrc).
|
| 346 |
+
try:
|
| 347 |
+
color = ast.literal_eval(s)
|
| 348 |
+
except (SyntaxError, ValueError):
|
| 349 |
+
pass
|
| 350 |
+
else:
|
| 351 |
+
if is_color_like(color):
|
| 352 |
+
return color
|
| 353 |
+
|
| 354 |
+
raise ValueError(f'{s!r} does not look like a color arg')
|
| 355 |
+
|
| 356 |
+
|
| 357 |
+
validate_colorlist = _listify_validator(
|
| 358 |
+
validate_color, allow_stringlist=True, doc='return a list of colorspecs')
|
| 359 |
+
|
| 360 |
+
|
| 361 |
+
def _validate_cmap(s):
|
| 362 |
+
_api.check_isinstance((str, Colormap), cmap=s)
|
| 363 |
+
return s
|
| 364 |
+
|
| 365 |
+
|
| 366 |
+
def validate_aspect(s):
|
| 367 |
+
if s in ('auto', 'equal'):
|
| 368 |
+
return s
|
| 369 |
+
try:
|
| 370 |
+
return float(s)
|
| 371 |
+
except ValueError as e:
|
| 372 |
+
raise ValueError('not a valid aspect specification') from e
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
def validate_fontsize_None(s):
|
| 376 |
+
if s is None or s == 'None':
|
| 377 |
+
return None
|
| 378 |
+
else:
|
| 379 |
+
return validate_fontsize(s)
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
def validate_fontsize(s):
|
| 383 |
+
fontsizes = ['xx-small', 'x-small', 'small', 'medium', 'large',
|
| 384 |
+
'x-large', 'xx-large', 'smaller', 'larger']
|
| 385 |
+
if isinstance(s, str):
|
| 386 |
+
s = s.lower()
|
| 387 |
+
if s in fontsizes:
|
| 388 |
+
return s
|
| 389 |
+
try:
|
| 390 |
+
return float(s)
|
| 391 |
+
except ValueError as e:
|
| 392 |
+
raise ValueError("%s is not a valid font size. Valid font sizes "
|
| 393 |
+
"are %s." % (s, ", ".join(fontsizes))) from e
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
validate_fontsizelist = _listify_validator(validate_fontsize)
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
def validate_fontweight(s):
|
| 400 |
+
weights = [
|
| 401 |
+
'ultralight', 'light', 'normal', 'regular', 'book', 'medium', 'roman',
|
| 402 |
+
'semibold', 'demibold', 'demi', 'bold', 'heavy', 'extra bold', 'black']
|
| 403 |
+
# Note: Historically, weights have been case-sensitive in Matplotlib
|
| 404 |
+
if s in weights:
|
| 405 |
+
return s
|
| 406 |
+
try:
|
| 407 |
+
return int(s)
|
| 408 |
+
except (ValueError, TypeError) as e:
|
| 409 |
+
raise ValueError(f'{s} is not a valid font weight.') from e
|
| 410 |
+
|
| 411 |
+
|
| 412 |
+
def validate_fontstretch(s):
|
| 413 |
+
stretchvalues = [
|
| 414 |
+
'ultra-condensed', 'extra-condensed', 'condensed', 'semi-condensed',
|
| 415 |
+
'normal', 'semi-expanded', 'expanded', 'extra-expanded',
|
| 416 |
+
'ultra-expanded']
|
| 417 |
+
# Note: Historically, stretchvalues have been case-sensitive in Matplotlib
|
| 418 |
+
if s in stretchvalues:
|
| 419 |
+
return s
|
| 420 |
+
try:
|
| 421 |
+
return int(s)
|
| 422 |
+
except (ValueError, TypeError) as e:
|
| 423 |
+
raise ValueError(f'{s} is not a valid font stretch.') from e
|
| 424 |
+
|
| 425 |
+
|
| 426 |
+
def validate_font_properties(s):
|
| 427 |
+
parse_fontconfig_pattern(s)
|
| 428 |
+
return s
|
| 429 |
+
|
| 430 |
+
|
| 431 |
+
def _validate_mathtext_fallback(s):
|
| 432 |
+
_fallback_fonts = ['cm', 'stix', 'stixsans']
|
| 433 |
+
if isinstance(s, str):
|
| 434 |
+
s = s.lower()
|
| 435 |
+
if s is None or s == 'none':
|
| 436 |
+
return None
|
| 437 |
+
elif s.lower() in _fallback_fonts:
|
| 438 |
+
return s
|
| 439 |
+
else:
|
| 440 |
+
raise ValueError(
|
| 441 |
+
f"{s} is not a valid fallback font name. Valid fallback font "
|
| 442 |
+
f"names are {','.join(_fallback_fonts)}. Passing 'None' will turn "
|
| 443 |
+
"fallback off.")
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
def validate_whiskers(s):
|
| 447 |
+
try:
|
| 448 |
+
return _listify_validator(validate_float, n=2)(s)
|
| 449 |
+
except (TypeError, ValueError):
|
| 450 |
+
try:
|
| 451 |
+
return float(s)
|
| 452 |
+
except ValueError as e:
|
| 453 |
+
raise ValueError("Not a valid whisker value [float, "
|
| 454 |
+
"(float, float)]") from e
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
def validate_ps_distiller(s):
|
| 458 |
+
if isinstance(s, str):
|
| 459 |
+
s = s.lower()
|
| 460 |
+
if s in ('none', None, 'false', False):
|
| 461 |
+
return None
|
| 462 |
+
else:
|
| 463 |
+
return ValidateInStrings('ps.usedistiller', ['ghostscript', 'xpdf'])(s)
|
| 464 |
+
|
| 465 |
+
|
| 466 |
+
# A validator dedicated to the named line styles, based on the items in
|
| 467 |
+
# ls_mapper, and a list of possible strings read from Line2D.set_linestyle
|
| 468 |
+
_validate_named_linestyle = ValidateInStrings(
|
| 469 |
+
'linestyle',
|
| 470 |
+
[*ls_mapper.keys(), *ls_mapper.values(), 'None', 'none', ' ', ''],
|
| 471 |
+
ignorecase=True)
|
| 472 |
+
|
| 473 |
+
|
| 474 |
+
def _validate_linestyle(ls):
|
| 475 |
+
"""
|
| 476 |
+
A validator for all possible line styles, the named ones *and*
|
| 477 |
+
the on-off ink sequences.
|
| 478 |
+
"""
|
| 479 |
+
if isinstance(ls, str):
|
| 480 |
+
try: # Look first for a valid named line style, like '--' or 'solid'.
|
| 481 |
+
return _validate_named_linestyle(ls)
|
| 482 |
+
except ValueError:
|
| 483 |
+
pass
|
| 484 |
+
try:
|
| 485 |
+
ls = ast.literal_eval(ls) # Parsing matplotlibrc.
|
| 486 |
+
except (SyntaxError, ValueError):
|
| 487 |
+
pass # Will error with the ValueError at the end.
|
| 488 |
+
|
| 489 |
+
def _is_iterable_not_string_like(x):
|
| 490 |
+
# Explicitly exclude bytes/bytearrays so that they are not
|
| 491 |
+
# nonsensically interpreted as sequences of numbers (codepoints).
|
| 492 |
+
return np.iterable(x) and not isinstance(x, (str, bytes, bytearray))
|
| 493 |
+
|
| 494 |
+
if _is_iterable_not_string_like(ls):
|
| 495 |
+
if len(ls) == 2 and _is_iterable_not_string_like(ls[1]):
|
| 496 |
+
# (offset, (on, off, on, off, ...))
|
| 497 |
+
offset, onoff = ls
|
| 498 |
+
else:
|
| 499 |
+
# For backcompat: (on, off, on, off, ...); the offset is implicit.
|
| 500 |
+
offset = 0
|
| 501 |
+
onoff = ls
|
| 502 |
+
|
| 503 |
+
if (isinstance(offset, Real)
|
| 504 |
+
and len(onoff) % 2 == 0
|
| 505 |
+
and all(isinstance(elem, Real) for elem in onoff)):
|
| 506 |
+
return (offset, onoff)
|
| 507 |
+
|
| 508 |
+
raise ValueError(f"linestyle {ls!r} is not a valid on-off ink sequence.")
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
validate_fillstyle = ValidateInStrings(
|
| 512 |
+
'markers.fillstyle', ['full', 'left', 'right', 'bottom', 'top', 'none'])
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
validate_fillstylelist = _listify_validator(validate_fillstyle)
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
def validate_markevery(s):
|
| 519 |
+
"""
|
| 520 |
+
Validate the markevery property of a Line2D object.
|
| 521 |
+
|
| 522 |
+
Parameters
|
| 523 |
+
----------
|
| 524 |
+
s : None, int, (int, int), slice, float, (float, float), or list[int]
|
| 525 |
+
|
| 526 |
+
Returns
|
| 527 |
+
-------
|
| 528 |
+
None, int, (int, int), slice, float, (float, float), or list[int]
|
| 529 |
+
"""
|
| 530 |
+
# Validate s against type slice float int and None
|
| 531 |
+
if isinstance(s, (slice, float, int, type(None))):
|
| 532 |
+
return s
|
| 533 |
+
# Validate s against type tuple
|
| 534 |
+
if isinstance(s, tuple):
|
| 535 |
+
if (len(s) == 2
|
| 536 |
+
and (all(isinstance(e, int) for e in s)
|
| 537 |
+
or all(isinstance(e, float) for e in s))):
|
| 538 |
+
return s
|
| 539 |
+
else:
|
| 540 |
+
raise TypeError(
|
| 541 |
+
"'markevery' tuple must be pair of ints or of floats")
|
| 542 |
+
# Validate s against type list
|
| 543 |
+
if isinstance(s, list):
|
| 544 |
+
if all(isinstance(e, int) for e in s):
|
| 545 |
+
return s
|
| 546 |
+
else:
|
| 547 |
+
raise TypeError(
|
| 548 |
+
"'markevery' list must have all elements of type int")
|
| 549 |
+
raise TypeError("'markevery' is of an invalid type")
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
validate_markeverylist = _listify_validator(validate_markevery)
|
| 553 |
+
|
| 554 |
+
|
| 555 |
+
def validate_bbox(s):
|
| 556 |
+
if isinstance(s, str):
|
| 557 |
+
s = s.lower()
|
| 558 |
+
if s == 'tight':
|
| 559 |
+
return s
|
| 560 |
+
if s == 'standard':
|
| 561 |
+
return None
|
| 562 |
+
raise ValueError("bbox should be 'tight' or 'standard'")
|
| 563 |
+
elif s is not None:
|
| 564 |
+
# Backwards compatibility. None is equivalent to 'standard'.
|
| 565 |
+
raise ValueError("bbox should be 'tight' or 'standard'")
|
| 566 |
+
return s
|
| 567 |
+
|
| 568 |
+
|
| 569 |
+
def validate_sketch(s):
|
| 570 |
+
|
| 571 |
+
if isinstance(s, str):
|
| 572 |
+
s = s.lower().strip()
|
| 573 |
+
if s.startswith("(") and s.endswith(")"):
|
| 574 |
+
s = s[1:-1]
|
| 575 |
+
if s == 'none' or s is None:
|
| 576 |
+
return None
|
| 577 |
+
try:
|
| 578 |
+
return tuple(_listify_validator(validate_float, n=3)(s))
|
| 579 |
+
except ValueError as exc:
|
| 580 |
+
raise ValueError("Expected a (scale, length, randomness) tuple") from exc
|
| 581 |
+
|
| 582 |
+
|
| 583 |
+
def _validate_greaterthan_minushalf(s):
|
| 584 |
+
s = validate_float(s)
|
| 585 |
+
if s > -0.5:
|
| 586 |
+
return s
|
| 587 |
+
else:
|
| 588 |
+
raise RuntimeError(f'Value must be >-0.5; got {s}')
|
| 589 |
+
|
| 590 |
+
|
| 591 |
+
def _validate_greaterequal0_lessequal1(s):
|
| 592 |
+
s = validate_float(s)
|
| 593 |
+
if 0 <= s <= 1:
|
| 594 |
+
return s
|
| 595 |
+
else:
|
| 596 |
+
raise RuntimeError(f'Value must be >=0 and <=1; got {s}')
|
| 597 |
+
|
| 598 |
+
|
| 599 |
+
def _validate_int_greaterequal0(s):
|
| 600 |
+
s = validate_int(s)
|
| 601 |
+
if s >= 0:
|
| 602 |
+
return s
|
| 603 |
+
else:
|
| 604 |
+
raise RuntimeError(f'Value must be >=0; got {s}')
|
| 605 |
+
|
| 606 |
+
|
| 607 |
+
def validate_hatch(s):
|
| 608 |
+
r"""
|
| 609 |
+
Validate a hatch pattern.
|
| 610 |
+
A hatch pattern string can have any sequence of the following
|
| 611 |
+
characters: ``\ / | - + * . x o O``.
|
| 612 |
+
"""
|
| 613 |
+
if not isinstance(s, str):
|
| 614 |
+
raise ValueError("Hatch pattern must be a string")
|
| 615 |
+
_api.check_isinstance(str, hatch_pattern=s)
|
| 616 |
+
unknown = set(s) - {'\\', '/', '|', '-', '+', '*', '.', 'x', 'o', 'O'}
|
| 617 |
+
if unknown:
|
| 618 |
+
raise ValueError("Unknown hatch symbol(s): %s" % list(unknown))
|
| 619 |
+
return s
|
| 620 |
+
|
| 621 |
+
|
| 622 |
+
validate_hatchlist = _listify_validator(validate_hatch)
|
| 623 |
+
validate_dashlist = _listify_validator(validate_floatlist)
|
| 624 |
+
|
| 625 |
+
|
| 626 |
+
def _validate_minor_tick_ndivs(n):
|
| 627 |
+
"""
|
| 628 |
+
Validate ndiv parameter related to the minor ticks.
|
| 629 |
+
It controls the number of minor ticks to be placed between
|
| 630 |
+
two major ticks.
|
| 631 |
+
"""
|
| 632 |
+
|
| 633 |
+
if cbook._str_lower_equal(n, 'auto'):
|
| 634 |
+
return n
|
| 635 |
+
try:
|
| 636 |
+
n = _validate_int_greaterequal0(n)
|
| 637 |
+
return n
|
| 638 |
+
except (RuntimeError, ValueError):
|
| 639 |
+
pass
|
| 640 |
+
|
| 641 |
+
raise ValueError("'tick.minor.ndivs' must be 'auto' or non-negative int")
|
| 642 |
+
|
| 643 |
+
|
| 644 |
+
_prop_validators = {
|
| 645 |
+
'color': _listify_validator(validate_color_for_prop_cycle,
|
| 646 |
+
allow_stringlist=True),
|
| 647 |
+
'linewidth': validate_floatlist,
|
| 648 |
+
'linestyle': _listify_validator(_validate_linestyle),
|
| 649 |
+
'facecolor': validate_colorlist,
|
| 650 |
+
'edgecolor': validate_colorlist,
|
| 651 |
+
'joinstyle': _listify_validator(JoinStyle),
|
| 652 |
+
'capstyle': _listify_validator(CapStyle),
|
| 653 |
+
'fillstyle': validate_fillstylelist,
|
| 654 |
+
'markerfacecolor': validate_colorlist,
|
| 655 |
+
'markersize': validate_floatlist,
|
| 656 |
+
'markeredgewidth': validate_floatlist,
|
| 657 |
+
'markeredgecolor': validate_colorlist,
|
| 658 |
+
'markevery': validate_markeverylist,
|
| 659 |
+
'alpha': validate_floatlist,
|
| 660 |
+
'marker': _validate_markerlist,
|
| 661 |
+
'hatch': validate_hatchlist,
|
| 662 |
+
'dashes': validate_dashlist,
|
| 663 |
+
}
|
| 664 |
+
_prop_aliases = {
|
| 665 |
+
'c': 'color',
|
| 666 |
+
'lw': 'linewidth',
|
| 667 |
+
'ls': 'linestyle',
|
| 668 |
+
'fc': 'facecolor',
|
| 669 |
+
'ec': 'edgecolor',
|
| 670 |
+
'mfc': 'markerfacecolor',
|
| 671 |
+
'mec': 'markeredgecolor',
|
| 672 |
+
'mew': 'markeredgewidth',
|
| 673 |
+
'ms': 'markersize',
|
| 674 |
+
}
|
| 675 |
+
|
| 676 |
+
|
| 677 |
+
def cycler(*args, **kwargs):
|
| 678 |
+
"""
|
| 679 |
+
Create a `~cycler.Cycler` object much like :func:`cycler.cycler`,
|
| 680 |
+
but includes input validation.
|
| 681 |
+
|
| 682 |
+
Call signatures::
|
| 683 |
+
|
| 684 |
+
cycler(cycler)
|
| 685 |
+
cycler(label=values, label2=values2, ...)
|
| 686 |
+
cycler(label, values)
|
| 687 |
+
|
| 688 |
+
Form 1 copies a given `~cycler.Cycler` object.
|
| 689 |
+
|
| 690 |
+
Form 2 creates a `~cycler.Cycler` which cycles over one or more
|
| 691 |
+
properties simultaneously. If multiple properties are given, their
|
| 692 |
+
value lists must have the same length.
|
| 693 |
+
|
| 694 |
+
Form 3 creates a `~cycler.Cycler` for a single property. This form
|
| 695 |
+
exists for compatibility with the original cycler. Its use is
|
| 696 |
+
discouraged in favor of the kwarg form, i.e. ``cycler(label=values)``.
|
| 697 |
+
|
| 698 |
+
Parameters
|
| 699 |
+
----------
|
| 700 |
+
cycler : Cycler
|
| 701 |
+
Copy constructor for Cycler.
|
| 702 |
+
|
| 703 |
+
label : str
|
| 704 |
+
The property key. Must be a valid `.Artist` property.
|
| 705 |
+
For example, 'color' or 'linestyle'. Aliases are allowed,
|
| 706 |
+
such as 'c' for 'color' and 'lw' for 'linewidth'.
|
| 707 |
+
|
| 708 |
+
values : iterable
|
| 709 |
+
Finite-length iterable of the property values. These values
|
| 710 |
+
are validated and will raise a ValueError if invalid.
|
| 711 |
+
|
| 712 |
+
Returns
|
| 713 |
+
-------
|
| 714 |
+
Cycler
|
| 715 |
+
A new :class:`~cycler.Cycler` for the given properties.
|
| 716 |
+
|
| 717 |
+
Examples
|
| 718 |
+
--------
|
| 719 |
+
Creating a cycler for a single property:
|
| 720 |
+
|
| 721 |
+
>>> c = cycler(color=['red', 'green', 'blue'])
|
| 722 |
+
|
| 723 |
+
Creating a cycler for simultaneously cycling over multiple properties
|
| 724 |
+
(e.g. red circle, green plus, blue cross):
|
| 725 |
+
|
| 726 |
+
>>> c = cycler(color=['red', 'green', 'blue'],
|
| 727 |
+
... marker=['o', '+', 'x'])
|
| 728 |
+
|
| 729 |
+
"""
|
| 730 |
+
if args and kwargs:
|
| 731 |
+
raise TypeError("cycler() can only accept positional OR keyword "
|
| 732 |
+
"arguments -- not both.")
|
| 733 |
+
elif not args and not kwargs:
|
| 734 |
+
raise TypeError("cycler() must have positional OR keyword arguments")
|
| 735 |
+
|
| 736 |
+
if len(args) == 1:
|
| 737 |
+
if not isinstance(args[0], Cycler):
|
| 738 |
+
raise TypeError("If only one positional argument given, it must "
|
| 739 |
+
"be a Cycler instance.")
|
| 740 |
+
return validate_cycler(args[0])
|
| 741 |
+
elif len(args) == 2:
|
| 742 |
+
pairs = [(args[0], args[1])]
|
| 743 |
+
elif len(args) > 2:
|
| 744 |
+
raise _api.nargs_error('cycler', '0-2', len(args))
|
| 745 |
+
else:
|
| 746 |
+
pairs = kwargs.items()
|
| 747 |
+
|
| 748 |
+
validated = []
|
| 749 |
+
for prop, vals in pairs:
|
| 750 |
+
norm_prop = _prop_aliases.get(prop, prop)
|
| 751 |
+
validator = _prop_validators.get(norm_prop, None)
|
| 752 |
+
if validator is None:
|
| 753 |
+
raise TypeError("Unknown artist property: %s" % prop)
|
| 754 |
+
vals = validator(vals)
|
| 755 |
+
# We will normalize the property names as well to reduce
|
| 756 |
+
# the amount of alias handling code elsewhere.
|
| 757 |
+
validated.append((norm_prop, vals))
|
| 758 |
+
|
| 759 |
+
return reduce(operator.add, (ccycler(k, v) for k, v in validated))
|
| 760 |
+
|
| 761 |
+
|
| 762 |
+
class _DunderChecker(ast.NodeVisitor):
|
| 763 |
+
def visit_Attribute(self, node):
|
| 764 |
+
if node.attr.startswith("__") and node.attr.endswith("__"):
|
| 765 |
+
raise ValueError("cycler strings with dunders are forbidden")
|
| 766 |
+
self.generic_visit(node)
|
| 767 |
+
|
| 768 |
+
|
| 769 |
+
# A validator dedicated to the named legend loc
|
| 770 |
+
_validate_named_legend_loc = ValidateInStrings(
|
| 771 |
+
'legend.loc',
|
| 772 |
+
[
|
| 773 |
+
"best",
|
| 774 |
+
"upper right", "upper left", "lower left", "lower right", "right",
|
| 775 |
+
"center left", "center right", "lower center", "upper center",
|
| 776 |
+
"center"],
|
| 777 |
+
ignorecase=True)
|
| 778 |
+
|
| 779 |
+
|
| 780 |
+
def _validate_legend_loc(loc):
|
| 781 |
+
"""
|
| 782 |
+
Confirm that loc is a type which rc.Params["legend.loc"] supports.
|
| 783 |
+
|
| 784 |
+
.. versionadded:: 3.8
|
| 785 |
+
|
| 786 |
+
Parameters
|
| 787 |
+
----------
|
| 788 |
+
loc : str | int | (float, float) | str((float, float))
|
| 789 |
+
The location of the legend.
|
| 790 |
+
|
| 791 |
+
Returns
|
| 792 |
+
-------
|
| 793 |
+
loc : str | int | (float, float) or raise ValueError exception
|
| 794 |
+
The location of the legend.
|
| 795 |
+
"""
|
| 796 |
+
if isinstance(loc, str):
|
| 797 |
+
try:
|
| 798 |
+
return _validate_named_legend_loc(loc)
|
| 799 |
+
except ValueError:
|
| 800 |
+
pass
|
| 801 |
+
try:
|
| 802 |
+
loc = ast.literal_eval(loc)
|
| 803 |
+
except (SyntaxError, ValueError):
|
| 804 |
+
pass
|
| 805 |
+
if isinstance(loc, int):
|
| 806 |
+
if 0 <= loc <= 10:
|
| 807 |
+
return loc
|
| 808 |
+
if isinstance(loc, tuple):
|
| 809 |
+
if len(loc) == 2 and all(isinstance(e, Real) for e in loc):
|
| 810 |
+
return loc
|
| 811 |
+
raise ValueError(f"{loc} is not a valid legend location.")
|
| 812 |
+
|
| 813 |
+
|
| 814 |
+
def validate_cycler(s):
|
| 815 |
+
"""Return a Cycler object from a string repr or the object itself."""
|
| 816 |
+
if isinstance(s, str):
|
| 817 |
+
# TODO: We might want to rethink this...
|
| 818 |
+
# While I think I have it quite locked down, it is execution of
|
| 819 |
+
# arbitrary code without sanitation.
|
| 820 |
+
# Combine this with the possibility that rcparams might come from the
|
| 821 |
+
# internet (future plans), this could be downright dangerous.
|
| 822 |
+
# I locked it down by only having the 'cycler()' function available.
|
| 823 |
+
# UPDATE: Partly plugging a security hole.
|
| 824 |
+
# I really should have read this:
|
| 825 |
+
# https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
|
| 826 |
+
# We should replace this eval with a combo of PyParsing and
|
| 827 |
+
# ast.literal_eval()
|
| 828 |
+
try:
|
| 829 |
+
_DunderChecker().visit(ast.parse(s))
|
| 830 |
+
s = eval(s, {'cycler': cycler, '__builtins__': {}})
|
| 831 |
+
except BaseException as e:
|
| 832 |
+
raise ValueError(f"{s!r} is not a valid cycler construction: {e}"
|
| 833 |
+
) from e
|
| 834 |
+
# Should make sure what comes from the above eval()
|
| 835 |
+
# is a Cycler object.
|
| 836 |
+
if isinstance(s, Cycler):
|
| 837 |
+
cycler_inst = s
|
| 838 |
+
else:
|
| 839 |
+
raise ValueError(f"Object is not a string or Cycler instance: {s!r}")
|
| 840 |
+
|
| 841 |
+
unknowns = cycler_inst.keys - (set(_prop_validators) | set(_prop_aliases))
|
| 842 |
+
if unknowns:
|
| 843 |
+
raise ValueError("Unknown artist properties: %s" % unknowns)
|
| 844 |
+
|
| 845 |
+
# Not a full validation, but it'll at least normalize property names
|
| 846 |
+
# A fuller validation would require v0.10 of cycler.
|
| 847 |
+
checker = set()
|
| 848 |
+
for prop in cycler_inst.keys:
|
| 849 |
+
norm_prop = _prop_aliases.get(prop, prop)
|
| 850 |
+
if norm_prop != prop and norm_prop in cycler_inst.keys:
|
| 851 |
+
raise ValueError(f"Cannot specify both {norm_prop!r} and alias "
|
| 852 |
+
f"{prop!r} in the same prop_cycle")
|
| 853 |
+
if norm_prop in checker:
|
| 854 |
+
raise ValueError(f"Another property was already aliased to "
|
| 855 |
+
f"{norm_prop!r}. Collision normalizing {prop!r}.")
|
| 856 |
+
checker.update([norm_prop])
|
| 857 |
+
|
| 858 |
+
# This is just an extra-careful check, just in case there is some
|
| 859 |
+
# edge-case I haven't thought of.
|
| 860 |
+
assert len(checker) == len(cycler_inst.keys)
|
| 861 |
+
|
| 862 |
+
# Now, it should be safe to mutate this cycler
|
| 863 |
+
for prop in cycler_inst.keys:
|
| 864 |
+
norm_prop = _prop_aliases.get(prop, prop)
|
| 865 |
+
cycler_inst.change_key(prop, norm_prop)
|
| 866 |
+
|
| 867 |
+
for key, vals in cycler_inst.by_key().items():
|
| 868 |
+
_prop_validators[key](vals)
|
| 869 |
+
|
| 870 |
+
return cycler_inst
|
| 871 |
+
|
| 872 |
+
|
| 873 |
+
def validate_hist_bins(s):
|
| 874 |
+
valid_strs = ["auto", "sturges", "fd", "doane", "scott", "rice", "sqrt"]
|
| 875 |
+
if isinstance(s, str) and s in valid_strs:
|
| 876 |
+
return s
|
| 877 |
+
try:
|
| 878 |
+
return int(s)
|
| 879 |
+
except (TypeError, ValueError):
|
| 880 |
+
pass
|
| 881 |
+
try:
|
| 882 |
+
return validate_floatlist(s)
|
| 883 |
+
except ValueError:
|
| 884 |
+
pass
|
| 885 |
+
raise ValueError(f"'hist.bins' must be one of {valid_strs}, an int or"
|
| 886 |
+
" a sequence of floats")
|
| 887 |
+
|
| 888 |
+
|
| 889 |
+
class _ignorecase(list):
|
| 890 |
+
"""A marker class indicating that a list-of-str is case-insensitive."""
|
| 891 |
+
|
| 892 |
+
|
| 893 |
+
def _convert_validator_spec(key, conv):
|
| 894 |
+
if isinstance(conv, list):
|
| 895 |
+
ignorecase = isinstance(conv, _ignorecase)
|
| 896 |
+
return ValidateInStrings(key, conv, ignorecase=ignorecase)
|
| 897 |
+
else:
|
| 898 |
+
return conv
|
| 899 |
+
|
| 900 |
+
|
| 901 |
+
# Mapping of rcParams to validators.
|
| 902 |
+
# Converters given as lists or _ignorecase are converted to ValidateInStrings
|
| 903 |
+
# immediately below.
|
| 904 |
+
# The rcParams defaults are defined in lib/matplotlib/mpl-data/matplotlibrc, which
|
| 905 |
+
# gets copied to matplotlib/mpl-data/matplotlibrc by the setup script.
|
| 906 |
+
_validators = {
|
| 907 |
+
"backend": validate_backend,
|
| 908 |
+
"backend_fallback": validate_bool,
|
| 909 |
+
"figure.hooks": validate_stringlist,
|
| 910 |
+
"toolbar": _validate_toolbar,
|
| 911 |
+
"interactive": validate_bool,
|
| 912 |
+
"timezone": validate_string,
|
| 913 |
+
|
| 914 |
+
"webagg.port": validate_int,
|
| 915 |
+
"webagg.address": validate_string,
|
| 916 |
+
"webagg.open_in_browser": validate_bool,
|
| 917 |
+
"webagg.port_retries": validate_int,
|
| 918 |
+
|
| 919 |
+
# line props
|
| 920 |
+
"lines.linewidth": validate_float, # line width in points
|
| 921 |
+
"lines.linestyle": _validate_linestyle, # solid line
|
| 922 |
+
"lines.color": validate_color, # first color in color cycle
|
| 923 |
+
"lines.marker": _validate_marker, # marker name
|
| 924 |
+
"lines.markerfacecolor": validate_color_or_auto, # default color
|
| 925 |
+
"lines.markeredgecolor": validate_color_or_auto, # default color
|
| 926 |
+
"lines.markeredgewidth": validate_float,
|
| 927 |
+
"lines.markersize": validate_float, # markersize, in points
|
| 928 |
+
"lines.antialiased": validate_bool, # antialiased (no jaggies)
|
| 929 |
+
"lines.dash_joinstyle": JoinStyle,
|
| 930 |
+
"lines.solid_joinstyle": JoinStyle,
|
| 931 |
+
"lines.dash_capstyle": CapStyle,
|
| 932 |
+
"lines.solid_capstyle": CapStyle,
|
| 933 |
+
"lines.dashed_pattern": validate_floatlist,
|
| 934 |
+
"lines.dashdot_pattern": validate_floatlist,
|
| 935 |
+
"lines.dotted_pattern": validate_floatlist,
|
| 936 |
+
"lines.scale_dashes": validate_bool,
|
| 937 |
+
|
| 938 |
+
# marker props
|
| 939 |
+
"markers.fillstyle": validate_fillstyle,
|
| 940 |
+
|
| 941 |
+
## pcolor(mesh) props:
|
| 942 |
+
"pcolor.shading": ["auto", "flat", "nearest", "gouraud"],
|
| 943 |
+
"pcolormesh.snap": validate_bool,
|
| 944 |
+
|
| 945 |
+
## patch props
|
| 946 |
+
"patch.linewidth": validate_float, # line width in points
|
| 947 |
+
"patch.edgecolor": validate_color,
|
| 948 |
+
"patch.force_edgecolor": validate_bool,
|
| 949 |
+
"patch.facecolor": validate_color, # first color in cycle
|
| 950 |
+
"patch.antialiased": validate_bool, # antialiased (no jaggies)
|
| 951 |
+
|
| 952 |
+
## hatch props
|
| 953 |
+
"hatch.color": validate_color,
|
| 954 |
+
"hatch.linewidth": validate_float,
|
| 955 |
+
|
| 956 |
+
## Histogram properties
|
| 957 |
+
"hist.bins": validate_hist_bins,
|
| 958 |
+
|
| 959 |
+
## Boxplot properties
|
| 960 |
+
"boxplot.notch": validate_bool,
|
| 961 |
+
"boxplot.vertical": validate_bool,
|
| 962 |
+
"boxplot.whiskers": validate_whiskers,
|
| 963 |
+
"boxplot.bootstrap": validate_int_or_None,
|
| 964 |
+
"boxplot.patchartist": validate_bool,
|
| 965 |
+
"boxplot.showmeans": validate_bool,
|
| 966 |
+
"boxplot.showcaps": validate_bool,
|
| 967 |
+
"boxplot.showbox": validate_bool,
|
| 968 |
+
"boxplot.showfliers": validate_bool,
|
| 969 |
+
"boxplot.meanline": validate_bool,
|
| 970 |
+
|
| 971 |
+
"boxplot.flierprops.color": validate_color,
|
| 972 |
+
"boxplot.flierprops.marker": _validate_marker,
|
| 973 |
+
"boxplot.flierprops.markerfacecolor": validate_color_or_auto,
|
| 974 |
+
"boxplot.flierprops.markeredgecolor": validate_color,
|
| 975 |
+
"boxplot.flierprops.markeredgewidth": validate_float,
|
| 976 |
+
"boxplot.flierprops.markersize": validate_float,
|
| 977 |
+
"boxplot.flierprops.linestyle": _validate_linestyle,
|
| 978 |
+
"boxplot.flierprops.linewidth": validate_float,
|
| 979 |
+
|
| 980 |
+
"boxplot.boxprops.color": validate_color,
|
| 981 |
+
"boxplot.boxprops.linewidth": validate_float,
|
| 982 |
+
"boxplot.boxprops.linestyle": _validate_linestyle,
|
| 983 |
+
|
| 984 |
+
"boxplot.whiskerprops.color": validate_color,
|
| 985 |
+
"boxplot.whiskerprops.linewidth": validate_float,
|
| 986 |
+
"boxplot.whiskerprops.linestyle": _validate_linestyle,
|
| 987 |
+
|
| 988 |
+
"boxplot.capprops.color": validate_color,
|
| 989 |
+
"boxplot.capprops.linewidth": validate_float,
|
| 990 |
+
"boxplot.capprops.linestyle": _validate_linestyle,
|
| 991 |
+
|
| 992 |
+
"boxplot.medianprops.color": validate_color,
|
| 993 |
+
"boxplot.medianprops.linewidth": validate_float,
|
| 994 |
+
"boxplot.medianprops.linestyle": _validate_linestyle,
|
| 995 |
+
|
| 996 |
+
"boxplot.meanprops.color": validate_color,
|
| 997 |
+
"boxplot.meanprops.marker": _validate_marker,
|
| 998 |
+
"boxplot.meanprops.markerfacecolor": validate_color,
|
| 999 |
+
"boxplot.meanprops.markeredgecolor": validate_color,
|
| 1000 |
+
"boxplot.meanprops.markersize": validate_float,
|
| 1001 |
+
"boxplot.meanprops.linestyle": _validate_linestyle,
|
| 1002 |
+
"boxplot.meanprops.linewidth": validate_float,
|
| 1003 |
+
|
| 1004 |
+
## font props
|
| 1005 |
+
"font.family": validate_stringlist, # used by text object
|
| 1006 |
+
"font.style": validate_string,
|
| 1007 |
+
"font.variant": validate_string,
|
| 1008 |
+
"font.stretch": validate_fontstretch,
|
| 1009 |
+
"font.weight": validate_fontweight,
|
| 1010 |
+
"font.size": validate_float, # Base font size in points
|
| 1011 |
+
"font.serif": validate_stringlist,
|
| 1012 |
+
"font.sans-serif": validate_stringlist,
|
| 1013 |
+
"font.cursive": validate_stringlist,
|
| 1014 |
+
"font.fantasy": validate_stringlist,
|
| 1015 |
+
"font.monospace": validate_stringlist,
|
| 1016 |
+
|
| 1017 |
+
# text props
|
| 1018 |
+
"text.color": validate_color,
|
| 1019 |
+
"text.usetex": validate_bool,
|
| 1020 |
+
"text.latex.preamble": validate_string,
|
| 1021 |
+
"text.hinting": ["default", "no_autohint", "force_autohint",
|
| 1022 |
+
"no_hinting", "auto", "native", "either", "none"],
|
| 1023 |
+
"text.hinting_factor": validate_int,
|
| 1024 |
+
"text.kerning_factor": validate_int,
|
| 1025 |
+
"text.antialiased": validate_bool,
|
| 1026 |
+
"text.parse_math": validate_bool,
|
| 1027 |
+
|
| 1028 |
+
"mathtext.cal": validate_font_properties,
|
| 1029 |
+
"mathtext.rm": validate_font_properties,
|
| 1030 |
+
"mathtext.tt": validate_font_properties,
|
| 1031 |
+
"mathtext.it": validate_font_properties,
|
| 1032 |
+
"mathtext.bf": validate_font_properties,
|
| 1033 |
+
"mathtext.bfit": validate_font_properties,
|
| 1034 |
+
"mathtext.sf": validate_font_properties,
|
| 1035 |
+
"mathtext.fontset": ["dejavusans", "dejavuserif", "cm", "stix",
|
| 1036 |
+
"stixsans", "custom"],
|
| 1037 |
+
"mathtext.default": ["rm", "cal", "bfit", "it", "tt", "sf", "bf", "default",
|
| 1038 |
+
"bb", "frak", "scr", "regular"],
|
| 1039 |
+
"mathtext.fallback": _validate_mathtext_fallback,
|
| 1040 |
+
|
| 1041 |
+
"image.aspect": validate_aspect, # equal, auto, a number
|
| 1042 |
+
"image.interpolation": validate_string,
|
| 1043 |
+
"image.interpolation_stage": ["auto", "data", "rgba"],
|
| 1044 |
+
"image.cmap": _validate_cmap, # gray, jet, etc.
|
| 1045 |
+
"image.lut": validate_int, # lookup table
|
| 1046 |
+
"image.origin": ["upper", "lower"],
|
| 1047 |
+
"image.resample": validate_bool,
|
| 1048 |
+
# Specify whether vector graphics backends will combine all images on a
|
| 1049 |
+
# set of Axes into a single composite image
|
| 1050 |
+
"image.composite_image": validate_bool,
|
| 1051 |
+
|
| 1052 |
+
# contour props
|
| 1053 |
+
"contour.negative_linestyle": _validate_linestyle,
|
| 1054 |
+
"contour.corner_mask": validate_bool,
|
| 1055 |
+
"contour.linewidth": validate_float_or_None,
|
| 1056 |
+
"contour.algorithm": ["mpl2005", "mpl2014", "serial", "threaded"],
|
| 1057 |
+
|
| 1058 |
+
# errorbar props
|
| 1059 |
+
"errorbar.capsize": validate_float,
|
| 1060 |
+
|
| 1061 |
+
# axis props
|
| 1062 |
+
# alignment of x/y axis title
|
| 1063 |
+
"xaxis.labellocation": ["left", "center", "right"],
|
| 1064 |
+
"yaxis.labellocation": ["bottom", "center", "top"],
|
| 1065 |
+
|
| 1066 |
+
# Axes props
|
| 1067 |
+
"axes.axisbelow": validate_axisbelow,
|
| 1068 |
+
"axes.facecolor": validate_color, # background color
|
| 1069 |
+
"axes.edgecolor": validate_color, # edge color
|
| 1070 |
+
"axes.linewidth": validate_float, # edge linewidth
|
| 1071 |
+
|
| 1072 |
+
"axes.spines.left": validate_bool, # Set visibility of axes spines,
|
| 1073 |
+
"axes.spines.right": validate_bool, # i.e., the lines around the chart
|
| 1074 |
+
"axes.spines.bottom": validate_bool, # denoting data boundary.
|
| 1075 |
+
"axes.spines.top": validate_bool,
|
| 1076 |
+
|
| 1077 |
+
"axes.titlesize": validate_fontsize, # Axes title fontsize
|
| 1078 |
+
"axes.titlelocation": ["left", "center", "right"], # Axes title alignment
|
| 1079 |
+
"axes.titleweight": validate_fontweight, # Axes title font weight
|
| 1080 |
+
"axes.titlecolor": validate_color_or_auto, # Axes title font color
|
| 1081 |
+
# title location, axes units, None means auto
|
| 1082 |
+
"axes.titley": validate_float_or_None,
|
| 1083 |
+
# pad from Axes top decoration to title in points
|
| 1084 |
+
"axes.titlepad": validate_float,
|
| 1085 |
+
"axes.grid": validate_bool, # display grid or not
|
| 1086 |
+
"axes.grid.which": ["minor", "both", "major"], # which grids are drawn
|
| 1087 |
+
"axes.grid.axis": ["x", "y", "both"], # grid type
|
| 1088 |
+
"axes.labelsize": validate_fontsize, # fontsize of x & y labels
|
| 1089 |
+
"axes.labelpad": validate_float, # space between label and axis
|
| 1090 |
+
"axes.labelweight": validate_fontweight, # fontsize of x & y labels
|
| 1091 |
+
"axes.labelcolor": validate_color, # color of axis label
|
| 1092 |
+
# use scientific notation if log10 of the axis range is smaller than the
|
| 1093 |
+
# first or larger than the second
|
| 1094 |
+
"axes.formatter.limits": _listify_validator(validate_int, n=2),
|
| 1095 |
+
# use current locale to format ticks
|
| 1096 |
+
"axes.formatter.use_locale": validate_bool,
|
| 1097 |
+
"axes.formatter.use_mathtext": validate_bool,
|
| 1098 |
+
# minimum exponent to format in scientific notation
|
| 1099 |
+
"axes.formatter.min_exponent": validate_int,
|
| 1100 |
+
"axes.formatter.useoffset": validate_bool,
|
| 1101 |
+
"axes.formatter.offset_threshold": validate_int,
|
| 1102 |
+
"axes.unicode_minus": validate_bool,
|
| 1103 |
+
# This entry can be either a cycler object or a string repr of a
|
| 1104 |
+
# cycler-object, which gets eval()'ed to create the object.
|
| 1105 |
+
"axes.prop_cycle": validate_cycler,
|
| 1106 |
+
# If "data", axes limits are set close to the data.
|
| 1107 |
+
# If "round_numbers" axes limits are set to the nearest round numbers.
|
| 1108 |
+
"axes.autolimit_mode": ["data", "round_numbers"],
|
| 1109 |
+
"axes.xmargin": _validate_greaterthan_minushalf, # margin added to xaxis
|
| 1110 |
+
"axes.ymargin": _validate_greaterthan_minushalf, # margin added to yaxis
|
| 1111 |
+
"axes.zmargin": _validate_greaterthan_minushalf, # margin added to zaxis
|
| 1112 |
+
|
| 1113 |
+
"polaraxes.grid": validate_bool, # display polar grid or not
|
| 1114 |
+
"axes3d.grid": validate_bool, # display 3d grid
|
| 1115 |
+
"axes3d.automargin": validate_bool, # automatically add margin when
|
| 1116 |
+
# manually setting 3D axis limits
|
| 1117 |
+
|
| 1118 |
+
"axes3d.xaxis.panecolor": validate_color, # 3d background pane
|
| 1119 |
+
"axes3d.yaxis.panecolor": validate_color, # 3d background pane
|
| 1120 |
+
"axes3d.zaxis.panecolor": validate_color, # 3d background pane
|
| 1121 |
+
|
| 1122 |
+
"axes3d.mouserotationstyle": ["azel", "trackball", "sphere", "arcball"],
|
| 1123 |
+
"axes3d.trackballsize": validate_float,
|
| 1124 |
+
"axes3d.trackballborder": validate_float,
|
| 1125 |
+
|
| 1126 |
+
# scatter props
|
| 1127 |
+
"scatter.marker": _validate_marker,
|
| 1128 |
+
"scatter.edgecolors": validate_string,
|
| 1129 |
+
|
| 1130 |
+
"date.epoch": _validate_date,
|
| 1131 |
+
"date.autoformatter.year": validate_string,
|
| 1132 |
+
"date.autoformatter.month": validate_string,
|
| 1133 |
+
"date.autoformatter.day": validate_string,
|
| 1134 |
+
"date.autoformatter.hour": validate_string,
|
| 1135 |
+
"date.autoformatter.minute": validate_string,
|
| 1136 |
+
"date.autoformatter.second": validate_string,
|
| 1137 |
+
"date.autoformatter.microsecond": validate_string,
|
| 1138 |
+
|
| 1139 |
+
'date.converter': ['auto', 'concise'],
|
| 1140 |
+
# for auto date locator, choose interval_multiples
|
| 1141 |
+
'date.interval_multiples': validate_bool,
|
| 1142 |
+
|
| 1143 |
+
# legend properties
|
| 1144 |
+
"legend.fancybox": validate_bool,
|
| 1145 |
+
"legend.loc": _validate_legend_loc,
|
| 1146 |
+
|
| 1147 |
+
# the number of points in the legend line
|
| 1148 |
+
"legend.numpoints": validate_int,
|
| 1149 |
+
# the number of points in the legend line for scatter
|
| 1150 |
+
"legend.scatterpoints": validate_int,
|
| 1151 |
+
"legend.fontsize": validate_fontsize,
|
| 1152 |
+
"legend.title_fontsize": validate_fontsize_None,
|
| 1153 |
+
# color of the legend
|
| 1154 |
+
"legend.labelcolor": _validate_color_or_linecolor,
|
| 1155 |
+
# the relative size of legend markers vs. original
|
| 1156 |
+
"legend.markerscale": validate_float,
|
| 1157 |
+
# using dict in rcParams not yet supported, so make sure it is bool
|
| 1158 |
+
"legend.shadow": validate_bool,
|
| 1159 |
+
# whether or not to draw a frame around legend
|
| 1160 |
+
"legend.frameon": validate_bool,
|
| 1161 |
+
# alpha value of the legend frame
|
| 1162 |
+
"legend.framealpha": validate_float_or_None,
|
| 1163 |
+
|
| 1164 |
+
## the following dimensions are in fraction of the font size
|
| 1165 |
+
"legend.borderpad": validate_float, # units are fontsize
|
| 1166 |
+
# the vertical space between the legend entries
|
| 1167 |
+
"legend.labelspacing": validate_float,
|
| 1168 |
+
# the length of the legend lines
|
| 1169 |
+
"legend.handlelength": validate_float,
|
| 1170 |
+
# the length of the legend lines
|
| 1171 |
+
"legend.handleheight": validate_float,
|
| 1172 |
+
# the space between the legend line and legend text
|
| 1173 |
+
"legend.handletextpad": validate_float,
|
| 1174 |
+
# the border between the Axes and legend edge
|
| 1175 |
+
"legend.borderaxespad": validate_float,
|
| 1176 |
+
# the border between the Axes and legend edge
|
| 1177 |
+
"legend.columnspacing": validate_float,
|
| 1178 |
+
"legend.facecolor": validate_color_or_inherit,
|
| 1179 |
+
"legend.edgecolor": validate_color_or_inherit,
|
| 1180 |
+
|
| 1181 |
+
# tick properties
|
| 1182 |
+
"xtick.top": validate_bool, # draw ticks on top side
|
| 1183 |
+
"xtick.bottom": validate_bool, # draw ticks on bottom side
|
| 1184 |
+
"xtick.labeltop": validate_bool, # draw label on top
|
| 1185 |
+
"xtick.labelbottom": validate_bool, # draw label on bottom
|
| 1186 |
+
"xtick.major.size": validate_float, # major xtick size in points
|
| 1187 |
+
"xtick.minor.size": validate_float, # minor xtick size in points
|
| 1188 |
+
"xtick.major.width": validate_float, # major xtick width in points
|
| 1189 |
+
"xtick.minor.width": validate_float, # minor xtick width in points
|
| 1190 |
+
"xtick.major.pad": validate_float, # distance to label in points
|
| 1191 |
+
"xtick.minor.pad": validate_float, # distance to label in points
|
| 1192 |
+
"xtick.color": validate_color, # color of xticks
|
| 1193 |
+
"xtick.labelcolor": validate_color_or_inherit, # color of xtick labels
|
| 1194 |
+
"xtick.minor.visible": validate_bool, # visibility of minor xticks
|
| 1195 |
+
"xtick.minor.top": validate_bool, # draw top minor xticks
|
| 1196 |
+
"xtick.minor.bottom": validate_bool, # draw bottom minor xticks
|
| 1197 |
+
"xtick.major.top": validate_bool, # draw top major xticks
|
| 1198 |
+
"xtick.major.bottom": validate_bool, # draw bottom major xticks
|
| 1199 |
+
# number of minor xticks
|
| 1200 |
+
"xtick.minor.ndivs": _validate_minor_tick_ndivs,
|
| 1201 |
+
"xtick.labelsize": validate_fontsize, # fontsize of xtick labels
|
| 1202 |
+
"xtick.direction": ["out", "in", "inout"], # direction of xticks
|
| 1203 |
+
"xtick.alignment": ["center", "right", "left"],
|
| 1204 |
+
|
| 1205 |
+
"ytick.left": validate_bool, # draw ticks on left side
|
| 1206 |
+
"ytick.right": validate_bool, # draw ticks on right side
|
| 1207 |
+
"ytick.labelleft": validate_bool, # draw tick labels on left side
|
| 1208 |
+
"ytick.labelright": validate_bool, # draw tick labels on right side
|
| 1209 |
+
"ytick.major.size": validate_float, # major ytick size in points
|
| 1210 |
+
"ytick.minor.size": validate_float, # minor ytick size in points
|
| 1211 |
+
"ytick.major.width": validate_float, # major ytick width in points
|
| 1212 |
+
"ytick.minor.width": validate_float, # minor ytick width in points
|
| 1213 |
+
"ytick.major.pad": validate_float, # distance to label in points
|
| 1214 |
+
"ytick.minor.pad": validate_float, # distance to label in points
|
| 1215 |
+
"ytick.color": validate_color, # color of yticks
|
| 1216 |
+
"ytick.labelcolor": validate_color_or_inherit, # color of ytick labels
|
| 1217 |
+
"ytick.minor.visible": validate_bool, # visibility of minor yticks
|
| 1218 |
+
"ytick.minor.left": validate_bool, # draw left minor yticks
|
| 1219 |
+
"ytick.minor.right": validate_bool, # draw right minor yticks
|
| 1220 |
+
"ytick.major.left": validate_bool, # draw left major yticks
|
| 1221 |
+
"ytick.major.right": validate_bool, # draw right major yticks
|
| 1222 |
+
# number of minor yticks
|
| 1223 |
+
"ytick.minor.ndivs": _validate_minor_tick_ndivs,
|
| 1224 |
+
"ytick.labelsize": validate_fontsize, # fontsize of ytick labels
|
| 1225 |
+
"ytick.direction": ["out", "in", "inout"], # direction of yticks
|
| 1226 |
+
"ytick.alignment": [
|
| 1227 |
+
"center", "top", "bottom", "baseline", "center_baseline"],
|
| 1228 |
+
|
| 1229 |
+
"grid.color": validate_color, # grid color
|
| 1230 |
+
"grid.linestyle": _validate_linestyle, # solid
|
| 1231 |
+
"grid.linewidth": validate_float, # in points
|
| 1232 |
+
"grid.alpha": validate_float,
|
| 1233 |
+
|
| 1234 |
+
## figure props
|
| 1235 |
+
# figure title
|
| 1236 |
+
"figure.titlesize": validate_fontsize,
|
| 1237 |
+
"figure.titleweight": validate_fontweight,
|
| 1238 |
+
|
| 1239 |
+
# figure labels
|
| 1240 |
+
"figure.labelsize": validate_fontsize,
|
| 1241 |
+
"figure.labelweight": validate_fontweight,
|
| 1242 |
+
|
| 1243 |
+
# figure size in inches: width by height
|
| 1244 |
+
"figure.figsize": _listify_validator(validate_float, n=2),
|
| 1245 |
+
"figure.dpi": validate_float,
|
| 1246 |
+
"figure.facecolor": validate_color,
|
| 1247 |
+
"figure.edgecolor": validate_color,
|
| 1248 |
+
"figure.frameon": validate_bool,
|
| 1249 |
+
"figure.autolayout": validate_bool,
|
| 1250 |
+
"figure.max_open_warning": validate_int,
|
| 1251 |
+
"figure.raise_window": validate_bool,
|
| 1252 |
+
"macosx.window_mode": ["system", "tab", "window"],
|
| 1253 |
+
|
| 1254 |
+
"figure.subplot.left": validate_float,
|
| 1255 |
+
"figure.subplot.right": validate_float,
|
| 1256 |
+
"figure.subplot.bottom": validate_float,
|
| 1257 |
+
"figure.subplot.top": validate_float,
|
| 1258 |
+
"figure.subplot.wspace": validate_float,
|
| 1259 |
+
"figure.subplot.hspace": validate_float,
|
| 1260 |
+
|
| 1261 |
+
"figure.constrained_layout.use": validate_bool, # run constrained_layout?
|
| 1262 |
+
# wspace and hspace are fraction of adjacent subplots to use for space.
|
| 1263 |
+
# Much smaller than above because we don't need room for the text.
|
| 1264 |
+
"figure.constrained_layout.hspace": validate_float,
|
| 1265 |
+
"figure.constrained_layout.wspace": validate_float,
|
| 1266 |
+
# buffer around the Axes, in inches.
|
| 1267 |
+
"figure.constrained_layout.h_pad": validate_float,
|
| 1268 |
+
"figure.constrained_layout.w_pad": validate_float,
|
| 1269 |
+
|
| 1270 |
+
## Saving figure's properties
|
| 1271 |
+
'savefig.dpi': validate_dpi,
|
| 1272 |
+
'savefig.facecolor': validate_color_or_auto,
|
| 1273 |
+
'savefig.edgecolor': validate_color_or_auto,
|
| 1274 |
+
'savefig.orientation': ['landscape', 'portrait'],
|
| 1275 |
+
"savefig.format": validate_string,
|
| 1276 |
+
"savefig.bbox": validate_bbox, # "tight", or "standard" (= None)
|
| 1277 |
+
"savefig.pad_inches": validate_float,
|
| 1278 |
+
# default directory in savefig dialog box
|
| 1279 |
+
"savefig.directory": _validate_pathlike,
|
| 1280 |
+
"savefig.transparent": validate_bool,
|
| 1281 |
+
|
| 1282 |
+
"tk.window_focus": validate_bool, # Maintain shell focus for TkAgg
|
| 1283 |
+
|
| 1284 |
+
# Set the papersize/type
|
| 1285 |
+
"ps.papersize": _ignorecase(
|
| 1286 |
+
["figure", "letter", "legal", "ledger",
|
| 1287 |
+
*[f"{ab}{i}" for ab in "ab" for i in range(11)]]),
|
| 1288 |
+
"ps.useafm": validate_bool,
|
| 1289 |
+
# use ghostscript or xpdf to distill ps output
|
| 1290 |
+
"ps.usedistiller": validate_ps_distiller,
|
| 1291 |
+
"ps.distiller.res": validate_int, # dpi
|
| 1292 |
+
"ps.fonttype": validate_fonttype, # 3 (Type3) or 42 (Truetype)
|
| 1293 |
+
"pdf.compression": validate_int, # 0-9 compression level; 0 to disable
|
| 1294 |
+
"pdf.inheritcolor": validate_bool, # skip color setting commands
|
| 1295 |
+
# use only the 14 PDF core fonts embedded in every PDF viewing application
|
| 1296 |
+
"pdf.use14corefonts": validate_bool,
|
| 1297 |
+
"pdf.fonttype": validate_fonttype, # 3 (Type3) or 42 (Truetype)
|
| 1298 |
+
|
| 1299 |
+
"pgf.texsystem": ["xelatex", "lualatex", "pdflatex"], # latex variant used
|
| 1300 |
+
"pgf.rcfonts": validate_bool, # use mpl's rc settings for font config
|
| 1301 |
+
"pgf.preamble": validate_string, # custom LaTeX preamble
|
| 1302 |
+
|
| 1303 |
+
# write raster image data into the svg file
|
| 1304 |
+
"svg.image_inline": validate_bool,
|
| 1305 |
+
"svg.fonttype": ["none", "path"], # save text as text ("none") or "paths"
|
| 1306 |
+
"svg.hashsalt": validate_string_or_None,
|
| 1307 |
+
"svg.id": validate_string_or_None,
|
| 1308 |
+
|
| 1309 |
+
# set this when you want to generate hardcopy docstring
|
| 1310 |
+
"docstring.hardcopy": validate_bool,
|
| 1311 |
+
|
| 1312 |
+
"path.simplify": validate_bool,
|
| 1313 |
+
"path.simplify_threshold": _validate_greaterequal0_lessequal1,
|
| 1314 |
+
"path.snap": validate_bool,
|
| 1315 |
+
"path.sketch": validate_sketch,
|
| 1316 |
+
"path.effects": validate_anylist,
|
| 1317 |
+
"agg.path.chunksize": validate_int, # 0 to disable chunking
|
| 1318 |
+
|
| 1319 |
+
# key-mappings (multi-character mappings should be a list/tuple)
|
| 1320 |
+
"keymap.fullscreen": validate_stringlist,
|
| 1321 |
+
"keymap.home": validate_stringlist,
|
| 1322 |
+
"keymap.back": validate_stringlist,
|
| 1323 |
+
"keymap.forward": validate_stringlist,
|
| 1324 |
+
"keymap.pan": validate_stringlist,
|
| 1325 |
+
"keymap.zoom": validate_stringlist,
|
| 1326 |
+
"keymap.save": validate_stringlist,
|
| 1327 |
+
"keymap.quit": validate_stringlist,
|
| 1328 |
+
"keymap.quit_all": validate_stringlist, # e.g.: "W", "cmd+W", "Q"
|
| 1329 |
+
"keymap.grid": validate_stringlist,
|
| 1330 |
+
"keymap.grid_minor": validate_stringlist,
|
| 1331 |
+
"keymap.yscale": validate_stringlist,
|
| 1332 |
+
"keymap.xscale": validate_stringlist,
|
| 1333 |
+
"keymap.help": validate_stringlist,
|
| 1334 |
+
"keymap.copy": validate_stringlist,
|
| 1335 |
+
|
| 1336 |
+
# Animation settings
|
| 1337 |
+
"animation.html": ["html5", "jshtml", "none"],
|
| 1338 |
+
# Limit, in MB, of size of base64 encoded animation in HTML
|
| 1339 |
+
# (i.e. IPython notebook)
|
| 1340 |
+
"animation.embed_limit": validate_float,
|
| 1341 |
+
"animation.writer": validate_string,
|
| 1342 |
+
"animation.codec": validate_string,
|
| 1343 |
+
"animation.bitrate": validate_int,
|
| 1344 |
+
# Controls image format when frames are written to disk
|
| 1345 |
+
"animation.frame_format": ["png", "jpeg", "tiff", "raw", "rgba", "ppm",
|
| 1346 |
+
"sgi", "bmp", "pbm", "svg"],
|
| 1347 |
+
# Path to ffmpeg binary. If just binary name, subprocess uses $PATH.
|
| 1348 |
+
"animation.ffmpeg_path": _validate_pathlike,
|
| 1349 |
+
# Additional arguments for ffmpeg movie writer (using pipes)
|
| 1350 |
+
"animation.ffmpeg_args": validate_stringlist,
|
| 1351 |
+
# Path to convert binary. If just binary name, subprocess uses $PATH.
|
| 1352 |
+
"animation.convert_path": _validate_pathlike,
|
| 1353 |
+
# Additional arguments for convert movie writer (using pipes)
|
| 1354 |
+
"animation.convert_args": validate_stringlist,
|
| 1355 |
+
|
| 1356 |
+
# Classic (pre 2.0) compatibility mode
|
| 1357 |
+
# This is used for things that are hard to make backward compatible
|
| 1358 |
+
# with a sane rcParam alone. This does *not* turn on classic mode
|
| 1359 |
+
# altogether. For that use `matplotlib.style.use("classic")`.
|
| 1360 |
+
"_internal.classic_mode": validate_bool
|
| 1361 |
+
}
|
| 1362 |
+
_hardcoded_defaults = { # Defaults not inferred from
|
| 1363 |
+
# lib/matplotlib/mpl-data/matplotlibrc...
|
| 1364 |
+
# ... because they are private:
|
| 1365 |
+
"_internal.classic_mode": False,
|
| 1366 |
+
# ... because they are deprecated:
|
| 1367 |
+
# No current deprecations.
|
| 1368 |
+
# backend is handled separately when constructing rcParamsDefault.
|
| 1369 |
+
}
|
| 1370 |
+
_validators = {k: _convert_validator_spec(k, conv)
|
| 1371 |
+
for k, conv in _validators.items()}
|
llava_video/lib/python3.10/site-packages/matplotlib/sankey.py
ADDED
|
@@ -0,0 +1,814 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Module for creating Sankey diagrams using Matplotlib.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import logging
|
| 6 |
+
from types import SimpleNamespace
|
| 7 |
+
|
| 8 |
+
import numpy as np
|
| 9 |
+
|
| 10 |
+
import matplotlib as mpl
|
| 11 |
+
from matplotlib.path import Path
|
| 12 |
+
from matplotlib.patches import PathPatch
|
| 13 |
+
from matplotlib.transforms import Affine2D
|
| 14 |
+
from matplotlib import _docstring
|
| 15 |
+
|
| 16 |
+
_log = logging.getLogger(__name__)
|
| 17 |
+
|
| 18 |
+
__author__ = "Kevin L. Davies"
|
| 19 |
+
__credits__ = ["Yannick Copin"]
|
| 20 |
+
__license__ = "BSD"
|
| 21 |
+
__version__ = "2011/09/16"
|
| 22 |
+
|
| 23 |
+
# Angles [deg/90]
|
| 24 |
+
RIGHT = 0
|
| 25 |
+
UP = 1
|
| 26 |
+
# LEFT = 2
|
| 27 |
+
DOWN = 3
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
class Sankey:
|
| 31 |
+
"""
|
| 32 |
+
Sankey diagram.
|
| 33 |
+
|
| 34 |
+
Sankey diagrams are a specific type of flow diagram, in which
|
| 35 |
+
the width of the arrows is shown proportionally to the flow
|
| 36 |
+
quantity. They are typically used to visualize energy or
|
| 37 |
+
material or cost transfers between processes.
|
| 38 |
+
`Wikipedia (6/1/2011) <https://en.wikipedia.org/wiki/Sankey_diagram>`_
|
| 39 |
+
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25,
|
| 43 |
+
radius=0.1, shoulder=0.03, offset=0.15, head_angle=100,
|
| 44 |
+
margin=0.4, tolerance=1e-6, **kwargs):
|
| 45 |
+
"""
|
| 46 |
+
Create a new Sankey instance.
|
| 47 |
+
|
| 48 |
+
The optional arguments listed below are applied to all subdiagrams so
|
| 49 |
+
that there is consistent alignment and formatting.
|
| 50 |
+
|
| 51 |
+
In order to draw a complex Sankey diagram, create an instance of
|
| 52 |
+
`Sankey` by calling it without any kwargs::
|
| 53 |
+
|
| 54 |
+
sankey = Sankey()
|
| 55 |
+
|
| 56 |
+
Then add simple Sankey sub-diagrams::
|
| 57 |
+
|
| 58 |
+
sankey.add() # 1
|
| 59 |
+
sankey.add() # 2
|
| 60 |
+
#...
|
| 61 |
+
sankey.add() # n
|
| 62 |
+
|
| 63 |
+
Finally, create the full diagram::
|
| 64 |
+
|
| 65 |
+
sankey.finish()
|
| 66 |
+
|
| 67 |
+
Or, instead, simply daisy-chain those calls::
|
| 68 |
+
|
| 69 |
+
Sankey().add().add... .add().finish()
|
| 70 |
+
|
| 71 |
+
Other Parameters
|
| 72 |
+
----------------
|
| 73 |
+
ax : `~matplotlib.axes.Axes`
|
| 74 |
+
Axes onto which the data should be plotted. If *ax* isn't
|
| 75 |
+
provided, new Axes will be created.
|
| 76 |
+
scale : float
|
| 77 |
+
Scaling factor for the flows. *scale* sizes the width of the paths
|
| 78 |
+
in order to maintain proper layout. The same scale is applied to
|
| 79 |
+
all subdiagrams. The value should be chosen such that the product
|
| 80 |
+
of the scale and the sum of the inputs is approximately 1.0 (and
|
| 81 |
+
the product of the scale and the sum of the outputs is
|
| 82 |
+
approximately -1.0).
|
| 83 |
+
unit : str
|
| 84 |
+
The physical unit associated with the flow quantities. If *unit*
|
| 85 |
+
is None, then none of the quantities are labeled.
|
| 86 |
+
format : str or callable
|
| 87 |
+
A Python number formatting string or callable used to label the
|
| 88 |
+
flows with their quantities (i.e., a number times a unit, where the
|
| 89 |
+
unit is given). If a format string is given, the label will be
|
| 90 |
+
``format % quantity``. If a callable is given, it will be called
|
| 91 |
+
with ``quantity`` as an argument.
|
| 92 |
+
gap : float
|
| 93 |
+
Space between paths that break in/break away to/from the top or
|
| 94 |
+
bottom.
|
| 95 |
+
radius : float
|
| 96 |
+
Inner radius of the vertical paths.
|
| 97 |
+
shoulder : float
|
| 98 |
+
Size of the shoulders of output arrows.
|
| 99 |
+
offset : float
|
| 100 |
+
Text offset (from the dip or tip of the arrow).
|
| 101 |
+
head_angle : float
|
| 102 |
+
Angle, in degrees, of the arrow heads (and negative of the angle of
|
| 103 |
+
the tails).
|
| 104 |
+
margin : float
|
| 105 |
+
Minimum space between Sankey outlines and the edge of the plot
|
| 106 |
+
area.
|
| 107 |
+
tolerance : float
|
| 108 |
+
Acceptable maximum of the magnitude of the sum of flows. The
|
| 109 |
+
magnitude of the sum of connected flows cannot be greater than
|
| 110 |
+
*tolerance*.
|
| 111 |
+
**kwargs
|
| 112 |
+
Any additional keyword arguments will be passed to `add`, which
|
| 113 |
+
will create the first subdiagram.
|
| 114 |
+
|
| 115 |
+
See Also
|
| 116 |
+
--------
|
| 117 |
+
Sankey.add
|
| 118 |
+
Sankey.finish
|
| 119 |
+
|
| 120 |
+
Examples
|
| 121 |
+
--------
|
| 122 |
+
.. plot:: gallery/specialty_plots/sankey_basics.py
|
| 123 |
+
"""
|
| 124 |
+
# Check the arguments.
|
| 125 |
+
if gap < 0:
|
| 126 |
+
raise ValueError(
|
| 127 |
+
"'gap' is negative, which is not allowed because it would "
|
| 128 |
+
"cause the paths to overlap")
|
| 129 |
+
if radius > gap:
|
| 130 |
+
raise ValueError(
|
| 131 |
+
"'radius' is greater than 'gap', which is not allowed because "
|
| 132 |
+
"it would cause the paths to overlap")
|
| 133 |
+
if head_angle < 0:
|
| 134 |
+
raise ValueError(
|
| 135 |
+
"'head_angle' is negative, which is not allowed because it "
|
| 136 |
+
"would cause inputs to look like outputs and vice versa")
|
| 137 |
+
if tolerance < 0:
|
| 138 |
+
raise ValueError(
|
| 139 |
+
"'tolerance' is negative, but it must be a magnitude")
|
| 140 |
+
|
| 141 |
+
# Create Axes if necessary.
|
| 142 |
+
if ax is None:
|
| 143 |
+
import matplotlib.pyplot as plt
|
| 144 |
+
fig = plt.figure()
|
| 145 |
+
ax = fig.add_subplot(1, 1, 1, xticks=[], yticks=[])
|
| 146 |
+
|
| 147 |
+
self.diagrams = []
|
| 148 |
+
|
| 149 |
+
# Store the inputs.
|
| 150 |
+
self.ax = ax
|
| 151 |
+
self.unit = unit
|
| 152 |
+
self.format = format
|
| 153 |
+
self.scale = scale
|
| 154 |
+
self.gap = gap
|
| 155 |
+
self.radius = radius
|
| 156 |
+
self.shoulder = shoulder
|
| 157 |
+
self.offset = offset
|
| 158 |
+
self.margin = margin
|
| 159 |
+
self.pitch = np.tan(np.pi * (1 - head_angle / 180.0) / 2.0)
|
| 160 |
+
self.tolerance = tolerance
|
| 161 |
+
|
| 162 |
+
# Initialize the vertices of tight box around the diagram(s).
|
| 163 |
+
self.extent = np.array((np.inf, -np.inf, np.inf, -np.inf))
|
| 164 |
+
|
| 165 |
+
# If there are any kwargs, create the first subdiagram.
|
| 166 |
+
if len(kwargs):
|
| 167 |
+
self.add(**kwargs)
|
| 168 |
+
|
| 169 |
+
def _arc(self, quadrant=0, cw=True, radius=1, center=(0, 0)):
|
| 170 |
+
"""
|
| 171 |
+
Return the codes and vertices for a rotated, scaled, and translated
|
| 172 |
+
90 degree arc.
|
| 173 |
+
|
| 174 |
+
Other Parameters
|
| 175 |
+
----------------
|
| 176 |
+
quadrant : {0, 1, 2, 3}, default: 0
|
| 177 |
+
Uses 0-based indexing (0, 1, 2, or 3).
|
| 178 |
+
cw : bool, default: True
|
| 179 |
+
If True, the arc vertices are produced clockwise; counter-clockwise
|
| 180 |
+
otherwise.
|
| 181 |
+
radius : float, default: 1
|
| 182 |
+
The radius of the arc.
|
| 183 |
+
center : (float, float), default: (0, 0)
|
| 184 |
+
(x, y) tuple of the arc's center.
|
| 185 |
+
"""
|
| 186 |
+
# Note: It would be possible to use matplotlib's transforms to rotate,
|
| 187 |
+
# scale, and translate the arc, but since the angles are discrete,
|
| 188 |
+
# it's just as easy and maybe more efficient to do it here.
|
| 189 |
+
ARC_CODES = [Path.LINETO,
|
| 190 |
+
Path.CURVE4,
|
| 191 |
+
Path.CURVE4,
|
| 192 |
+
Path.CURVE4,
|
| 193 |
+
Path.CURVE4,
|
| 194 |
+
Path.CURVE4,
|
| 195 |
+
Path.CURVE4]
|
| 196 |
+
# Vertices of a cubic Bezier curve approximating a 90 deg arc
|
| 197 |
+
# These can be determined by Path.arc(0, 90).
|
| 198 |
+
ARC_VERTICES = np.array([[1.00000000e+00, 0.00000000e+00],
|
| 199 |
+
[1.00000000e+00, 2.65114773e-01],
|
| 200 |
+
[8.94571235e-01, 5.19642327e-01],
|
| 201 |
+
[7.07106781e-01, 7.07106781e-01],
|
| 202 |
+
[5.19642327e-01, 8.94571235e-01],
|
| 203 |
+
[2.65114773e-01, 1.00000000e+00],
|
| 204 |
+
# Insignificant
|
| 205 |
+
# [6.12303177e-17, 1.00000000e+00]])
|
| 206 |
+
[0.00000000e+00, 1.00000000e+00]])
|
| 207 |
+
if quadrant in (0, 2):
|
| 208 |
+
if cw:
|
| 209 |
+
vertices = ARC_VERTICES
|
| 210 |
+
else:
|
| 211 |
+
vertices = ARC_VERTICES[:, ::-1] # Swap x and y.
|
| 212 |
+
else: # 1, 3
|
| 213 |
+
# Negate x.
|
| 214 |
+
if cw:
|
| 215 |
+
# Swap x and y.
|
| 216 |
+
vertices = np.column_stack((-ARC_VERTICES[:, 1],
|
| 217 |
+
ARC_VERTICES[:, 0]))
|
| 218 |
+
else:
|
| 219 |
+
vertices = np.column_stack((-ARC_VERTICES[:, 0],
|
| 220 |
+
ARC_VERTICES[:, 1]))
|
| 221 |
+
if quadrant > 1:
|
| 222 |
+
radius = -radius # Rotate 180 deg.
|
| 223 |
+
return list(zip(ARC_CODES, radius * vertices +
|
| 224 |
+
np.tile(center, (ARC_VERTICES.shape[0], 1))))
|
| 225 |
+
|
| 226 |
+
def _add_input(self, path, angle, flow, length):
|
| 227 |
+
"""
|
| 228 |
+
Add an input to a path and return its tip and label locations.
|
| 229 |
+
"""
|
| 230 |
+
if angle is None:
|
| 231 |
+
return [0, 0], [0, 0]
|
| 232 |
+
else:
|
| 233 |
+
x, y = path[-1][1] # Use the last point as a reference.
|
| 234 |
+
dipdepth = (flow / 2) * self.pitch
|
| 235 |
+
if angle == RIGHT:
|
| 236 |
+
x -= length
|
| 237 |
+
dip = [x + dipdepth, y + flow / 2.0]
|
| 238 |
+
path.extend([(Path.LINETO, [x, y]),
|
| 239 |
+
(Path.LINETO, dip),
|
| 240 |
+
(Path.LINETO, [x, y + flow]),
|
| 241 |
+
(Path.LINETO, [x + self.gap, y + flow])])
|
| 242 |
+
label_location = [dip[0] - self.offset, dip[1]]
|
| 243 |
+
else: # Vertical
|
| 244 |
+
x -= self.gap
|
| 245 |
+
if angle == UP:
|
| 246 |
+
sign = 1
|
| 247 |
+
else:
|
| 248 |
+
sign = -1
|
| 249 |
+
|
| 250 |
+
dip = [x - flow / 2, y - sign * (length - dipdepth)]
|
| 251 |
+
if angle == DOWN:
|
| 252 |
+
quadrant = 2
|
| 253 |
+
else:
|
| 254 |
+
quadrant = 1
|
| 255 |
+
|
| 256 |
+
# Inner arc isn't needed if inner radius is zero
|
| 257 |
+
if self.radius:
|
| 258 |
+
path.extend(self._arc(quadrant=quadrant,
|
| 259 |
+
cw=angle == UP,
|
| 260 |
+
radius=self.radius,
|
| 261 |
+
center=(x + self.radius,
|
| 262 |
+
y - sign * self.radius)))
|
| 263 |
+
else:
|
| 264 |
+
path.append((Path.LINETO, [x, y]))
|
| 265 |
+
path.extend([(Path.LINETO, [x, y - sign * length]),
|
| 266 |
+
(Path.LINETO, dip),
|
| 267 |
+
(Path.LINETO, [x - flow, y - sign * length])])
|
| 268 |
+
path.extend(self._arc(quadrant=quadrant,
|
| 269 |
+
cw=angle == DOWN,
|
| 270 |
+
radius=flow + self.radius,
|
| 271 |
+
center=(x + self.radius,
|
| 272 |
+
y - sign * self.radius)))
|
| 273 |
+
path.append((Path.LINETO, [x - flow, y + sign * flow]))
|
| 274 |
+
label_location = [dip[0], dip[1] - sign * self.offset]
|
| 275 |
+
|
| 276 |
+
return dip, label_location
|
| 277 |
+
|
| 278 |
+
def _add_output(self, path, angle, flow, length):
|
| 279 |
+
"""
|
| 280 |
+
Append an output to a path and return its tip and label locations.
|
| 281 |
+
|
| 282 |
+
.. note:: *flow* is negative for an output.
|
| 283 |
+
"""
|
| 284 |
+
if angle is None:
|
| 285 |
+
return [0, 0], [0, 0]
|
| 286 |
+
else:
|
| 287 |
+
x, y = path[-1][1] # Use the last point as a reference.
|
| 288 |
+
tipheight = (self.shoulder - flow / 2) * self.pitch
|
| 289 |
+
if angle == RIGHT:
|
| 290 |
+
x += length
|
| 291 |
+
tip = [x + tipheight, y + flow / 2.0]
|
| 292 |
+
path.extend([(Path.LINETO, [x, y]),
|
| 293 |
+
(Path.LINETO, [x, y + self.shoulder]),
|
| 294 |
+
(Path.LINETO, tip),
|
| 295 |
+
(Path.LINETO, [x, y - self.shoulder + flow]),
|
| 296 |
+
(Path.LINETO, [x, y + flow]),
|
| 297 |
+
(Path.LINETO, [x - self.gap, y + flow])])
|
| 298 |
+
label_location = [tip[0] + self.offset, tip[1]]
|
| 299 |
+
else: # Vertical
|
| 300 |
+
x += self.gap
|
| 301 |
+
if angle == UP:
|
| 302 |
+
sign, quadrant = 1, 3
|
| 303 |
+
else:
|
| 304 |
+
sign, quadrant = -1, 0
|
| 305 |
+
|
| 306 |
+
tip = [x - flow / 2.0, y + sign * (length + tipheight)]
|
| 307 |
+
# Inner arc isn't needed if inner radius is zero
|
| 308 |
+
if self.radius:
|
| 309 |
+
path.extend(self._arc(quadrant=quadrant,
|
| 310 |
+
cw=angle == UP,
|
| 311 |
+
radius=self.radius,
|
| 312 |
+
center=(x - self.radius,
|
| 313 |
+
y + sign * self.radius)))
|
| 314 |
+
else:
|
| 315 |
+
path.append((Path.LINETO, [x, y]))
|
| 316 |
+
path.extend([(Path.LINETO, [x, y + sign * length]),
|
| 317 |
+
(Path.LINETO, [x - self.shoulder,
|
| 318 |
+
y + sign * length]),
|
| 319 |
+
(Path.LINETO, tip),
|
| 320 |
+
(Path.LINETO, [x + self.shoulder - flow,
|
| 321 |
+
y + sign * length]),
|
| 322 |
+
(Path.LINETO, [x - flow, y + sign * length])])
|
| 323 |
+
path.extend(self._arc(quadrant=quadrant,
|
| 324 |
+
cw=angle == DOWN,
|
| 325 |
+
radius=self.radius - flow,
|
| 326 |
+
center=(x - self.radius,
|
| 327 |
+
y + sign * self.radius)))
|
| 328 |
+
path.append((Path.LINETO, [x - flow, y + sign * flow]))
|
| 329 |
+
label_location = [tip[0], tip[1] + sign * self.offset]
|
| 330 |
+
return tip, label_location
|
| 331 |
+
|
| 332 |
+
def _revert(self, path, first_action=Path.LINETO):
|
| 333 |
+
"""
|
| 334 |
+
A path is not simply reversible by path[::-1] since the code
|
| 335 |
+
specifies an action to take from the **previous** point.
|
| 336 |
+
"""
|
| 337 |
+
reverse_path = []
|
| 338 |
+
next_code = first_action
|
| 339 |
+
for code, position in path[::-1]:
|
| 340 |
+
reverse_path.append((next_code, position))
|
| 341 |
+
next_code = code
|
| 342 |
+
return reverse_path
|
| 343 |
+
# This might be more efficient, but it fails because 'tuple' object
|
| 344 |
+
# doesn't support item assignment:
|
| 345 |
+
# path[1] = path[1][-1:0:-1]
|
| 346 |
+
# path[1][0] = first_action
|
| 347 |
+
# path[2] = path[2][::-1]
|
| 348 |
+
# return path
|
| 349 |
+
|
| 350 |
+
@_docstring.interpd
|
| 351 |
+
def add(self, patchlabel='', flows=None, orientations=None, labels='',
|
| 352 |
+
trunklength=1.0, pathlengths=0.25, prior=None, connect=(0, 0),
|
| 353 |
+
rotation=0, **kwargs):
|
| 354 |
+
"""
|
| 355 |
+
Add a simple Sankey diagram with flows at the same hierarchical level.
|
| 356 |
+
|
| 357 |
+
Parameters
|
| 358 |
+
----------
|
| 359 |
+
patchlabel : str
|
| 360 |
+
Label to be placed at the center of the diagram.
|
| 361 |
+
Note that *label* (not *patchlabel*) can be passed as keyword
|
| 362 |
+
argument to create an entry in the legend.
|
| 363 |
+
|
| 364 |
+
flows : list of float
|
| 365 |
+
Array of flow values. By convention, inputs are positive and
|
| 366 |
+
outputs are negative.
|
| 367 |
+
|
| 368 |
+
Flows are placed along the top of the diagram from the inside out
|
| 369 |
+
in order of their index within *flows*. They are placed along the
|
| 370 |
+
sides of the diagram from the top down and along the bottom from
|
| 371 |
+
the outside in.
|
| 372 |
+
|
| 373 |
+
If the sum of the inputs and outputs is
|
| 374 |
+
nonzero, the discrepancy will appear as a cubic Bézier curve along
|
| 375 |
+
the top and bottom edges of the trunk.
|
| 376 |
+
|
| 377 |
+
orientations : list of {-1, 0, 1}
|
| 378 |
+
List of orientations of the flows (or a single orientation to be
|
| 379 |
+
used for all flows). Valid values are 0 (inputs from
|
| 380 |
+
the left, outputs to the right), 1 (from and to the top) or -1
|
| 381 |
+
(from and to the bottom).
|
| 382 |
+
|
| 383 |
+
labels : list of (str or None)
|
| 384 |
+
List of labels for the flows (or a single label to be used for all
|
| 385 |
+
flows). Each label may be *None* (no label), or a labeling string.
|
| 386 |
+
If an entry is a (possibly empty) string, then the quantity for the
|
| 387 |
+
corresponding flow will be shown below the string. However, if
|
| 388 |
+
the *unit* of the main diagram is None, then quantities are never
|
| 389 |
+
shown, regardless of the value of this argument.
|
| 390 |
+
|
| 391 |
+
trunklength : float
|
| 392 |
+
Length between the bases of the input and output groups (in
|
| 393 |
+
data-space units).
|
| 394 |
+
|
| 395 |
+
pathlengths : list of float
|
| 396 |
+
List of lengths of the vertical arrows before break-in or after
|
| 397 |
+
break-away. If a single value is given, then it will be applied to
|
| 398 |
+
the first (inside) paths on the top and bottom, and the length of
|
| 399 |
+
all other arrows will be justified accordingly. The *pathlengths*
|
| 400 |
+
are not applied to the horizontal inputs and outputs.
|
| 401 |
+
|
| 402 |
+
prior : int
|
| 403 |
+
Index of the prior diagram to which this diagram should be
|
| 404 |
+
connected.
|
| 405 |
+
|
| 406 |
+
connect : (int, int)
|
| 407 |
+
A (prior, this) tuple indexing the flow of the prior diagram and
|
| 408 |
+
the flow of this diagram which should be connected. If this is the
|
| 409 |
+
first diagram or *prior* is *None*, *connect* will be ignored.
|
| 410 |
+
|
| 411 |
+
rotation : float
|
| 412 |
+
Angle of rotation of the diagram in degrees. The interpretation of
|
| 413 |
+
the *orientations* argument will be rotated accordingly (e.g., if
|
| 414 |
+
*rotation* == 90, an *orientations* entry of 1 means to/from the
|
| 415 |
+
left). *rotation* is ignored if this diagram is connected to an
|
| 416 |
+
existing one (using *prior* and *connect*).
|
| 417 |
+
|
| 418 |
+
Returns
|
| 419 |
+
-------
|
| 420 |
+
Sankey
|
| 421 |
+
The current `.Sankey` instance.
|
| 422 |
+
|
| 423 |
+
Other Parameters
|
| 424 |
+
----------------
|
| 425 |
+
**kwargs
|
| 426 |
+
Additional keyword arguments set `matplotlib.patches.PathPatch`
|
| 427 |
+
properties, listed below. For example, one may want to use
|
| 428 |
+
``fill=False`` or ``label="A legend entry"``.
|
| 429 |
+
|
| 430 |
+
%(Patch:kwdoc)s
|
| 431 |
+
|
| 432 |
+
See Also
|
| 433 |
+
--------
|
| 434 |
+
Sankey.finish
|
| 435 |
+
"""
|
| 436 |
+
# Check and preprocess the arguments.
|
| 437 |
+
flows = np.array([1.0, -1.0]) if flows is None else np.array(flows)
|
| 438 |
+
n = flows.shape[0] # Number of flows
|
| 439 |
+
if rotation is None:
|
| 440 |
+
rotation = 0
|
| 441 |
+
else:
|
| 442 |
+
# In the code below, angles are expressed in deg/90.
|
| 443 |
+
rotation /= 90.0
|
| 444 |
+
if orientations is None:
|
| 445 |
+
orientations = 0
|
| 446 |
+
try:
|
| 447 |
+
orientations = np.broadcast_to(orientations, n)
|
| 448 |
+
except ValueError:
|
| 449 |
+
raise ValueError(
|
| 450 |
+
f"The shapes of 'flows' {np.shape(flows)} and 'orientations' "
|
| 451 |
+
f"{np.shape(orientations)} are incompatible"
|
| 452 |
+
) from None
|
| 453 |
+
try:
|
| 454 |
+
labels = np.broadcast_to(labels, n)
|
| 455 |
+
except ValueError:
|
| 456 |
+
raise ValueError(
|
| 457 |
+
f"The shapes of 'flows' {np.shape(flows)} and 'labels' "
|
| 458 |
+
f"{np.shape(labels)} are incompatible"
|
| 459 |
+
) from None
|
| 460 |
+
if trunklength < 0:
|
| 461 |
+
raise ValueError(
|
| 462 |
+
"'trunklength' is negative, which is not allowed because it "
|
| 463 |
+
"would cause poor layout")
|
| 464 |
+
if abs(np.sum(flows)) > self.tolerance:
|
| 465 |
+
_log.info("The sum of the flows is nonzero (%f; patchlabel=%r); "
|
| 466 |
+
"is the system not at steady state?",
|
| 467 |
+
np.sum(flows), patchlabel)
|
| 468 |
+
scaled_flows = self.scale * flows
|
| 469 |
+
gain = sum(max(flow, 0) for flow in scaled_flows)
|
| 470 |
+
loss = sum(min(flow, 0) for flow in scaled_flows)
|
| 471 |
+
if prior is not None:
|
| 472 |
+
if prior < 0:
|
| 473 |
+
raise ValueError("The index of the prior diagram is negative")
|
| 474 |
+
if min(connect) < 0:
|
| 475 |
+
raise ValueError(
|
| 476 |
+
"At least one of the connection indices is negative")
|
| 477 |
+
if prior >= len(self.diagrams):
|
| 478 |
+
raise ValueError(
|
| 479 |
+
f"The index of the prior diagram is {prior}, but there "
|
| 480 |
+
f"are only {len(self.diagrams)} other diagrams")
|
| 481 |
+
if connect[0] >= len(self.diagrams[prior].flows):
|
| 482 |
+
raise ValueError(
|
| 483 |
+
"The connection index to the source diagram is {}, but "
|
| 484 |
+
"that diagram has only {} flows".format(
|
| 485 |
+
connect[0], len(self.diagrams[prior].flows)))
|
| 486 |
+
if connect[1] >= n:
|
| 487 |
+
raise ValueError(
|
| 488 |
+
f"The connection index to this diagram is {connect[1]}, "
|
| 489 |
+
f"but this diagram has only {n} flows")
|
| 490 |
+
if self.diagrams[prior].angles[connect[0]] is None:
|
| 491 |
+
raise ValueError(
|
| 492 |
+
f"The connection cannot be made, which may occur if the "
|
| 493 |
+
f"magnitude of flow {connect[0]} of diagram {prior} is "
|
| 494 |
+
f"less than the specified tolerance")
|
| 495 |
+
flow_error = (self.diagrams[prior].flows[connect[0]] +
|
| 496 |
+
flows[connect[1]])
|
| 497 |
+
if abs(flow_error) >= self.tolerance:
|
| 498 |
+
raise ValueError(
|
| 499 |
+
f"The scaled sum of the connected flows is {flow_error}, "
|
| 500 |
+
f"which is not within the tolerance ({self.tolerance})")
|
| 501 |
+
|
| 502 |
+
# Determine if the flows are inputs.
|
| 503 |
+
are_inputs = [None] * n
|
| 504 |
+
for i, flow in enumerate(flows):
|
| 505 |
+
if flow >= self.tolerance:
|
| 506 |
+
are_inputs[i] = True
|
| 507 |
+
elif flow <= -self.tolerance:
|
| 508 |
+
are_inputs[i] = False
|
| 509 |
+
else:
|
| 510 |
+
_log.info(
|
| 511 |
+
"The magnitude of flow %d (%f) is below the tolerance "
|
| 512 |
+
"(%f).\nIt will not be shown, and it cannot be used in a "
|
| 513 |
+
"connection.", i, flow, self.tolerance)
|
| 514 |
+
|
| 515 |
+
# Determine the angles of the arrows (before rotation).
|
| 516 |
+
angles = [None] * n
|
| 517 |
+
for i, (orient, is_input) in enumerate(zip(orientations, are_inputs)):
|
| 518 |
+
if orient == 1:
|
| 519 |
+
if is_input:
|
| 520 |
+
angles[i] = DOWN
|
| 521 |
+
elif is_input is False:
|
| 522 |
+
# Be specific since is_input can be None.
|
| 523 |
+
angles[i] = UP
|
| 524 |
+
elif orient == 0:
|
| 525 |
+
if is_input is not None:
|
| 526 |
+
angles[i] = RIGHT
|
| 527 |
+
else:
|
| 528 |
+
if orient != -1:
|
| 529 |
+
raise ValueError(
|
| 530 |
+
f"The value of orientations[{i}] is {orient}, "
|
| 531 |
+
f"but it must be -1, 0, or 1")
|
| 532 |
+
if is_input:
|
| 533 |
+
angles[i] = UP
|
| 534 |
+
elif is_input is False:
|
| 535 |
+
angles[i] = DOWN
|
| 536 |
+
|
| 537 |
+
# Justify the lengths of the paths.
|
| 538 |
+
if np.iterable(pathlengths):
|
| 539 |
+
if len(pathlengths) != n:
|
| 540 |
+
raise ValueError(
|
| 541 |
+
f"The lengths of 'flows' ({n}) and 'pathlengths' "
|
| 542 |
+
f"({len(pathlengths)}) are incompatible")
|
| 543 |
+
else: # Make pathlengths into a list.
|
| 544 |
+
urlength = pathlengths
|
| 545 |
+
ullength = pathlengths
|
| 546 |
+
lrlength = pathlengths
|
| 547 |
+
lllength = pathlengths
|
| 548 |
+
d = dict(RIGHT=pathlengths)
|
| 549 |
+
pathlengths = [d.get(angle, 0) for angle in angles]
|
| 550 |
+
# Determine the lengths of the top-side arrows
|
| 551 |
+
# from the middle outwards.
|
| 552 |
+
for i, (angle, is_input, flow) in enumerate(zip(angles, are_inputs,
|
| 553 |
+
scaled_flows)):
|
| 554 |
+
if angle == DOWN and is_input:
|
| 555 |
+
pathlengths[i] = ullength
|
| 556 |
+
ullength += flow
|
| 557 |
+
elif angle == UP and is_input is False:
|
| 558 |
+
pathlengths[i] = urlength
|
| 559 |
+
urlength -= flow # Flow is negative for outputs.
|
| 560 |
+
# Determine the lengths of the bottom-side arrows
|
| 561 |
+
# from the middle outwards.
|
| 562 |
+
for i, (angle, is_input, flow) in enumerate(reversed(list(zip(
|
| 563 |
+
angles, are_inputs, scaled_flows)))):
|
| 564 |
+
if angle == UP and is_input:
|
| 565 |
+
pathlengths[n - i - 1] = lllength
|
| 566 |
+
lllength += flow
|
| 567 |
+
elif angle == DOWN and is_input is False:
|
| 568 |
+
pathlengths[n - i - 1] = lrlength
|
| 569 |
+
lrlength -= flow
|
| 570 |
+
# Determine the lengths of the left-side arrows
|
| 571 |
+
# from the bottom upwards.
|
| 572 |
+
has_left_input = False
|
| 573 |
+
for i, (angle, is_input, spec) in enumerate(reversed(list(zip(
|
| 574 |
+
angles, are_inputs, zip(scaled_flows, pathlengths))))):
|
| 575 |
+
if angle == RIGHT:
|
| 576 |
+
if is_input:
|
| 577 |
+
if has_left_input:
|
| 578 |
+
pathlengths[n - i - 1] = 0
|
| 579 |
+
else:
|
| 580 |
+
has_left_input = True
|
| 581 |
+
# Determine the lengths of the right-side arrows
|
| 582 |
+
# from the top downwards.
|
| 583 |
+
has_right_output = False
|
| 584 |
+
for i, (angle, is_input, spec) in enumerate(zip(
|
| 585 |
+
angles, are_inputs, list(zip(scaled_flows, pathlengths)))):
|
| 586 |
+
if angle == RIGHT:
|
| 587 |
+
if is_input is False:
|
| 588 |
+
if has_right_output:
|
| 589 |
+
pathlengths[i] = 0
|
| 590 |
+
else:
|
| 591 |
+
has_right_output = True
|
| 592 |
+
|
| 593 |
+
# Begin the subpaths, and smooth the transition if the sum of the flows
|
| 594 |
+
# is nonzero.
|
| 595 |
+
urpath = [(Path.MOVETO, [(self.gap - trunklength / 2.0), # Upper right
|
| 596 |
+
gain / 2.0]),
|
| 597 |
+
(Path.LINETO, [(self.gap - trunklength / 2.0) / 2.0,
|
| 598 |
+
gain / 2.0]),
|
| 599 |
+
(Path.CURVE4, [(self.gap - trunklength / 2.0) / 8.0,
|
| 600 |
+
gain / 2.0]),
|
| 601 |
+
(Path.CURVE4, [(trunklength / 2.0 - self.gap) / 8.0,
|
| 602 |
+
-loss / 2.0]),
|
| 603 |
+
(Path.LINETO, [(trunklength / 2.0 - self.gap) / 2.0,
|
| 604 |
+
-loss / 2.0]),
|
| 605 |
+
(Path.LINETO, [(trunklength / 2.0 - self.gap),
|
| 606 |
+
-loss / 2.0])]
|
| 607 |
+
llpath = [(Path.LINETO, [(trunklength / 2.0 - self.gap), # Lower left
|
| 608 |
+
loss / 2.0]),
|
| 609 |
+
(Path.LINETO, [(trunklength / 2.0 - self.gap) / 2.0,
|
| 610 |
+
loss / 2.0]),
|
| 611 |
+
(Path.CURVE4, [(trunklength / 2.0 - self.gap) / 8.0,
|
| 612 |
+
loss / 2.0]),
|
| 613 |
+
(Path.CURVE4, [(self.gap - trunklength / 2.0) / 8.0,
|
| 614 |
+
-gain / 2.0]),
|
| 615 |
+
(Path.LINETO, [(self.gap - trunklength / 2.0) / 2.0,
|
| 616 |
+
-gain / 2.0]),
|
| 617 |
+
(Path.LINETO, [(self.gap - trunklength / 2.0),
|
| 618 |
+
-gain / 2.0])]
|
| 619 |
+
lrpath = [(Path.LINETO, [(trunklength / 2.0 - self.gap), # Lower right
|
| 620 |
+
loss / 2.0])]
|
| 621 |
+
ulpath = [(Path.LINETO, [self.gap - trunklength / 2.0, # Upper left
|
| 622 |
+
gain / 2.0])]
|
| 623 |
+
|
| 624 |
+
# Add the subpaths and assign the locations of the tips and labels.
|
| 625 |
+
tips = np.zeros((n, 2))
|
| 626 |
+
label_locations = np.zeros((n, 2))
|
| 627 |
+
# Add the top-side inputs and outputs from the middle outwards.
|
| 628 |
+
for i, (angle, is_input, spec) in enumerate(zip(
|
| 629 |
+
angles, are_inputs, list(zip(scaled_flows, pathlengths)))):
|
| 630 |
+
if angle == DOWN and is_input:
|
| 631 |
+
tips[i, :], label_locations[i, :] = self._add_input(
|
| 632 |
+
ulpath, angle, *spec)
|
| 633 |
+
elif angle == UP and is_input is False:
|
| 634 |
+
tips[i, :], label_locations[i, :] = self._add_output(
|
| 635 |
+
urpath, angle, *spec)
|
| 636 |
+
# Add the bottom-side inputs and outputs from the middle outwards.
|
| 637 |
+
for i, (angle, is_input, spec) in enumerate(reversed(list(zip(
|
| 638 |
+
angles, are_inputs, list(zip(scaled_flows, pathlengths)))))):
|
| 639 |
+
if angle == UP and is_input:
|
| 640 |
+
tip, label_location = self._add_input(llpath, angle, *spec)
|
| 641 |
+
tips[n - i - 1, :] = tip
|
| 642 |
+
label_locations[n - i - 1, :] = label_location
|
| 643 |
+
elif angle == DOWN and is_input is False:
|
| 644 |
+
tip, label_location = self._add_output(lrpath, angle, *spec)
|
| 645 |
+
tips[n - i - 1, :] = tip
|
| 646 |
+
label_locations[n - i - 1, :] = label_location
|
| 647 |
+
# Add the left-side inputs from the bottom upwards.
|
| 648 |
+
has_left_input = False
|
| 649 |
+
for i, (angle, is_input, spec) in enumerate(reversed(list(zip(
|
| 650 |
+
angles, are_inputs, list(zip(scaled_flows, pathlengths)))))):
|
| 651 |
+
if angle == RIGHT and is_input:
|
| 652 |
+
if not has_left_input:
|
| 653 |
+
# Make sure the lower path extends
|
| 654 |
+
# at least as far as the upper one.
|
| 655 |
+
if llpath[-1][1][0] > ulpath[-1][1][0]:
|
| 656 |
+
llpath.append((Path.LINETO, [ulpath[-1][1][0],
|
| 657 |
+
llpath[-1][1][1]]))
|
| 658 |
+
has_left_input = True
|
| 659 |
+
tip, label_location = self._add_input(llpath, angle, *spec)
|
| 660 |
+
tips[n - i - 1, :] = tip
|
| 661 |
+
label_locations[n - i - 1, :] = label_location
|
| 662 |
+
# Add the right-side outputs from the top downwards.
|
| 663 |
+
has_right_output = False
|
| 664 |
+
for i, (angle, is_input, spec) in enumerate(zip(
|
| 665 |
+
angles, are_inputs, list(zip(scaled_flows, pathlengths)))):
|
| 666 |
+
if angle == RIGHT and is_input is False:
|
| 667 |
+
if not has_right_output:
|
| 668 |
+
# Make sure the upper path extends
|
| 669 |
+
# at least as far as the lower one.
|
| 670 |
+
if urpath[-1][1][0] < lrpath[-1][1][0]:
|
| 671 |
+
urpath.append((Path.LINETO, [lrpath[-1][1][0],
|
| 672 |
+
urpath[-1][1][1]]))
|
| 673 |
+
has_right_output = True
|
| 674 |
+
tips[i, :], label_locations[i, :] = self._add_output(
|
| 675 |
+
urpath, angle, *spec)
|
| 676 |
+
# Trim any hanging vertices.
|
| 677 |
+
if not has_left_input:
|
| 678 |
+
ulpath.pop()
|
| 679 |
+
llpath.pop()
|
| 680 |
+
if not has_right_output:
|
| 681 |
+
lrpath.pop()
|
| 682 |
+
urpath.pop()
|
| 683 |
+
|
| 684 |
+
# Concatenate the subpaths in the correct order (clockwise from top).
|
| 685 |
+
path = (urpath + self._revert(lrpath) + llpath + self._revert(ulpath) +
|
| 686 |
+
[(Path.CLOSEPOLY, urpath[0][1])])
|
| 687 |
+
|
| 688 |
+
# Create a patch with the Sankey outline.
|
| 689 |
+
codes, vertices = zip(*path)
|
| 690 |
+
vertices = np.array(vertices)
|
| 691 |
+
|
| 692 |
+
def _get_angle(a, r):
|
| 693 |
+
if a is None:
|
| 694 |
+
return None
|
| 695 |
+
else:
|
| 696 |
+
return a + r
|
| 697 |
+
|
| 698 |
+
if prior is None:
|
| 699 |
+
if rotation != 0: # By default, none of this is needed.
|
| 700 |
+
angles = [_get_angle(angle, rotation) for angle in angles]
|
| 701 |
+
rotate = Affine2D().rotate_deg(rotation * 90).transform_affine
|
| 702 |
+
tips = rotate(tips)
|
| 703 |
+
label_locations = rotate(label_locations)
|
| 704 |
+
vertices = rotate(vertices)
|
| 705 |
+
text = self.ax.text(0, 0, s=patchlabel, ha='center', va='center')
|
| 706 |
+
else:
|
| 707 |
+
rotation = (self.diagrams[prior].angles[connect[0]] -
|
| 708 |
+
angles[connect[1]])
|
| 709 |
+
angles = [_get_angle(angle, rotation) for angle in angles]
|
| 710 |
+
rotate = Affine2D().rotate_deg(rotation * 90).transform_affine
|
| 711 |
+
tips = rotate(tips)
|
| 712 |
+
offset = self.diagrams[prior].tips[connect[0]] - tips[connect[1]]
|
| 713 |
+
translate = Affine2D().translate(*offset).transform_affine
|
| 714 |
+
tips = translate(tips)
|
| 715 |
+
label_locations = translate(rotate(label_locations))
|
| 716 |
+
vertices = translate(rotate(vertices))
|
| 717 |
+
kwds = dict(s=patchlabel, ha='center', va='center')
|
| 718 |
+
text = self.ax.text(*offset, **kwds)
|
| 719 |
+
if mpl.rcParams['_internal.classic_mode']:
|
| 720 |
+
fc = kwargs.pop('fc', kwargs.pop('facecolor', '#bfd1d4'))
|
| 721 |
+
lw = kwargs.pop('lw', kwargs.pop('linewidth', 0.5))
|
| 722 |
+
else:
|
| 723 |
+
fc = kwargs.pop('fc', kwargs.pop('facecolor', None))
|
| 724 |
+
lw = kwargs.pop('lw', kwargs.pop('linewidth', None))
|
| 725 |
+
if fc is None:
|
| 726 |
+
fc = self.ax._get_patches_for_fill.get_next_color()
|
| 727 |
+
patch = PathPatch(Path(vertices, codes), fc=fc, lw=lw, **kwargs)
|
| 728 |
+
self.ax.add_patch(patch)
|
| 729 |
+
|
| 730 |
+
# Add the path labels.
|
| 731 |
+
texts = []
|
| 732 |
+
for number, angle, label, location in zip(flows, angles, labels,
|
| 733 |
+
label_locations):
|
| 734 |
+
if label is None or angle is None:
|
| 735 |
+
label = ''
|
| 736 |
+
elif self.unit is not None:
|
| 737 |
+
if isinstance(self.format, str):
|
| 738 |
+
quantity = self.format % abs(number) + self.unit
|
| 739 |
+
elif callable(self.format):
|
| 740 |
+
quantity = self.format(number)
|
| 741 |
+
else:
|
| 742 |
+
raise TypeError(
|
| 743 |
+
'format must be callable or a format string')
|
| 744 |
+
if label != '':
|
| 745 |
+
label += "\n"
|
| 746 |
+
label += quantity
|
| 747 |
+
texts.append(self.ax.text(x=location[0], y=location[1],
|
| 748 |
+
s=label,
|
| 749 |
+
ha='center', va='center'))
|
| 750 |
+
# Text objects are placed even they are empty (as long as the magnitude
|
| 751 |
+
# of the corresponding flow is larger than the tolerance) in case the
|
| 752 |
+
# user wants to provide labels later.
|
| 753 |
+
|
| 754 |
+
# Expand the size of the diagram if necessary.
|
| 755 |
+
self.extent = (min(np.min(vertices[:, 0]),
|
| 756 |
+
np.min(label_locations[:, 0]),
|
| 757 |
+
self.extent[0]),
|
| 758 |
+
max(np.max(vertices[:, 0]),
|
| 759 |
+
np.max(label_locations[:, 0]),
|
| 760 |
+
self.extent[1]),
|
| 761 |
+
min(np.min(vertices[:, 1]),
|
| 762 |
+
np.min(label_locations[:, 1]),
|
| 763 |
+
self.extent[2]),
|
| 764 |
+
max(np.max(vertices[:, 1]),
|
| 765 |
+
np.max(label_locations[:, 1]),
|
| 766 |
+
self.extent[3]))
|
| 767 |
+
# Include both vertices _and_ label locations in the extents; there are
|
| 768 |
+
# where either could determine the margins (e.g., arrow shoulders).
|
| 769 |
+
|
| 770 |
+
# Add this diagram as a subdiagram.
|
| 771 |
+
self.diagrams.append(
|
| 772 |
+
SimpleNamespace(patch=patch, flows=flows, angles=angles, tips=tips,
|
| 773 |
+
text=text, texts=texts))
|
| 774 |
+
|
| 775 |
+
# Allow a daisy-chained call structure (see docstring for the class).
|
| 776 |
+
return self
|
| 777 |
+
|
| 778 |
+
def finish(self):
|
| 779 |
+
"""
|
| 780 |
+
Adjust the Axes and return a list of information about the Sankey
|
| 781 |
+
subdiagram(s).
|
| 782 |
+
|
| 783 |
+
Returns a list of subdiagrams with the following fields:
|
| 784 |
+
|
| 785 |
+
======== =============================================================
|
| 786 |
+
Field Description
|
| 787 |
+
======== =============================================================
|
| 788 |
+
*patch* Sankey outline (a `~matplotlib.patches.PathPatch`).
|
| 789 |
+
*flows* Flow values (positive for input, negative for output).
|
| 790 |
+
*angles* List of angles of the arrows [deg/90].
|
| 791 |
+
For example, if the diagram has not been rotated,
|
| 792 |
+
an input to the top side has an angle of 3 (DOWN),
|
| 793 |
+
and an output from the top side has an angle of 1 (UP).
|
| 794 |
+
If a flow has been skipped (because its magnitude is less
|
| 795 |
+
than *tolerance*), then its angle will be *None*.
|
| 796 |
+
*tips* (N, 2)-array of the (x, y) positions of the tips (or "dips")
|
| 797 |
+
of the flow paths.
|
| 798 |
+
If the magnitude of a flow is less the *tolerance* of this
|
| 799 |
+
`Sankey` instance, the flow is skipped and its tip will be at
|
| 800 |
+
the center of the diagram.
|
| 801 |
+
*text* `.Text` instance for the diagram label.
|
| 802 |
+
*texts* List of `.Text` instances for the flow labels.
|
| 803 |
+
======== =============================================================
|
| 804 |
+
|
| 805 |
+
See Also
|
| 806 |
+
--------
|
| 807 |
+
Sankey.add
|
| 808 |
+
"""
|
| 809 |
+
self.ax.axis([self.extent[0] - self.margin,
|
| 810 |
+
self.extent[1] + self.margin,
|
| 811 |
+
self.extent[2] - self.margin,
|
| 812 |
+
self.extent[3] + self.margin])
|
| 813 |
+
self.ax.set_aspect('equal', adjustable='datalim')
|
| 814 |
+
return self.diagrams
|