Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/__init__.pyi +124 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_afm.py +532 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_cm_bivar.py +1312 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_color_data.pyi +6 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_constrained_layout.py +801 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_docstring.py +141 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_docstring.pyi +34 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_enums.py +177 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_mathtext.py +0 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_mathtext_data.py +1742 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_path.pyi +9 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_pylab_helpers.pyi +29 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_qhull.pyi +0 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_tight_layout.py +301 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_tri.pyi +36 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/_version.py +1 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/artist.py +1855 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/axis.pyi +280 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/backend_bases.pyi +482 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/backend_managers.py +387 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/backend_managers.pyi +64 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/cbook.pyi +173 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/collections.pyi +262 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/colorbar.py +1563 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/colorbar.pyi +139 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/colors.pyi +449 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/container.py +141 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/dviread.py +1139 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/figure.py +0 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/ft2font.pyi +312 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/gridspec.py +788 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/gridspec.pyi +160 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/inset.py +269 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/layout_engine.pyi +62 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/legend.py +1370 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/legend_handler.pyi +294 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/lines.py +1706 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/markers.py +908 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/markers.pyi +51 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/mathtext.py +140 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/mathtext.pyi +33 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/offsetbox.py +1607 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/path.pyi +140 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/patheffects.py +511 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/py.typed +0 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/quiver.pyi +184 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/rcsetup.py +1371 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/sankey.py +814 -0
- infer_4_30_0/lib/python3.10/site-packages/matplotlib/sankey.pyi +61 -0
.gitattributes
CHANGED
|
@@ -1006,3 +1006,4 @@ infer_4_30_0/lib/python3.10/site-packages/scipy/stats/__pycache__/_mstats_basic.
|
|
| 1006 |
infer_4_30_0/lib/python3.10/site-packages/scipy/stats/__pycache__/_distribution_infrastructure.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 1007 |
infer_4_30_0/lib/python3.10/site-packages/scipy/signal/_peak_finding_utils.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1008 |
infer_4_30_0/lib/python3.10/site-packages/scipy/signal/_upfirdn_apply.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 1006 |
infer_4_30_0/lib/python3.10/site-packages/scipy/stats/__pycache__/_distribution_infrastructure.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 1007 |
infer_4_30_0/lib/python3.10/site-packages/scipy/signal/_peak_finding_utils.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1008 |
infer_4_30_0/lib/python3.10/site-packages/scipy/signal/_upfirdn_apply.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 1009 |
+
infer_4_30_0/lib/python3.10/site-packages/pkg_resources/__pycache__/__init__.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
infer_4_30_0/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
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_afm.py
ADDED
|
@@ -0,0 +1,532 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A python interface to Adobe Font Metrics Files.
|
| 3 |
+
|
| 4 |
+
Although a number of other Python implementations exist, and may be more
|
| 5 |
+
complete than this, it was decided not to go with them because they were
|
| 6 |
+
either:
|
| 7 |
+
|
| 8 |
+
1) copyrighted or used a non-BSD compatible license
|
| 9 |
+
2) had too many dependencies and a free standing lib was needed
|
| 10 |
+
3) did more than needed and it was easier to write afresh rather than
|
| 11 |
+
figure out how to get just what was needed.
|
| 12 |
+
|
| 13 |
+
It is pretty easy to use, and has no external dependencies:
|
| 14 |
+
|
| 15 |
+
>>> import matplotlib as mpl
|
| 16 |
+
>>> from pathlib import Path
|
| 17 |
+
>>> afm_path = Path(mpl.get_data_path(), 'fonts', 'afm', 'ptmr8a.afm')
|
| 18 |
+
>>>
|
| 19 |
+
>>> from matplotlib.afm import AFM
|
| 20 |
+
>>> with afm_path.open('rb') as fh:
|
| 21 |
+
... afm = AFM(fh)
|
| 22 |
+
>>> afm.string_width_height('What the heck?')
|
| 23 |
+
(6220.0, 694)
|
| 24 |
+
>>> afm.get_fontname()
|
| 25 |
+
'Times-Roman'
|
| 26 |
+
>>> afm.get_kern_dist('A', 'f')
|
| 27 |
+
0
|
| 28 |
+
>>> afm.get_kern_dist('A', 'y')
|
| 29 |
+
-92.0
|
| 30 |
+
>>> afm.get_bbox_char('!')
|
| 31 |
+
[130, -9, 238, 676]
|
| 32 |
+
|
| 33 |
+
As in the Adobe Font Metrics File Format Specification, all dimensions
|
| 34 |
+
are given in units of 1/1000 of the scale factor (point size) of the font
|
| 35 |
+
being used.
|
| 36 |
+
"""
|
| 37 |
+
|
| 38 |
+
from collections import namedtuple
|
| 39 |
+
import logging
|
| 40 |
+
import re
|
| 41 |
+
|
| 42 |
+
from ._mathtext_data import uni2type1
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
_log = logging.getLogger(__name__)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def _to_int(x):
|
| 49 |
+
# Some AFM files have floats where we are expecting ints -- there is
|
| 50 |
+
# probably a better way to handle this (support floats, round rather than
|
| 51 |
+
# truncate). But I don't know what the best approach is now and this
|
| 52 |
+
# change to _to_int should at least prevent Matplotlib from crashing on
|
| 53 |
+
# these. JDH (2009-11-06)
|
| 54 |
+
return int(float(x))
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def _to_float(x):
|
| 58 |
+
# Some AFM files use "," instead of "." as decimal separator -- this
|
| 59 |
+
# shouldn't be ambiguous (unless someone is wicked enough to use "," as
|
| 60 |
+
# thousands separator...).
|
| 61 |
+
if isinstance(x, bytes):
|
| 62 |
+
# Encoding doesn't really matter -- if we have codepoints >127 the call
|
| 63 |
+
# to float() will error anyways.
|
| 64 |
+
x = x.decode('latin-1')
|
| 65 |
+
return float(x.replace(',', '.'))
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def _to_str(x):
|
| 69 |
+
return x.decode('utf8')
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def _to_list_of_ints(s):
|
| 73 |
+
s = s.replace(b',', b' ')
|
| 74 |
+
return [_to_int(val) for val in s.split()]
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def _to_list_of_floats(s):
|
| 78 |
+
return [_to_float(val) for val in s.split()]
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def _to_bool(s):
|
| 82 |
+
if s.lower().strip() in (b'false', b'0', b'no'):
|
| 83 |
+
return False
|
| 84 |
+
else:
|
| 85 |
+
return True
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def _parse_header(fh):
|
| 89 |
+
"""
|
| 90 |
+
Read the font metrics header (up to the char metrics) and returns
|
| 91 |
+
a dictionary mapping *key* to *val*. *val* will be converted to the
|
| 92 |
+
appropriate python type as necessary; e.g.:
|
| 93 |
+
|
| 94 |
+
* 'False'->False
|
| 95 |
+
* '0'->0
|
| 96 |
+
* '-168 -218 1000 898'-> [-168, -218, 1000, 898]
|
| 97 |
+
|
| 98 |
+
Dictionary keys are
|
| 99 |
+
|
| 100 |
+
StartFontMetrics, FontName, FullName, FamilyName, Weight,
|
| 101 |
+
ItalicAngle, IsFixedPitch, FontBBox, UnderlinePosition,
|
| 102 |
+
UnderlineThickness, Version, Notice, EncodingScheme, CapHeight,
|
| 103 |
+
XHeight, Ascender, Descender, StartCharMetrics
|
| 104 |
+
"""
|
| 105 |
+
header_converters = {
|
| 106 |
+
b'StartFontMetrics': _to_float,
|
| 107 |
+
b'FontName': _to_str,
|
| 108 |
+
b'FullName': _to_str,
|
| 109 |
+
b'FamilyName': _to_str,
|
| 110 |
+
b'Weight': _to_str,
|
| 111 |
+
b'ItalicAngle': _to_float,
|
| 112 |
+
b'IsFixedPitch': _to_bool,
|
| 113 |
+
b'FontBBox': _to_list_of_ints,
|
| 114 |
+
b'UnderlinePosition': _to_float,
|
| 115 |
+
b'UnderlineThickness': _to_float,
|
| 116 |
+
b'Version': _to_str,
|
| 117 |
+
# Some AFM files have non-ASCII characters (which are not allowed by
|
| 118 |
+
# the spec). Given that there is actually no public API to even access
|
| 119 |
+
# this field, just return it as straight bytes.
|
| 120 |
+
b'Notice': lambda x: x,
|
| 121 |
+
b'EncodingScheme': _to_str,
|
| 122 |
+
b'CapHeight': _to_float, # Is the second version a mistake, or
|
| 123 |
+
b'Capheight': _to_float, # do some AFM files contain 'Capheight'? -JKS
|
| 124 |
+
b'XHeight': _to_float,
|
| 125 |
+
b'Ascender': _to_float,
|
| 126 |
+
b'Descender': _to_float,
|
| 127 |
+
b'StdHW': _to_float,
|
| 128 |
+
b'StdVW': _to_float,
|
| 129 |
+
b'StartCharMetrics': _to_int,
|
| 130 |
+
b'CharacterSet': _to_str,
|
| 131 |
+
b'Characters': _to_int,
|
| 132 |
+
}
|
| 133 |
+
d = {}
|
| 134 |
+
first_line = True
|
| 135 |
+
for line in fh:
|
| 136 |
+
line = line.rstrip()
|
| 137 |
+
if line.startswith(b'Comment'):
|
| 138 |
+
continue
|
| 139 |
+
lst = line.split(b' ', 1)
|
| 140 |
+
key = lst[0]
|
| 141 |
+
if first_line:
|
| 142 |
+
# AFM spec, Section 4: The StartFontMetrics keyword
|
| 143 |
+
# [followed by a version number] must be the first line in
|
| 144 |
+
# the file, and the EndFontMetrics keyword must be the
|
| 145 |
+
# last non-empty line in the file. We just check the
|
| 146 |
+
# first header entry.
|
| 147 |
+
if key != b'StartFontMetrics':
|
| 148 |
+
raise RuntimeError('Not an AFM file')
|
| 149 |
+
first_line = False
|
| 150 |
+
if len(lst) == 2:
|
| 151 |
+
val = lst[1]
|
| 152 |
+
else:
|
| 153 |
+
val = b''
|
| 154 |
+
try:
|
| 155 |
+
converter = header_converters[key]
|
| 156 |
+
except KeyError:
|
| 157 |
+
_log.error("Found an unknown keyword in AFM header (was %r)", key)
|
| 158 |
+
continue
|
| 159 |
+
try:
|
| 160 |
+
d[key] = converter(val)
|
| 161 |
+
except ValueError:
|
| 162 |
+
_log.error('Value error parsing header in AFM: %s, %s', key, val)
|
| 163 |
+
continue
|
| 164 |
+
if key == b'StartCharMetrics':
|
| 165 |
+
break
|
| 166 |
+
else:
|
| 167 |
+
raise RuntimeError('Bad parse')
|
| 168 |
+
return d
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
CharMetrics = namedtuple('CharMetrics', 'width, name, bbox')
|
| 172 |
+
CharMetrics.__doc__ = """
|
| 173 |
+
Represents the character metrics of a single character.
|
| 174 |
+
|
| 175 |
+
Notes
|
| 176 |
+
-----
|
| 177 |
+
The fields do currently only describe a subset of character metrics
|
| 178 |
+
information defined in the AFM standard.
|
| 179 |
+
"""
|
| 180 |
+
CharMetrics.width.__doc__ = """The character width (WX)."""
|
| 181 |
+
CharMetrics.name.__doc__ = """The character name (N)."""
|
| 182 |
+
CharMetrics.bbox.__doc__ = """
|
| 183 |
+
The bbox of the character (B) as a tuple (*llx*, *lly*, *urx*, *ury*)."""
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
def _parse_char_metrics(fh):
|
| 187 |
+
"""
|
| 188 |
+
Parse the given filehandle for character metrics information and return
|
| 189 |
+
the information as dicts.
|
| 190 |
+
|
| 191 |
+
It is assumed that the file cursor is on the line behind
|
| 192 |
+
'StartCharMetrics'.
|
| 193 |
+
|
| 194 |
+
Returns
|
| 195 |
+
-------
|
| 196 |
+
ascii_d : dict
|
| 197 |
+
A mapping "ASCII num of the character" to `.CharMetrics`.
|
| 198 |
+
name_d : dict
|
| 199 |
+
A mapping "character name" to `.CharMetrics`.
|
| 200 |
+
|
| 201 |
+
Notes
|
| 202 |
+
-----
|
| 203 |
+
This function is incomplete per the standard, but thus far parses
|
| 204 |
+
all the sample afm files tried.
|
| 205 |
+
"""
|
| 206 |
+
required_keys = {'C', 'WX', 'N', 'B'}
|
| 207 |
+
|
| 208 |
+
ascii_d = {}
|
| 209 |
+
name_d = {}
|
| 210 |
+
for line in fh:
|
| 211 |
+
# We are defensively letting values be utf8. The spec requires
|
| 212 |
+
# ascii, but there are non-compliant fonts in circulation
|
| 213 |
+
line = _to_str(line.rstrip()) # Convert from byte-literal
|
| 214 |
+
if line.startswith('EndCharMetrics'):
|
| 215 |
+
return ascii_d, name_d
|
| 216 |
+
# Split the metric line into a dictionary, keyed by metric identifiers
|
| 217 |
+
vals = dict(s.strip().split(' ', 1) for s in line.split(';') if s)
|
| 218 |
+
# There may be other metrics present, but only these are needed
|
| 219 |
+
if not required_keys.issubset(vals):
|
| 220 |
+
raise RuntimeError('Bad char metrics line: %s' % line)
|
| 221 |
+
num = _to_int(vals['C'])
|
| 222 |
+
wx = _to_float(vals['WX'])
|
| 223 |
+
name = vals['N']
|
| 224 |
+
bbox = _to_list_of_floats(vals['B'])
|
| 225 |
+
bbox = list(map(int, bbox))
|
| 226 |
+
metrics = CharMetrics(wx, name, bbox)
|
| 227 |
+
# Workaround: If the character name is 'Euro', give it the
|
| 228 |
+
# corresponding character code, according to WinAnsiEncoding (see PDF
|
| 229 |
+
# Reference).
|
| 230 |
+
if name == 'Euro':
|
| 231 |
+
num = 128
|
| 232 |
+
elif name == 'minus':
|
| 233 |
+
num = ord("\N{MINUS SIGN}") # 0x2212
|
| 234 |
+
if num != -1:
|
| 235 |
+
ascii_d[num] = metrics
|
| 236 |
+
name_d[name] = metrics
|
| 237 |
+
raise RuntimeError('Bad parse')
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
def _parse_kern_pairs(fh):
|
| 241 |
+
"""
|
| 242 |
+
Return a kern pairs dictionary; keys are (*char1*, *char2*) tuples and
|
| 243 |
+
values are the kern pair value. For example, a kern pairs line like
|
| 244 |
+
``KPX A y -50``
|
| 245 |
+
|
| 246 |
+
will be represented as::
|
| 247 |
+
|
| 248 |
+
d[ ('A', 'y') ] = -50
|
| 249 |
+
|
| 250 |
+
"""
|
| 251 |
+
|
| 252 |
+
line = next(fh)
|
| 253 |
+
if not line.startswith(b'StartKernPairs'):
|
| 254 |
+
raise RuntimeError('Bad start of kern pairs data: %s' % line)
|
| 255 |
+
|
| 256 |
+
d = {}
|
| 257 |
+
for line in fh:
|
| 258 |
+
line = line.rstrip()
|
| 259 |
+
if not line:
|
| 260 |
+
continue
|
| 261 |
+
if line.startswith(b'EndKernPairs'):
|
| 262 |
+
next(fh) # EndKernData
|
| 263 |
+
return d
|
| 264 |
+
vals = line.split()
|
| 265 |
+
if len(vals) != 4 or vals[0] != b'KPX':
|
| 266 |
+
raise RuntimeError('Bad kern pairs line: %s' % line)
|
| 267 |
+
c1, c2, val = _to_str(vals[1]), _to_str(vals[2]), _to_float(vals[3])
|
| 268 |
+
d[(c1, c2)] = val
|
| 269 |
+
raise RuntimeError('Bad kern pairs parse')
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
CompositePart = namedtuple('CompositePart', 'name, dx, dy')
|
| 273 |
+
CompositePart.__doc__ = """
|
| 274 |
+
Represents the information on a composite element of a composite char."""
|
| 275 |
+
CompositePart.name.__doc__ = """Name of the part, e.g. 'acute'."""
|
| 276 |
+
CompositePart.dx.__doc__ = """x-displacement of the part from the origin."""
|
| 277 |
+
CompositePart.dy.__doc__ = """y-displacement of the part from the origin."""
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
def _parse_composites(fh):
|
| 281 |
+
"""
|
| 282 |
+
Parse the given filehandle for composites information return them as a
|
| 283 |
+
dict.
|
| 284 |
+
|
| 285 |
+
It is assumed that the file cursor is on the line behind 'StartComposites'.
|
| 286 |
+
|
| 287 |
+
Returns
|
| 288 |
+
-------
|
| 289 |
+
dict
|
| 290 |
+
A dict mapping composite character names to a parts list. The parts
|
| 291 |
+
list is a list of `.CompositePart` entries describing the parts of
|
| 292 |
+
the composite.
|
| 293 |
+
|
| 294 |
+
Examples
|
| 295 |
+
--------
|
| 296 |
+
A composite definition line::
|
| 297 |
+
|
| 298 |
+
CC Aacute 2 ; PCC A 0 0 ; PCC acute 160 170 ;
|
| 299 |
+
|
| 300 |
+
will be represented as::
|
| 301 |
+
|
| 302 |
+
composites['Aacute'] = [CompositePart(name='A', dx=0, dy=0),
|
| 303 |
+
CompositePart(name='acute', dx=160, dy=170)]
|
| 304 |
+
|
| 305 |
+
"""
|
| 306 |
+
composites = {}
|
| 307 |
+
for line in fh:
|
| 308 |
+
line = line.rstrip()
|
| 309 |
+
if not line:
|
| 310 |
+
continue
|
| 311 |
+
if line.startswith(b'EndComposites'):
|
| 312 |
+
return composites
|
| 313 |
+
vals = line.split(b';')
|
| 314 |
+
cc = vals[0].split()
|
| 315 |
+
name, _num_parts = cc[1], _to_int(cc[2])
|
| 316 |
+
pccParts = []
|
| 317 |
+
for s in vals[1:-1]:
|
| 318 |
+
pcc = s.split()
|
| 319 |
+
part = CompositePart(pcc[1], _to_float(pcc[2]), _to_float(pcc[3]))
|
| 320 |
+
pccParts.append(part)
|
| 321 |
+
composites[name] = pccParts
|
| 322 |
+
|
| 323 |
+
raise RuntimeError('Bad composites parse')
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def _parse_optional(fh):
|
| 327 |
+
"""
|
| 328 |
+
Parse the optional fields for kern pair data and composites.
|
| 329 |
+
|
| 330 |
+
Returns
|
| 331 |
+
-------
|
| 332 |
+
kern_data : dict
|
| 333 |
+
A dict containing kerning information. May be empty.
|
| 334 |
+
See `._parse_kern_pairs`.
|
| 335 |
+
composites : dict
|
| 336 |
+
A dict containing composite information. May be empty.
|
| 337 |
+
See `._parse_composites`.
|
| 338 |
+
"""
|
| 339 |
+
optional = {
|
| 340 |
+
b'StartKernData': _parse_kern_pairs,
|
| 341 |
+
b'StartComposites': _parse_composites,
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
d = {b'StartKernData': {},
|
| 345 |
+
b'StartComposites': {}}
|
| 346 |
+
for line in fh:
|
| 347 |
+
line = line.rstrip()
|
| 348 |
+
if not line:
|
| 349 |
+
continue
|
| 350 |
+
key = line.split()[0]
|
| 351 |
+
|
| 352 |
+
if key in optional:
|
| 353 |
+
d[key] = optional[key](fh)
|
| 354 |
+
|
| 355 |
+
return d[b'StartKernData'], d[b'StartComposites']
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
class AFM:
|
| 359 |
+
|
| 360 |
+
def __init__(self, fh):
|
| 361 |
+
"""Parse the AFM file in file object *fh*."""
|
| 362 |
+
self._header = _parse_header(fh)
|
| 363 |
+
self._metrics, self._metrics_by_name = _parse_char_metrics(fh)
|
| 364 |
+
self._kern, self._composite = _parse_optional(fh)
|
| 365 |
+
|
| 366 |
+
def get_bbox_char(self, c, isord=False):
|
| 367 |
+
if not isord:
|
| 368 |
+
c = ord(c)
|
| 369 |
+
return self._metrics[c].bbox
|
| 370 |
+
|
| 371 |
+
def string_width_height(self, s):
|
| 372 |
+
"""
|
| 373 |
+
Return the string width (including kerning) and string height
|
| 374 |
+
as a (*w*, *h*) tuple.
|
| 375 |
+
"""
|
| 376 |
+
if not len(s):
|
| 377 |
+
return 0, 0
|
| 378 |
+
total_width = 0
|
| 379 |
+
namelast = None
|
| 380 |
+
miny = 1e9
|
| 381 |
+
maxy = 0
|
| 382 |
+
for c in s:
|
| 383 |
+
if c == '\n':
|
| 384 |
+
continue
|
| 385 |
+
wx, name, bbox = self._metrics[ord(c)]
|
| 386 |
+
|
| 387 |
+
total_width += wx + self._kern.get((namelast, name), 0)
|
| 388 |
+
l, b, w, h = bbox
|
| 389 |
+
miny = min(miny, b)
|
| 390 |
+
maxy = max(maxy, b + h)
|
| 391 |
+
|
| 392 |
+
namelast = name
|
| 393 |
+
|
| 394 |
+
return total_width, maxy - miny
|
| 395 |
+
|
| 396 |
+
def get_str_bbox_and_descent(self, s):
|
| 397 |
+
"""Return the string bounding box and the maximal descent."""
|
| 398 |
+
if not len(s):
|
| 399 |
+
return 0, 0, 0, 0, 0
|
| 400 |
+
total_width = 0
|
| 401 |
+
namelast = None
|
| 402 |
+
miny = 1e9
|
| 403 |
+
maxy = 0
|
| 404 |
+
left = 0
|
| 405 |
+
if not isinstance(s, str):
|
| 406 |
+
s = _to_str(s)
|
| 407 |
+
for c in s:
|
| 408 |
+
if c == '\n':
|
| 409 |
+
continue
|
| 410 |
+
name = uni2type1.get(ord(c), f"uni{ord(c):04X}")
|
| 411 |
+
try:
|
| 412 |
+
wx, _, bbox = self._metrics_by_name[name]
|
| 413 |
+
except KeyError:
|
| 414 |
+
name = 'question'
|
| 415 |
+
wx, _, bbox = self._metrics_by_name[name]
|
| 416 |
+
total_width += wx + self._kern.get((namelast, name), 0)
|
| 417 |
+
l, b, w, h = bbox
|
| 418 |
+
left = min(left, l)
|
| 419 |
+
miny = min(miny, b)
|
| 420 |
+
maxy = max(maxy, b + h)
|
| 421 |
+
|
| 422 |
+
namelast = name
|
| 423 |
+
|
| 424 |
+
return left, miny, total_width, maxy - miny, -miny
|
| 425 |
+
|
| 426 |
+
def get_str_bbox(self, s):
|
| 427 |
+
"""Return the string bounding box."""
|
| 428 |
+
return self.get_str_bbox_and_descent(s)[:4]
|
| 429 |
+
|
| 430 |
+
def get_name_char(self, c, isord=False):
|
| 431 |
+
"""Get the name of the character, i.e., ';' is 'semicolon'."""
|
| 432 |
+
if not isord:
|
| 433 |
+
c = ord(c)
|
| 434 |
+
return self._metrics[c].name
|
| 435 |
+
|
| 436 |
+
def get_width_char(self, c, isord=False):
|
| 437 |
+
"""
|
| 438 |
+
Get the width of the character from the character metric WX field.
|
| 439 |
+
"""
|
| 440 |
+
if not isord:
|
| 441 |
+
c = ord(c)
|
| 442 |
+
return self._metrics[c].width
|
| 443 |
+
|
| 444 |
+
def get_width_from_char_name(self, name):
|
| 445 |
+
"""Get the width of the character from a type1 character name."""
|
| 446 |
+
return self._metrics_by_name[name].width
|
| 447 |
+
|
| 448 |
+
def get_height_char(self, c, isord=False):
|
| 449 |
+
"""Get the bounding box (ink) height of character *c* (space is 0)."""
|
| 450 |
+
if not isord:
|
| 451 |
+
c = ord(c)
|
| 452 |
+
return self._metrics[c].bbox[-1]
|
| 453 |
+
|
| 454 |
+
def get_kern_dist(self, c1, c2):
|
| 455 |
+
"""
|
| 456 |
+
Return the kerning pair distance (possibly 0) for chars *c1* and *c2*.
|
| 457 |
+
"""
|
| 458 |
+
name1, name2 = self.get_name_char(c1), self.get_name_char(c2)
|
| 459 |
+
return self.get_kern_dist_from_name(name1, name2)
|
| 460 |
+
|
| 461 |
+
def get_kern_dist_from_name(self, name1, name2):
|
| 462 |
+
"""
|
| 463 |
+
Return the kerning pair distance (possibly 0) for chars
|
| 464 |
+
*name1* and *name2*.
|
| 465 |
+
"""
|
| 466 |
+
return self._kern.get((name1, name2), 0)
|
| 467 |
+
|
| 468 |
+
def get_fontname(self):
|
| 469 |
+
"""Return the font name, e.g., 'Times-Roman'."""
|
| 470 |
+
return self._header[b'FontName']
|
| 471 |
+
|
| 472 |
+
@property
|
| 473 |
+
def postscript_name(self): # For consistency with FT2Font.
|
| 474 |
+
return self.get_fontname()
|
| 475 |
+
|
| 476 |
+
def get_fullname(self):
|
| 477 |
+
"""Return the font full name, e.g., 'Times-Roman'."""
|
| 478 |
+
name = self._header.get(b'FullName')
|
| 479 |
+
if name is None: # use FontName as a substitute
|
| 480 |
+
name = self._header[b'FontName']
|
| 481 |
+
return name
|
| 482 |
+
|
| 483 |
+
def get_familyname(self):
|
| 484 |
+
"""Return the font family name, e.g., 'Times'."""
|
| 485 |
+
name = self._header.get(b'FamilyName')
|
| 486 |
+
if name is not None:
|
| 487 |
+
return name
|
| 488 |
+
|
| 489 |
+
# FamilyName not specified so we'll make a guess
|
| 490 |
+
name = self.get_fullname()
|
| 491 |
+
extras = (r'(?i)([ -](regular|plain|italic|oblique|bold|semibold|'
|
| 492 |
+
r'light|ultralight|extra|condensed))+$')
|
| 493 |
+
return re.sub(extras, '', name)
|
| 494 |
+
|
| 495 |
+
@property
|
| 496 |
+
def family_name(self):
|
| 497 |
+
"""The font family name, e.g., 'Times'."""
|
| 498 |
+
return self.get_familyname()
|
| 499 |
+
|
| 500 |
+
def get_weight(self):
|
| 501 |
+
"""Return the font weight, e.g., 'Bold' or 'Roman'."""
|
| 502 |
+
return self._header[b'Weight']
|
| 503 |
+
|
| 504 |
+
def get_angle(self):
|
| 505 |
+
"""Return the fontangle as float."""
|
| 506 |
+
return self._header[b'ItalicAngle']
|
| 507 |
+
|
| 508 |
+
def get_capheight(self):
|
| 509 |
+
"""Return the cap height as float."""
|
| 510 |
+
return self._header[b'CapHeight']
|
| 511 |
+
|
| 512 |
+
def get_xheight(self):
|
| 513 |
+
"""Return the xheight as float."""
|
| 514 |
+
return self._header[b'XHeight']
|
| 515 |
+
|
| 516 |
+
def get_underline_thickness(self):
|
| 517 |
+
"""Return the underline thickness as float."""
|
| 518 |
+
return self._header[b'UnderlineThickness']
|
| 519 |
+
|
| 520 |
+
def get_horizontal_stem_width(self):
|
| 521 |
+
"""
|
| 522 |
+
Return the standard horizontal stem width as float, or *None* if
|
| 523 |
+
not specified in AFM file.
|
| 524 |
+
"""
|
| 525 |
+
return self._header.get(b'StdHW', None)
|
| 526 |
+
|
| 527 |
+
def get_vertical_stem_width(self):
|
| 528 |
+
"""
|
| 529 |
+
Return the standard vertical stem width as float, or *None* if
|
| 530 |
+
not specified in AFM file.
|
| 531 |
+
"""
|
| 532 |
+
return self._header.get(b'StdVW', None)
|
infer_4_30_0/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 |
+
}
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_color_data.pyi
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .typing import ColorType
|
| 2 |
+
|
| 3 |
+
BASE_COLORS: dict[str, ColorType]
|
| 4 |
+
TABLEAU_COLORS: dict[str, ColorType]
|
| 5 |
+
XKCD_COLORS: dict[str, ColorType]
|
| 6 |
+
CSS4_COLORS: dict[str, ColorType]
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_constrained_layout.py
ADDED
|
@@ -0,0 +1,801 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Adjust subplot layouts so that there are no overlapping Axes or Axes
|
| 3 |
+
decorations. All Axes decorations are dealt with (labels, ticks, titles,
|
| 4 |
+
ticklabels) and some dependent artists are also dealt with (colorbar,
|
| 5 |
+
suptitle).
|
| 6 |
+
|
| 7 |
+
Layout is done via `~matplotlib.gridspec`, with one constraint per gridspec,
|
| 8 |
+
so it is possible to have overlapping Axes if the gridspecs overlap (i.e.
|
| 9 |
+
using `~matplotlib.gridspec.GridSpecFromSubplotSpec`). Axes placed using
|
| 10 |
+
``figure.subplots()`` or ``figure.add_subplots()`` will participate in the
|
| 11 |
+
layout. Axes manually placed via ``figure.add_axes()`` will not.
|
| 12 |
+
|
| 13 |
+
See Tutorial: :ref:`constrainedlayout_guide`
|
| 14 |
+
|
| 15 |
+
General idea:
|
| 16 |
+
-------------
|
| 17 |
+
|
| 18 |
+
First, a figure has a gridspec that divides the figure into nrows and ncols,
|
| 19 |
+
with heights and widths set by ``height_ratios`` and ``width_ratios``,
|
| 20 |
+
often just set to 1 for an equal grid.
|
| 21 |
+
|
| 22 |
+
Subplotspecs that are derived from this gridspec can contain either a
|
| 23 |
+
``SubPanel``, a ``GridSpecFromSubplotSpec``, or an ``Axes``. The ``SubPanel``
|
| 24 |
+
and ``GridSpecFromSubplotSpec`` are dealt with recursively and each contain an
|
| 25 |
+
analogous layout.
|
| 26 |
+
|
| 27 |
+
Each ``GridSpec`` has a ``_layoutgrid`` attached to it. The ``_layoutgrid``
|
| 28 |
+
has the same logical layout as the ``GridSpec``. Each row of the grid spec
|
| 29 |
+
has a top and bottom "margin" and each column has a left and right "margin".
|
| 30 |
+
The "inner" height of each row is constrained to be the same (or as modified
|
| 31 |
+
by ``height_ratio``), and the "inner" width of each column is
|
| 32 |
+
constrained to be the same (as modified by ``width_ratio``), where "inner"
|
| 33 |
+
is the width or height of each column/row minus the size of the margins.
|
| 34 |
+
|
| 35 |
+
Then the size of the margins for each row and column are determined as the
|
| 36 |
+
max width of the decorators on each Axes that has decorators in that margin.
|
| 37 |
+
For instance, a normal Axes would have a left margin that includes the
|
| 38 |
+
left ticklabels, and the ylabel if it exists. The right margin may include a
|
| 39 |
+
colorbar, the bottom margin the xaxis decorations, and the top margin the
|
| 40 |
+
title.
|
| 41 |
+
|
| 42 |
+
With these constraints, the solver then finds appropriate bounds for the
|
| 43 |
+
columns and rows. It's possible that the margins take up the whole figure,
|
| 44 |
+
in which case the algorithm is not applied and a warning is raised.
|
| 45 |
+
|
| 46 |
+
See the tutorial :ref:`constrainedlayout_guide`
|
| 47 |
+
for more discussion of the algorithm with examples.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
import logging
|
| 51 |
+
|
| 52 |
+
import numpy as np
|
| 53 |
+
|
| 54 |
+
from matplotlib import _api, artist as martist
|
| 55 |
+
import matplotlib.transforms as mtransforms
|
| 56 |
+
import matplotlib._layoutgrid as mlayoutgrid
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
_log = logging.getLogger(__name__)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
######################################################
|
| 63 |
+
def do_constrained_layout(fig, h_pad, w_pad,
|
| 64 |
+
hspace=None, wspace=None, rect=(0, 0, 1, 1),
|
| 65 |
+
compress=False):
|
| 66 |
+
"""
|
| 67 |
+
Do the constrained_layout. Called at draw time in
|
| 68 |
+
``figure.constrained_layout()``
|
| 69 |
+
|
| 70 |
+
Parameters
|
| 71 |
+
----------
|
| 72 |
+
fig : `~matplotlib.figure.Figure`
|
| 73 |
+
`.Figure` instance to do the layout in.
|
| 74 |
+
|
| 75 |
+
h_pad, w_pad : float
|
| 76 |
+
Padding around the Axes elements in figure-normalized units.
|
| 77 |
+
|
| 78 |
+
hspace, wspace : float
|
| 79 |
+
Fraction of the figure to dedicate to space between the
|
| 80 |
+
Axes. These are evenly spread between the gaps between the Axes.
|
| 81 |
+
A value of 0.2 for a three-column layout would have a space
|
| 82 |
+
of 0.1 of the figure width between each column.
|
| 83 |
+
If h/wspace < h/w_pad, then the pads are used instead.
|
| 84 |
+
|
| 85 |
+
rect : tuple of 4 floats
|
| 86 |
+
Rectangle in figure coordinates to perform constrained layout in
|
| 87 |
+
[left, bottom, width, height], each from 0-1.
|
| 88 |
+
|
| 89 |
+
compress : bool
|
| 90 |
+
Whether to shift Axes so that white space in between them is
|
| 91 |
+
removed. This is useful for simple grids of fixed-aspect Axes (e.g.
|
| 92 |
+
a grid of images).
|
| 93 |
+
|
| 94 |
+
Returns
|
| 95 |
+
-------
|
| 96 |
+
layoutgrid : private debugging structure
|
| 97 |
+
"""
|
| 98 |
+
|
| 99 |
+
renderer = fig._get_renderer()
|
| 100 |
+
# make layoutgrid tree...
|
| 101 |
+
layoutgrids = make_layoutgrids(fig, None, rect=rect)
|
| 102 |
+
if not layoutgrids['hasgrids']:
|
| 103 |
+
_api.warn_external('There are no gridspecs with layoutgrids. '
|
| 104 |
+
'Possibly did not call parent GridSpec with the'
|
| 105 |
+
' "figure" keyword')
|
| 106 |
+
return
|
| 107 |
+
|
| 108 |
+
for _ in range(2):
|
| 109 |
+
# do the algorithm twice. This has to be done because decorations
|
| 110 |
+
# change size after the first re-position (i.e. x/yticklabels get
|
| 111 |
+
# larger/smaller). This second reposition tends to be much milder,
|
| 112 |
+
# so doing twice makes things work OK.
|
| 113 |
+
|
| 114 |
+
# make margins for all the Axes and subfigures in the
|
| 115 |
+
# figure. Add margins for colorbars...
|
| 116 |
+
make_layout_margins(layoutgrids, fig, renderer, h_pad=h_pad,
|
| 117 |
+
w_pad=w_pad, hspace=hspace, wspace=wspace)
|
| 118 |
+
make_margin_suptitles(layoutgrids, fig, renderer, h_pad=h_pad,
|
| 119 |
+
w_pad=w_pad)
|
| 120 |
+
|
| 121 |
+
# if a layout is such that a columns (or rows) margin has no
|
| 122 |
+
# constraints, we need to make all such instances in the grid
|
| 123 |
+
# match in margin size.
|
| 124 |
+
match_submerged_margins(layoutgrids, fig)
|
| 125 |
+
|
| 126 |
+
# update all the variables in the layout.
|
| 127 |
+
layoutgrids[fig].update_variables()
|
| 128 |
+
|
| 129 |
+
warn_collapsed = ('constrained_layout not applied because '
|
| 130 |
+
'axes sizes collapsed to zero. Try making '
|
| 131 |
+
'figure larger or Axes decorations smaller.')
|
| 132 |
+
if check_no_collapsed_axes(layoutgrids, fig):
|
| 133 |
+
reposition_axes(layoutgrids, fig, renderer, h_pad=h_pad,
|
| 134 |
+
w_pad=w_pad, hspace=hspace, wspace=wspace)
|
| 135 |
+
if compress:
|
| 136 |
+
layoutgrids = compress_fixed_aspect(layoutgrids, fig)
|
| 137 |
+
layoutgrids[fig].update_variables()
|
| 138 |
+
if check_no_collapsed_axes(layoutgrids, fig):
|
| 139 |
+
reposition_axes(layoutgrids, fig, renderer, h_pad=h_pad,
|
| 140 |
+
w_pad=w_pad, hspace=hspace, wspace=wspace)
|
| 141 |
+
else:
|
| 142 |
+
_api.warn_external(warn_collapsed)
|
| 143 |
+
|
| 144 |
+
if ((suptitle := fig._suptitle) is not None and
|
| 145 |
+
suptitle.get_in_layout() and suptitle._autopos):
|
| 146 |
+
x, _ = suptitle.get_position()
|
| 147 |
+
suptitle.set_position(
|
| 148 |
+
(x, layoutgrids[fig].get_inner_bbox().y1 + h_pad))
|
| 149 |
+
suptitle.set_verticalalignment('bottom')
|
| 150 |
+
else:
|
| 151 |
+
_api.warn_external(warn_collapsed)
|
| 152 |
+
reset_margins(layoutgrids, fig)
|
| 153 |
+
return layoutgrids
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def make_layoutgrids(fig, layoutgrids, rect=(0, 0, 1, 1)):
|
| 157 |
+
"""
|
| 158 |
+
Make the layoutgrid tree.
|
| 159 |
+
|
| 160 |
+
(Sub)Figures get a layoutgrid so we can have figure margins.
|
| 161 |
+
|
| 162 |
+
Gridspecs that are attached to Axes get a layoutgrid so Axes
|
| 163 |
+
can have margins.
|
| 164 |
+
"""
|
| 165 |
+
|
| 166 |
+
if layoutgrids is None:
|
| 167 |
+
layoutgrids = dict()
|
| 168 |
+
layoutgrids['hasgrids'] = False
|
| 169 |
+
if not hasattr(fig, '_parent'):
|
| 170 |
+
# top figure; pass rect as parent to allow user-specified
|
| 171 |
+
# margins
|
| 172 |
+
layoutgrids[fig] = mlayoutgrid.LayoutGrid(parent=rect, name='figlb')
|
| 173 |
+
else:
|
| 174 |
+
# subfigure
|
| 175 |
+
gs = fig._subplotspec.get_gridspec()
|
| 176 |
+
# it is possible the gridspec containing this subfigure hasn't
|
| 177 |
+
# been added to the tree yet:
|
| 178 |
+
layoutgrids = make_layoutgrids_gs(layoutgrids, gs)
|
| 179 |
+
# add the layoutgrid for the subfigure:
|
| 180 |
+
parentlb = layoutgrids[gs]
|
| 181 |
+
layoutgrids[fig] = mlayoutgrid.LayoutGrid(
|
| 182 |
+
parent=parentlb,
|
| 183 |
+
name='panellb',
|
| 184 |
+
parent_inner=True,
|
| 185 |
+
nrows=1, ncols=1,
|
| 186 |
+
parent_pos=(fig._subplotspec.rowspan,
|
| 187 |
+
fig._subplotspec.colspan))
|
| 188 |
+
# recursively do all subfigures in this figure...
|
| 189 |
+
for sfig in fig.subfigs:
|
| 190 |
+
layoutgrids = make_layoutgrids(sfig, layoutgrids)
|
| 191 |
+
|
| 192 |
+
# for each Axes at the local level add its gridspec:
|
| 193 |
+
for ax in fig._localaxes:
|
| 194 |
+
gs = ax.get_gridspec()
|
| 195 |
+
if gs is not None:
|
| 196 |
+
layoutgrids = make_layoutgrids_gs(layoutgrids, gs)
|
| 197 |
+
|
| 198 |
+
return layoutgrids
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def make_layoutgrids_gs(layoutgrids, gs):
|
| 202 |
+
"""
|
| 203 |
+
Make the layoutgrid for a gridspec (and anything nested in the gridspec)
|
| 204 |
+
"""
|
| 205 |
+
|
| 206 |
+
if gs in layoutgrids or gs.figure is None:
|
| 207 |
+
return layoutgrids
|
| 208 |
+
# in order to do constrained_layout there has to be at least *one*
|
| 209 |
+
# gridspec in the tree:
|
| 210 |
+
layoutgrids['hasgrids'] = True
|
| 211 |
+
if not hasattr(gs, '_subplot_spec'):
|
| 212 |
+
# normal gridspec
|
| 213 |
+
parent = layoutgrids[gs.figure]
|
| 214 |
+
layoutgrids[gs] = mlayoutgrid.LayoutGrid(
|
| 215 |
+
parent=parent,
|
| 216 |
+
parent_inner=True,
|
| 217 |
+
name='gridspec',
|
| 218 |
+
ncols=gs._ncols, nrows=gs._nrows,
|
| 219 |
+
width_ratios=gs.get_width_ratios(),
|
| 220 |
+
height_ratios=gs.get_height_ratios())
|
| 221 |
+
else:
|
| 222 |
+
# this is a gridspecfromsubplotspec:
|
| 223 |
+
subplot_spec = gs._subplot_spec
|
| 224 |
+
parentgs = subplot_spec.get_gridspec()
|
| 225 |
+
# if a nested gridspec it is possible the parent is not in there yet:
|
| 226 |
+
if parentgs not in layoutgrids:
|
| 227 |
+
layoutgrids = make_layoutgrids_gs(layoutgrids, parentgs)
|
| 228 |
+
subspeclb = layoutgrids[parentgs]
|
| 229 |
+
# gridspecfromsubplotspec need an outer container:
|
| 230 |
+
# get a unique representation:
|
| 231 |
+
rep = (gs, 'top')
|
| 232 |
+
if rep not in layoutgrids:
|
| 233 |
+
layoutgrids[rep] = mlayoutgrid.LayoutGrid(
|
| 234 |
+
parent=subspeclb,
|
| 235 |
+
name='top',
|
| 236 |
+
nrows=1, ncols=1,
|
| 237 |
+
parent_pos=(subplot_spec.rowspan, subplot_spec.colspan))
|
| 238 |
+
layoutgrids[gs] = mlayoutgrid.LayoutGrid(
|
| 239 |
+
parent=layoutgrids[rep],
|
| 240 |
+
name='gridspec',
|
| 241 |
+
nrows=gs._nrows, ncols=gs._ncols,
|
| 242 |
+
width_ratios=gs.get_width_ratios(),
|
| 243 |
+
height_ratios=gs.get_height_ratios())
|
| 244 |
+
return layoutgrids
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
def check_no_collapsed_axes(layoutgrids, fig):
|
| 248 |
+
"""
|
| 249 |
+
Check that no Axes have collapsed to zero size.
|
| 250 |
+
"""
|
| 251 |
+
for sfig in fig.subfigs:
|
| 252 |
+
ok = check_no_collapsed_axes(layoutgrids, sfig)
|
| 253 |
+
if not ok:
|
| 254 |
+
return False
|
| 255 |
+
for ax in fig.axes:
|
| 256 |
+
gs = ax.get_gridspec()
|
| 257 |
+
if gs in layoutgrids: # also implies gs is not None.
|
| 258 |
+
lg = layoutgrids[gs]
|
| 259 |
+
for i in range(gs.nrows):
|
| 260 |
+
for j in range(gs.ncols):
|
| 261 |
+
bb = lg.get_inner_bbox(i, j)
|
| 262 |
+
if bb.width <= 0 or bb.height <= 0:
|
| 263 |
+
return False
|
| 264 |
+
return True
|
| 265 |
+
|
| 266 |
+
|
| 267 |
+
def compress_fixed_aspect(layoutgrids, fig):
|
| 268 |
+
gs = None
|
| 269 |
+
for ax in fig.axes:
|
| 270 |
+
if ax.get_subplotspec() is None:
|
| 271 |
+
continue
|
| 272 |
+
ax.apply_aspect()
|
| 273 |
+
sub = ax.get_subplotspec()
|
| 274 |
+
_gs = sub.get_gridspec()
|
| 275 |
+
if gs is None:
|
| 276 |
+
gs = _gs
|
| 277 |
+
extraw = np.zeros(gs.ncols)
|
| 278 |
+
extrah = np.zeros(gs.nrows)
|
| 279 |
+
elif _gs != gs:
|
| 280 |
+
raise ValueError('Cannot do compressed layout if Axes are not'
|
| 281 |
+
'all from the same gridspec')
|
| 282 |
+
orig = ax.get_position(original=True)
|
| 283 |
+
actual = ax.get_position(original=False)
|
| 284 |
+
dw = orig.width - actual.width
|
| 285 |
+
if dw > 0:
|
| 286 |
+
extraw[sub.colspan] = np.maximum(extraw[sub.colspan], dw)
|
| 287 |
+
dh = orig.height - actual.height
|
| 288 |
+
if dh > 0:
|
| 289 |
+
extrah[sub.rowspan] = np.maximum(extrah[sub.rowspan], dh)
|
| 290 |
+
|
| 291 |
+
if gs is None:
|
| 292 |
+
raise ValueError('Cannot do compressed layout if no Axes '
|
| 293 |
+
'are part of a gridspec.')
|
| 294 |
+
w = np.sum(extraw) / 2
|
| 295 |
+
layoutgrids[fig].edit_margin_min('left', w)
|
| 296 |
+
layoutgrids[fig].edit_margin_min('right', w)
|
| 297 |
+
|
| 298 |
+
h = np.sum(extrah) / 2
|
| 299 |
+
layoutgrids[fig].edit_margin_min('top', h)
|
| 300 |
+
layoutgrids[fig].edit_margin_min('bottom', h)
|
| 301 |
+
return layoutgrids
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
def get_margin_from_padding(obj, *, w_pad=0, h_pad=0,
|
| 305 |
+
hspace=0, wspace=0):
|
| 306 |
+
|
| 307 |
+
ss = obj._subplotspec
|
| 308 |
+
gs = ss.get_gridspec()
|
| 309 |
+
|
| 310 |
+
if hasattr(gs, 'hspace'):
|
| 311 |
+
_hspace = (gs.hspace if gs.hspace is not None else hspace)
|
| 312 |
+
_wspace = (gs.wspace if gs.wspace is not None else wspace)
|
| 313 |
+
else:
|
| 314 |
+
_hspace = (gs._hspace if gs._hspace is not None else hspace)
|
| 315 |
+
_wspace = (gs._wspace if gs._wspace is not None else wspace)
|
| 316 |
+
|
| 317 |
+
_wspace = _wspace / 2
|
| 318 |
+
_hspace = _hspace / 2
|
| 319 |
+
|
| 320 |
+
nrows, ncols = gs.get_geometry()
|
| 321 |
+
# there are two margins for each direction. The "cb"
|
| 322 |
+
# margins are for pads and colorbars, the non-"cb" are
|
| 323 |
+
# for the Axes decorations (labels etc).
|
| 324 |
+
margin = {'leftcb': w_pad, 'rightcb': w_pad,
|
| 325 |
+
'bottomcb': h_pad, 'topcb': h_pad,
|
| 326 |
+
'left': 0, 'right': 0,
|
| 327 |
+
'top': 0, 'bottom': 0}
|
| 328 |
+
if _wspace / ncols > w_pad:
|
| 329 |
+
if ss.colspan.start > 0:
|
| 330 |
+
margin['leftcb'] = _wspace / ncols
|
| 331 |
+
if ss.colspan.stop < ncols:
|
| 332 |
+
margin['rightcb'] = _wspace / ncols
|
| 333 |
+
if _hspace / nrows > h_pad:
|
| 334 |
+
if ss.rowspan.stop < nrows:
|
| 335 |
+
margin['bottomcb'] = _hspace / nrows
|
| 336 |
+
if ss.rowspan.start > 0:
|
| 337 |
+
margin['topcb'] = _hspace / nrows
|
| 338 |
+
|
| 339 |
+
return margin
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
def make_layout_margins(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0,
|
| 343 |
+
hspace=0, wspace=0):
|
| 344 |
+
"""
|
| 345 |
+
For each Axes, make a margin between the *pos* layoutbox and the
|
| 346 |
+
*axes* layoutbox be a minimum size that can accommodate the
|
| 347 |
+
decorations on the axis.
|
| 348 |
+
|
| 349 |
+
Then make room for colorbars.
|
| 350 |
+
|
| 351 |
+
Parameters
|
| 352 |
+
----------
|
| 353 |
+
layoutgrids : dict
|
| 354 |
+
fig : `~matplotlib.figure.Figure`
|
| 355 |
+
`.Figure` instance to do the layout in.
|
| 356 |
+
renderer : `~matplotlib.backend_bases.RendererBase` subclass.
|
| 357 |
+
The renderer to use.
|
| 358 |
+
w_pad, h_pad : float, default: 0
|
| 359 |
+
Width and height padding (in fraction of figure).
|
| 360 |
+
hspace, wspace : float, default: 0
|
| 361 |
+
Width and height padding as fraction of figure size divided by
|
| 362 |
+
number of columns or rows.
|
| 363 |
+
"""
|
| 364 |
+
for sfig in fig.subfigs: # recursively make child panel margins
|
| 365 |
+
ss = sfig._subplotspec
|
| 366 |
+
gs = ss.get_gridspec()
|
| 367 |
+
|
| 368 |
+
make_layout_margins(layoutgrids, sfig, renderer,
|
| 369 |
+
w_pad=w_pad, h_pad=h_pad,
|
| 370 |
+
hspace=hspace, wspace=wspace)
|
| 371 |
+
|
| 372 |
+
margins = get_margin_from_padding(sfig, w_pad=0, h_pad=0,
|
| 373 |
+
hspace=hspace, wspace=wspace)
|
| 374 |
+
layoutgrids[gs].edit_outer_margin_mins(margins, ss)
|
| 375 |
+
|
| 376 |
+
for ax in fig._localaxes:
|
| 377 |
+
if not ax.get_subplotspec() or not ax.get_in_layout():
|
| 378 |
+
continue
|
| 379 |
+
|
| 380 |
+
ss = ax.get_subplotspec()
|
| 381 |
+
gs = ss.get_gridspec()
|
| 382 |
+
|
| 383 |
+
if gs not in layoutgrids:
|
| 384 |
+
return
|
| 385 |
+
|
| 386 |
+
margin = get_margin_from_padding(ax, w_pad=w_pad, h_pad=h_pad,
|
| 387 |
+
hspace=hspace, wspace=wspace)
|
| 388 |
+
pos, bbox = get_pos_and_bbox(ax, renderer)
|
| 389 |
+
# the margin is the distance between the bounding box of the Axes
|
| 390 |
+
# and its position (plus the padding from above)
|
| 391 |
+
margin['left'] += pos.x0 - bbox.x0
|
| 392 |
+
margin['right'] += bbox.x1 - pos.x1
|
| 393 |
+
# remember that rows are ordered from top:
|
| 394 |
+
margin['bottom'] += pos.y0 - bbox.y0
|
| 395 |
+
margin['top'] += bbox.y1 - pos.y1
|
| 396 |
+
|
| 397 |
+
# make margin for colorbars. These margins go in the
|
| 398 |
+
# padding margin, versus the margin for Axes decorators.
|
| 399 |
+
for cbax in ax._colorbars:
|
| 400 |
+
# note pad is a fraction of the parent width...
|
| 401 |
+
pad = colorbar_get_pad(layoutgrids, cbax)
|
| 402 |
+
# colorbars can be child of more than one subplot spec:
|
| 403 |
+
cbp_rspan, cbp_cspan = get_cb_parent_spans(cbax)
|
| 404 |
+
loc = cbax._colorbar_info['location']
|
| 405 |
+
cbpos, cbbbox = get_pos_and_bbox(cbax, renderer)
|
| 406 |
+
if loc == 'right':
|
| 407 |
+
if cbp_cspan.stop == ss.colspan.stop:
|
| 408 |
+
# only increase if the colorbar is on the right edge
|
| 409 |
+
margin['rightcb'] += cbbbox.width + pad
|
| 410 |
+
elif loc == 'left':
|
| 411 |
+
if cbp_cspan.start == ss.colspan.start:
|
| 412 |
+
# only increase if the colorbar is on the left edge
|
| 413 |
+
margin['leftcb'] += cbbbox.width + pad
|
| 414 |
+
elif loc == 'top':
|
| 415 |
+
if cbp_rspan.start == ss.rowspan.start:
|
| 416 |
+
margin['topcb'] += cbbbox.height + pad
|
| 417 |
+
else:
|
| 418 |
+
if cbp_rspan.stop == ss.rowspan.stop:
|
| 419 |
+
margin['bottomcb'] += cbbbox.height + pad
|
| 420 |
+
# If the colorbars are wider than the parent box in the
|
| 421 |
+
# cross direction
|
| 422 |
+
if loc in ['top', 'bottom']:
|
| 423 |
+
if (cbp_cspan.start == ss.colspan.start and
|
| 424 |
+
cbbbox.x0 < bbox.x0):
|
| 425 |
+
margin['left'] += bbox.x0 - cbbbox.x0
|
| 426 |
+
if (cbp_cspan.stop == ss.colspan.stop and
|
| 427 |
+
cbbbox.x1 > bbox.x1):
|
| 428 |
+
margin['right'] += cbbbox.x1 - bbox.x1
|
| 429 |
+
# or taller:
|
| 430 |
+
if loc in ['left', 'right']:
|
| 431 |
+
if (cbp_rspan.stop == ss.rowspan.stop and
|
| 432 |
+
cbbbox.y0 < bbox.y0):
|
| 433 |
+
margin['bottom'] += bbox.y0 - cbbbox.y0
|
| 434 |
+
if (cbp_rspan.start == ss.rowspan.start and
|
| 435 |
+
cbbbox.y1 > bbox.y1):
|
| 436 |
+
margin['top'] += cbbbox.y1 - bbox.y1
|
| 437 |
+
# pass the new margins down to the layout grid for the solution...
|
| 438 |
+
layoutgrids[gs].edit_outer_margin_mins(margin, ss)
|
| 439 |
+
|
| 440 |
+
# make margins for figure-level legends:
|
| 441 |
+
for leg in fig.legends:
|
| 442 |
+
inv_trans_fig = None
|
| 443 |
+
if leg._outside_loc and leg._bbox_to_anchor is None:
|
| 444 |
+
if inv_trans_fig is None:
|
| 445 |
+
inv_trans_fig = fig.transFigure.inverted().transform_bbox
|
| 446 |
+
bbox = inv_trans_fig(leg.get_tightbbox(renderer))
|
| 447 |
+
w = bbox.width + 2 * w_pad
|
| 448 |
+
h = bbox.height + 2 * h_pad
|
| 449 |
+
legendloc = leg._outside_loc
|
| 450 |
+
if legendloc == 'lower':
|
| 451 |
+
layoutgrids[fig].edit_margin_min('bottom', h)
|
| 452 |
+
elif legendloc == 'upper':
|
| 453 |
+
layoutgrids[fig].edit_margin_min('top', h)
|
| 454 |
+
if legendloc == 'right':
|
| 455 |
+
layoutgrids[fig].edit_margin_min('right', w)
|
| 456 |
+
elif legendloc == 'left':
|
| 457 |
+
layoutgrids[fig].edit_margin_min('left', w)
|
| 458 |
+
|
| 459 |
+
|
| 460 |
+
def make_margin_suptitles(layoutgrids, fig, renderer, *, w_pad=0, h_pad=0):
|
| 461 |
+
# Figure out how large the suptitle is and make the
|
| 462 |
+
# top level figure margin larger.
|
| 463 |
+
|
| 464 |
+
inv_trans_fig = fig.transFigure.inverted().transform_bbox
|
| 465 |
+
# get the h_pad and w_pad as distances in the local subfigure coordinates:
|
| 466 |
+
padbox = mtransforms.Bbox([[0, 0], [w_pad, h_pad]])
|
| 467 |
+
padbox = (fig.transFigure -
|
| 468 |
+
fig.transSubfigure).transform_bbox(padbox)
|
| 469 |
+
h_pad_local = padbox.height
|
| 470 |
+
w_pad_local = padbox.width
|
| 471 |
+
|
| 472 |
+
for sfig in fig.subfigs:
|
| 473 |
+
make_margin_suptitles(layoutgrids, sfig, renderer,
|
| 474 |
+
w_pad=w_pad, h_pad=h_pad)
|
| 475 |
+
|
| 476 |
+
if fig._suptitle is not None and fig._suptitle.get_in_layout():
|
| 477 |
+
p = fig._suptitle.get_position()
|
| 478 |
+
if getattr(fig._suptitle, '_autopos', False):
|
| 479 |
+
fig._suptitle.set_position((p[0], 1 - h_pad_local))
|
| 480 |
+
bbox = inv_trans_fig(fig._suptitle.get_tightbbox(renderer))
|
| 481 |
+
layoutgrids[fig].edit_margin_min('top', bbox.height + 2 * h_pad)
|
| 482 |
+
|
| 483 |
+
if fig._supxlabel is not None and fig._supxlabel.get_in_layout():
|
| 484 |
+
p = fig._supxlabel.get_position()
|
| 485 |
+
if getattr(fig._supxlabel, '_autopos', False):
|
| 486 |
+
fig._supxlabel.set_position((p[0], h_pad_local))
|
| 487 |
+
bbox = inv_trans_fig(fig._supxlabel.get_tightbbox(renderer))
|
| 488 |
+
layoutgrids[fig].edit_margin_min('bottom',
|
| 489 |
+
bbox.height + 2 * h_pad)
|
| 490 |
+
|
| 491 |
+
if fig._supylabel is not None and fig._supylabel.get_in_layout():
|
| 492 |
+
p = fig._supylabel.get_position()
|
| 493 |
+
if getattr(fig._supylabel, '_autopos', False):
|
| 494 |
+
fig._supylabel.set_position((w_pad_local, p[1]))
|
| 495 |
+
bbox = inv_trans_fig(fig._supylabel.get_tightbbox(renderer))
|
| 496 |
+
layoutgrids[fig].edit_margin_min('left', bbox.width + 2 * w_pad)
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
def match_submerged_margins(layoutgrids, fig):
|
| 500 |
+
"""
|
| 501 |
+
Make the margins that are submerged inside an Axes the same size.
|
| 502 |
+
|
| 503 |
+
This allows Axes that span two columns (or rows) that are offset
|
| 504 |
+
from one another to have the same size.
|
| 505 |
+
|
| 506 |
+
This gives the proper layout for something like::
|
| 507 |
+
fig = plt.figure(constrained_layout=True)
|
| 508 |
+
axs = fig.subplot_mosaic("AAAB\nCCDD")
|
| 509 |
+
|
| 510 |
+
Without this routine, the Axes D will be wider than C, because the
|
| 511 |
+
margin width between the two columns in C has no width by default,
|
| 512 |
+
whereas the margins between the two columns of D are set by the
|
| 513 |
+
width of the margin between A and B. However, obviously the user would
|
| 514 |
+
like C and D to be the same size, so we need to add constraints to these
|
| 515 |
+
"submerged" margins.
|
| 516 |
+
|
| 517 |
+
This routine makes all the interior margins the same, and the spacing
|
| 518 |
+
between the three columns in A and the two column in C are all set to the
|
| 519 |
+
margins between the two columns of D.
|
| 520 |
+
|
| 521 |
+
See test_constrained_layout::test_constrained_layout12 for an example.
|
| 522 |
+
"""
|
| 523 |
+
|
| 524 |
+
for sfig in fig.subfigs:
|
| 525 |
+
match_submerged_margins(layoutgrids, sfig)
|
| 526 |
+
|
| 527 |
+
axs = [a for a in fig.get_axes()
|
| 528 |
+
if a.get_subplotspec() is not None and a.get_in_layout()]
|
| 529 |
+
|
| 530 |
+
for ax1 in axs:
|
| 531 |
+
ss1 = ax1.get_subplotspec()
|
| 532 |
+
if ss1.get_gridspec() not in layoutgrids:
|
| 533 |
+
axs.remove(ax1)
|
| 534 |
+
continue
|
| 535 |
+
lg1 = layoutgrids[ss1.get_gridspec()]
|
| 536 |
+
|
| 537 |
+
# interior columns:
|
| 538 |
+
if len(ss1.colspan) > 1:
|
| 539 |
+
maxsubl = np.max(
|
| 540 |
+
lg1.margin_vals['left'][ss1.colspan[1:]] +
|
| 541 |
+
lg1.margin_vals['leftcb'][ss1.colspan[1:]]
|
| 542 |
+
)
|
| 543 |
+
maxsubr = np.max(
|
| 544 |
+
lg1.margin_vals['right'][ss1.colspan[:-1]] +
|
| 545 |
+
lg1.margin_vals['rightcb'][ss1.colspan[:-1]]
|
| 546 |
+
)
|
| 547 |
+
for ax2 in axs:
|
| 548 |
+
ss2 = ax2.get_subplotspec()
|
| 549 |
+
lg2 = layoutgrids[ss2.get_gridspec()]
|
| 550 |
+
if lg2 is not None and len(ss2.colspan) > 1:
|
| 551 |
+
maxsubl2 = np.max(
|
| 552 |
+
lg2.margin_vals['left'][ss2.colspan[1:]] +
|
| 553 |
+
lg2.margin_vals['leftcb'][ss2.colspan[1:]])
|
| 554 |
+
if maxsubl2 > maxsubl:
|
| 555 |
+
maxsubl = maxsubl2
|
| 556 |
+
maxsubr2 = np.max(
|
| 557 |
+
lg2.margin_vals['right'][ss2.colspan[:-1]] +
|
| 558 |
+
lg2.margin_vals['rightcb'][ss2.colspan[:-1]])
|
| 559 |
+
if maxsubr2 > maxsubr:
|
| 560 |
+
maxsubr = maxsubr2
|
| 561 |
+
for i in ss1.colspan[1:]:
|
| 562 |
+
lg1.edit_margin_min('left', maxsubl, cell=i)
|
| 563 |
+
for i in ss1.colspan[:-1]:
|
| 564 |
+
lg1.edit_margin_min('right', maxsubr, cell=i)
|
| 565 |
+
|
| 566 |
+
# interior rows:
|
| 567 |
+
if len(ss1.rowspan) > 1:
|
| 568 |
+
maxsubt = np.max(
|
| 569 |
+
lg1.margin_vals['top'][ss1.rowspan[1:]] +
|
| 570 |
+
lg1.margin_vals['topcb'][ss1.rowspan[1:]]
|
| 571 |
+
)
|
| 572 |
+
maxsubb = np.max(
|
| 573 |
+
lg1.margin_vals['bottom'][ss1.rowspan[:-1]] +
|
| 574 |
+
lg1.margin_vals['bottomcb'][ss1.rowspan[:-1]]
|
| 575 |
+
)
|
| 576 |
+
|
| 577 |
+
for ax2 in axs:
|
| 578 |
+
ss2 = ax2.get_subplotspec()
|
| 579 |
+
lg2 = layoutgrids[ss2.get_gridspec()]
|
| 580 |
+
if lg2 is not None:
|
| 581 |
+
if len(ss2.rowspan) > 1:
|
| 582 |
+
maxsubt = np.max([np.max(
|
| 583 |
+
lg2.margin_vals['top'][ss2.rowspan[1:]] +
|
| 584 |
+
lg2.margin_vals['topcb'][ss2.rowspan[1:]]
|
| 585 |
+
), maxsubt])
|
| 586 |
+
maxsubb = np.max([np.max(
|
| 587 |
+
lg2.margin_vals['bottom'][ss2.rowspan[:-1]] +
|
| 588 |
+
lg2.margin_vals['bottomcb'][ss2.rowspan[:-1]]
|
| 589 |
+
), maxsubb])
|
| 590 |
+
for i in ss1.rowspan[1:]:
|
| 591 |
+
lg1.edit_margin_min('top', maxsubt, cell=i)
|
| 592 |
+
for i in ss1.rowspan[:-1]:
|
| 593 |
+
lg1.edit_margin_min('bottom', maxsubb, cell=i)
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
def get_cb_parent_spans(cbax):
|
| 597 |
+
"""
|
| 598 |
+
Figure out which subplotspecs this colorbar belongs to.
|
| 599 |
+
|
| 600 |
+
Parameters
|
| 601 |
+
----------
|
| 602 |
+
cbax : `~matplotlib.axes.Axes`
|
| 603 |
+
Axes for the colorbar.
|
| 604 |
+
"""
|
| 605 |
+
rowstart = np.inf
|
| 606 |
+
rowstop = -np.inf
|
| 607 |
+
colstart = np.inf
|
| 608 |
+
colstop = -np.inf
|
| 609 |
+
for parent in cbax._colorbar_info['parents']:
|
| 610 |
+
ss = parent.get_subplotspec()
|
| 611 |
+
rowstart = min(ss.rowspan.start, rowstart)
|
| 612 |
+
rowstop = max(ss.rowspan.stop, rowstop)
|
| 613 |
+
colstart = min(ss.colspan.start, colstart)
|
| 614 |
+
colstop = max(ss.colspan.stop, colstop)
|
| 615 |
+
|
| 616 |
+
rowspan = range(rowstart, rowstop)
|
| 617 |
+
colspan = range(colstart, colstop)
|
| 618 |
+
return rowspan, colspan
|
| 619 |
+
|
| 620 |
+
|
| 621 |
+
def get_pos_and_bbox(ax, renderer):
|
| 622 |
+
"""
|
| 623 |
+
Get the position and the bbox for the Axes.
|
| 624 |
+
|
| 625 |
+
Parameters
|
| 626 |
+
----------
|
| 627 |
+
ax : `~matplotlib.axes.Axes`
|
| 628 |
+
renderer : `~matplotlib.backend_bases.RendererBase` subclass.
|
| 629 |
+
|
| 630 |
+
Returns
|
| 631 |
+
-------
|
| 632 |
+
pos : `~matplotlib.transforms.Bbox`
|
| 633 |
+
Position in figure coordinates.
|
| 634 |
+
bbox : `~matplotlib.transforms.Bbox`
|
| 635 |
+
Tight bounding box in figure coordinates.
|
| 636 |
+
"""
|
| 637 |
+
fig = ax.get_figure(root=False)
|
| 638 |
+
pos = ax.get_position(original=True)
|
| 639 |
+
# pos is in panel co-ords, but we need in figure for the layout
|
| 640 |
+
pos = pos.transformed(fig.transSubfigure - fig.transFigure)
|
| 641 |
+
tightbbox = martist._get_tightbbox_for_layout_only(ax, renderer)
|
| 642 |
+
if tightbbox is None:
|
| 643 |
+
bbox = pos
|
| 644 |
+
else:
|
| 645 |
+
bbox = tightbbox.transformed(fig.transFigure.inverted())
|
| 646 |
+
return pos, bbox
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
def reposition_axes(layoutgrids, fig, renderer, *,
|
| 650 |
+
w_pad=0, h_pad=0, hspace=0, wspace=0):
|
| 651 |
+
"""
|
| 652 |
+
Reposition all the Axes based on the new inner bounding box.
|
| 653 |
+
"""
|
| 654 |
+
trans_fig_to_subfig = fig.transFigure - fig.transSubfigure
|
| 655 |
+
for sfig in fig.subfigs:
|
| 656 |
+
bbox = layoutgrids[sfig].get_outer_bbox()
|
| 657 |
+
sfig._redo_transform_rel_fig(
|
| 658 |
+
bbox=bbox.transformed(trans_fig_to_subfig))
|
| 659 |
+
reposition_axes(layoutgrids, sfig, renderer,
|
| 660 |
+
w_pad=w_pad, h_pad=h_pad,
|
| 661 |
+
wspace=wspace, hspace=hspace)
|
| 662 |
+
|
| 663 |
+
for ax in fig._localaxes:
|
| 664 |
+
if ax.get_subplotspec() is None or not ax.get_in_layout():
|
| 665 |
+
continue
|
| 666 |
+
|
| 667 |
+
# grid bbox is in Figure coordinates, but we specify in panel
|
| 668 |
+
# coordinates...
|
| 669 |
+
ss = ax.get_subplotspec()
|
| 670 |
+
gs = ss.get_gridspec()
|
| 671 |
+
if gs not in layoutgrids:
|
| 672 |
+
return
|
| 673 |
+
|
| 674 |
+
bbox = layoutgrids[gs].get_inner_bbox(rows=ss.rowspan,
|
| 675 |
+
cols=ss.colspan)
|
| 676 |
+
|
| 677 |
+
# transform from figure to panel for set_position:
|
| 678 |
+
newbbox = trans_fig_to_subfig.transform_bbox(bbox)
|
| 679 |
+
ax._set_position(newbbox)
|
| 680 |
+
|
| 681 |
+
# move the colorbars:
|
| 682 |
+
# we need to keep track of oldw and oldh if there is more than
|
| 683 |
+
# one colorbar:
|
| 684 |
+
offset = {'left': 0, 'right': 0, 'bottom': 0, 'top': 0}
|
| 685 |
+
for nn, cbax in enumerate(ax._colorbars[::-1]):
|
| 686 |
+
if ax == cbax._colorbar_info['parents'][0]:
|
| 687 |
+
reposition_colorbar(layoutgrids, cbax, renderer,
|
| 688 |
+
offset=offset)
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
def reposition_colorbar(layoutgrids, cbax, renderer, *, offset=None):
|
| 692 |
+
"""
|
| 693 |
+
Place the colorbar in its new place.
|
| 694 |
+
|
| 695 |
+
Parameters
|
| 696 |
+
----------
|
| 697 |
+
layoutgrids : dict
|
| 698 |
+
cbax : `~matplotlib.axes.Axes`
|
| 699 |
+
Axes for the colorbar.
|
| 700 |
+
renderer : `~matplotlib.backend_bases.RendererBase` subclass.
|
| 701 |
+
The renderer to use.
|
| 702 |
+
offset : array-like
|
| 703 |
+
Offset the colorbar needs to be pushed to in order to
|
| 704 |
+
account for multiple colorbars.
|
| 705 |
+
"""
|
| 706 |
+
|
| 707 |
+
parents = cbax._colorbar_info['parents']
|
| 708 |
+
gs = parents[0].get_gridspec()
|
| 709 |
+
fig = cbax.get_figure(root=False)
|
| 710 |
+
trans_fig_to_subfig = fig.transFigure - fig.transSubfigure
|
| 711 |
+
|
| 712 |
+
cb_rspans, cb_cspans = get_cb_parent_spans(cbax)
|
| 713 |
+
bboxparent = layoutgrids[gs].get_bbox_for_cb(rows=cb_rspans,
|
| 714 |
+
cols=cb_cspans)
|
| 715 |
+
pb = layoutgrids[gs].get_inner_bbox(rows=cb_rspans, cols=cb_cspans)
|
| 716 |
+
|
| 717 |
+
location = cbax._colorbar_info['location']
|
| 718 |
+
anchor = cbax._colorbar_info['anchor']
|
| 719 |
+
fraction = cbax._colorbar_info['fraction']
|
| 720 |
+
aspect = cbax._colorbar_info['aspect']
|
| 721 |
+
shrink = cbax._colorbar_info['shrink']
|
| 722 |
+
|
| 723 |
+
cbpos, cbbbox = get_pos_and_bbox(cbax, renderer)
|
| 724 |
+
|
| 725 |
+
# Colorbar gets put at extreme edge of outer bbox of the subplotspec
|
| 726 |
+
# It needs to be moved in by: 1) a pad 2) its "margin" 3) by
|
| 727 |
+
# any colorbars already added at this location:
|
| 728 |
+
cbpad = colorbar_get_pad(layoutgrids, cbax)
|
| 729 |
+
if location in ('left', 'right'):
|
| 730 |
+
# fraction and shrink are fractions of parent
|
| 731 |
+
pbcb = pb.shrunk(fraction, shrink).anchored(anchor, pb)
|
| 732 |
+
# The colorbar is at the left side of the parent. Need
|
| 733 |
+
# to translate to right (or left)
|
| 734 |
+
if location == 'right':
|
| 735 |
+
lmargin = cbpos.x0 - cbbbox.x0
|
| 736 |
+
dx = bboxparent.x1 - pbcb.x0 + offset['right']
|
| 737 |
+
dx += cbpad + lmargin
|
| 738 |
+
offset['right'] += cbbbox.width + cbpad
|
| 739 |
+
pbcb = pbcb.translated(dx, 0)
|
| 740 |
+
else:
|
| 741 |
+
lmargin = cbpos.x0 - cbbbox.x0
|
| 742 |
+
dx = bboxparent.x0 - pbcb.x0 # edge of parent
|
| 743 |
+
dx += -cbbbox.width - cbpad + lmargin - offset['left']
|
| 744 |
+
offset['left'] += cbbbox.width + cbpad
|
| 745 |
+
pbcb = pbcb.translated(dx, 0)
|
| 746 |
+
else: # horizontal axes:
|
| 747 |
+
pbcb = pb.shrunk(shrink, fraction).anchored(anchor, pb)
|
| 748 |
+
if location == 'top':
|
| 749 |
+
bmargin = cbpos.y0 - cbbbox.y0
|
| 750 |
+
dy = bboxparent.y1 - pbcb.y0 + offset['top']
|
| 751 |
+
dy += cbpad + bmargin
|
| 752 |
+
offset['top'] += cbbbox.height + cbpad
|
| 753 |
+
pbcb = pbcb.translated(0, dy)
|
| 754 |
+
else:
|
| 755 |
+
bmargin = cbpos.y0 - cbbbox.y0
|
| 756 |
+
dy = bboxparent.y0 - pbcb.y0
|
| 757 |
+
dy += -cbbbox.height - cbpad + bmargin - offset['bottom']
|
| 758 |
+
offset['bottom'] += cbbbox.height + cbpad
|
| 759 |
+
pbcb = pbcb.translated(0, dy)
|
| 760 |
+
|
| 761 |
+
pbcb = trans_fig_to_subfig.transform_bbox(pbcb)
|
| 762 |
+
cbax.set_transform(fig.transSubfigure)
|
| 763 |
+
cbax._set_position(pbcb)
|
| 764 |
+
cbax.set_anchor(anchor)
|
| 765 |
+
if location in ['bottom', 'top']:
|
| 766 |
+
aspect = 1 / aspect
|
| 767 |
+
cbax.set_box_aspect(aspect)
|
| 768 |
+
cbax.set_aspect('auto')
|
| 769 |
+
return offset
|
| 770 |
+
|
| 771 |
+
|
| 772 |
+
def reset_margins(layoutgrids, fig):
|
| 773 |
+
"""
|
| 774 |
+
Reset the margins in the layoutboxes of *fig*.
|
| 775 |
+
|
| 776 |
+
Margins are usually set as a minimum, so if the figure gets smaller
|
| 777 |
+
the minimum needs to be zero in order for it to grow again.
|
| 778 |
+
"""
|
| 779 |
+
for sfig in fig.subfigs:
|
| 780 |
+
reset_margins(layoutgrids, sfig)
|
| 781 |
+
for ax in fig.axes:
|
| 782 |
+
if ax.get_in_layout():
|
| 783 |
+
gs = ax.get_gridspec()
|
| 784 |
+
if gs in layoutgrids: # also implies gs is not None.
|
| 785 |
+
layoutgrids[gs].reset_margins()
|
| 786 |
+
layoutgrids[fig].reset_margins()
|
| 787 |
+
|
| 788 |
+
|
| 789 |
+
def colorbar_get_pad(layoutgrids, cax):
|
| 790 |
+
parents = cax._colorbar_info['parents']
|
| 791 |
+
gs = parents[0].get_gridspec()
|
| 792 |
+
|
| 793 |
+
cb_rspans, cb_cspans = get_cb_parent_spans(cax)
|
| 794 |
+
bboxouter = layoutgrids[gs].get_inner_bbox(rows=cb_rspans, cols=cb_cspans)
|
| 795 |
+
|
| 796 |
+
if cax._colorbar_info['location'] in ['right', 'left']:
|
| 797 |
+
size = bboxouter.width
|
| 798 |
+
else:
|
| 799 |
+
size = bboxouter.height
|
| 800 |
+
|
| 801 |
+
return cax._colorbar_info['pad'] * size
|
infer_4_30_0/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()
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_docstring.pyi
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable
|
| 2 |
+
from typing import Any, TypeVar, overload
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
_T = TypeVar('_T')
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def kwarg_doc(text: str) -> Callable[[_T], _T]: ...
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class Substitution:
|
| 12 |
+
@overload
|
| 13 |
+
def __init__(self, *args: str): ...
|
| 14 |
+
@overload
|
| 15 |
+
def __init__(self, **kwargs: str): ...
|
| 16 |
+
def __call__(self, func: _T) -> _T: ...
|
| 17 |
+
def update(self, *args, **kwargs): ... # type: ignore[no-untyped-def]
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class _ArtistKwdocLoader(dict[str, str]):
|
| 21 |
+
def __missing__(self, key: str) -> str: ...
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class _ArtistPropertiesSubstitution:
|
| 25 |
+
def __init__(self) -> None: ...
|
| 26 |
+
def register(self, **kwargs) -> None: ...
|
| 27 |
+
def __call__(self, obj: _T) -> _T: ...
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def copy(source: Any) -> Callable[[_T], _T]: ...
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
dedent_interpd: _ArtistPropertiesSubstitution
|
| 34 |
+
interpd: _ArtistPropertiesSubstitution
|
infer_4_30_0/lib/python3.10/site-packages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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Enums representing sets of strings that Matplotlib uses as input parameters.
|
| 3 |
+
|
| 4 |
+
Matplotlib often uses simple data types like strings or tuples to define a
|
| 5 |
+
concept; e.g. the line capstyle can be specified as one of 'butt', 'round',
|
| 6 |
+
or 'projecting'. The classes in this module are used internally and serve to
|
| 7 |
+
document these concepts formally.
|
| 8 |
+
|
| 9 |
+
As an end-user you will not use these classes directly, but only the values
|
| 10 |
+
they define.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from enum import Enum
|
| 14 |
+
from matplotlib import _docstring
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class JoinStyle(str, Enum):
|
| 18 |
+
"""
|
| 19 |
+
Define how the connection between two line segments is drawn.
|
| 20 |
+
|
| 21 |
+
For a visual impression of each *JoinStyle*, `view these docs online
|
| 22 |
+
<JoinStyle>`, or run `JoinStyle.demo`.
|
| 23 |
+
|
| 24 |
+
Lines in Matplotlib are typically defined by a 1D `~.path.Path` and a
|
| 25 |
+
finite ``linewidth``, where the underlying 1D `~.path.Path` represents the
|
| 26 |
+
center of the stroked line.
|
| 27 |
+
|
| 28 |
+
By default, `~.backend_bases.GraphicsContextBase` defines the boundaries of
|
| 29 |
+
a stroked line to simply be every point within some radius,
|
| 30 |
+
``linewidth/2``, away from any point of the center line. However, this
|
| 31 |
+
results in corners appearing "rounded", which may not be the desired
|
| 32 |
+
behavior if you are drawing, for example, a polygon or pointed star.
|
| 33 |
+
|
| 34 |
+
**Supported values:**
|
| 35 |
+
|
| 36 |
+
.. rst-class:: value-list
|
| 37 |
+
|
| 38 |
+
'miter'
|
| 39 |
+
the "arrow-tip" style. Each boundary of the filled-in area will
|
| 40 |
+
extend in a straight line parallel to the tangent vector of the
|
| 41 |
+
centerline at the point it meets the corner, until they meet in a
|
| 42 |
+
sharp point.
|
| 43 |
+
'round'
|
| 44 |
+
stokes every point within a radius of ``linewidth/2`` of the center
|
| 45 |
+
lines.
|
| 46 |
+
'bevel'
|
| 47 |
+
the "squared-off" style. It can be thought of as a rounded corner
|
| 48 |
+
where the "circular" part of the corner has been cut off.
|
| 49 |
+
|
| 50 |
+
.. note::
|
| 51 |
+
|
| 52 |
+
Very long miter tips are cut off (to form a *bevel*) after a
|
| 53 |
+
backend-dependent limit called the "miter limit", which specifies the
|
| 54 |
+
maximum allowed ratio of miter length to line width. For example, the
|
| 55 |
+
PDF backend uses the default value of 10 specified by the PDF standard,
|
| 56 |
+
while the SVG backend does not even specify the miter limit, resulting
|
| 57 |
+
in a default value of 4 per the SVG specification. Matplotlib does not
|
| 58 |
+
currently allow the user to adjust this parameter.
|
| 59 |
+
|
| 60 |
+
A more detailed description of the effect of a miter limit can be found
|
| 61 |
+
in the `Mozilla Developer Docs
|
| 62 |
+
<https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-miterlimit>`_
|
| 63 |
+
|
| 64 |
+
.. plot::
|
| 65 |
+
:alt: Demo of possible JoinStyle's
|
| 66 |
+
|
| 67 |
+
from matplotlib._enums import JoinStyle
|
| 68 |
+
JoinStyle.demo()
|
| 69 |
+
|
| 70 |
+
"""
|
| 71 |
+
|
| 72 |
+
miter = "miter"
|
| 73 |
+
round = "round"
|
| 74 |
+
bevel = "bevel"
|
| 75 |
+
|
| 76 |
+
@staticmethod
|
| 77 |
+
def demo():
|
| 78 |
+
"""Demonstrate how each JoinStyle looks for various join angles."""
|
| 79 |
+
import numpy as np
|
| 80 |
+
import matplotlib.pyplot as plt
|
| 81 |
+
|
| 82 |
+
def plot_angle(ax, x, y, angle, style):
|
| 83 |
+
phi = np.radians(angle)
|
| 84 |
+
xx = [x + .5, x, x + .5*np.cos(phi)]
|
| 85 |
+
yy = [y, y, y + .5*np.sin(phi)]
|
| 86 |
+
ax.plot(xx, yy, lw=12, color='tab:blue', solid_joinstyle=style)
|
| 87 |
+
ax.plot(xx, yy, lw=1, color='black')
|
| 88 |
+
ax.plot(xx[1], yy[1], 'o', color='tab:red', markersize=3)
|
| 89 |
+
|
| 90 |
+
fig, ax = plt.subplots(figsize=(5, 4), constrained_layout=True)
|
| 91 |
+
ax.set_title('Join style')
|
| 92 |
+
for x, style in enumerate(['miter', 'round', 'bevel']):
|
| 93 |
+
ax.text(x, 5, style)
|
| 94 |
+
for y, angle in enumerate([20, 45, 60, 90, 120]):
|
| 95 |
+
plot_angle(ax, x, y, angle, style)
|
| 96 |
+
if x == 0:
|
| 97 |
+
ax.text(-1.3, y, f'{angle} degrees')
|
| 98 |
+
ax.set_xlim(-1.5, 2.75)
|
| 99 |
+
ax.set_ylim(-.5, 5.5)
|
| 100 |
+
ax.set_axis_off()
|
| 101 |
+
fig.show()
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
JoinStyle.input_description = "{" \
|
| 105 |
+
+ ", ".join([f"'{js.name}'" for js in JoinStyle]) \
|
| 106 |
+
+ "}"
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
class CapStyle(str, Enum):
|
| 110 |
+
r"""
|
| 111 |
+
Define how the two endpoints (caps) of an unclosed line are drawn.
|
| 112 |
+
|
| 113 |
+
How to draw the start and end points of lines that represent a closed curve
|
| 114 |
+
(i.e. that end in a `~.path.Path.CLOSEPOLY`) is controlled by the line's
|
| 115 |
+
`JoinStyle`. For all other lines, how the start and end points are drawn is
|
| 116 |
+
controlled by the *CapStyle*.
|
| 117 |
+
|
| 118 |
+
For a visual impression of each *CapStyle*, `view these docs online
|
| 119 |
+
<CapStyle>` or run `CapStyle.demo`.
|
| 120 |
+
|
| 121 |
+
By default, `~.backend_bases.GraphicsContextBase` draws a stroked line as
|
| 122 |
+
squared off at its endpoints.
|
| 123 |
+
|
| 124 |
+
**Supported values:**
|
| 125 |
+
|
| 126 |
+
.. rst-class:: value-list
|
| 127 |
+
|
| 128 |
+
'butt'
|
| 129 |
+
the line is squared off at its endpoint.
|
| 130 |
+
'projecting'
|
| 131 |
+
the line is squared off as in *butt*, but the filled in area
|
| 132 |
+
extends beyond the endpoint a distance of ``linewidth/2``.
|
| 133 |
+
'round'
|
| 134 |
+
like *butt*, but a semicircular cap is added to the end of the
|
| 135 |
+
line, of radius ``linewidth/2``.
|
| 136 |
+
|
| 137 |
+
.. plot::
|
| 138 |
+
:alt: Demo of possible CapStyle's
|
| 139 |
+
|
| 140 |
+
from matplotlib._enums import CapStyle
|
| 141 |
+
CapStyle.demo()
|
| 142 |
+
|
| 143 |
+
"""
|
| 144 |
+
butt = "butt"
|
| 145 |
+
projecting = "projecting"
|
| 146 |
+
round = "round"
|
| 147 |
+
|
| 148 |
+
@staticmethod
|
| 149 |
+
def demo():
|
| 150 |
+
"""Demonstrate how each CapStyle looks for a thick line segment."""
|
| 151 |
+
import matplotlib.pyplot as plt
|
| 152 |
+
|
| 153 |
+
fig = plt.figure(figsize=(4, 1.2))
|
| 154 |
+
ax = fig.add_axes([0, 0, 1, 0.8])
|
| 155 |
+
ax.set_title('Cap style')
|
| 156 |
+
|
| 157 |
+
for x, style in enumerate(['butt', 'round', 'projecting']):
|
| 158 |
+
ax.text(x+0.25, 0.85, style, ha='center')
|
| 159 |
+
xx = [x, x+0.5]
|
| 160 |
+
yy = [0, 0]
|
| 161 |
+
ax.plot(xx, yy, lw=12, color='tab:blue', solid_capstyle=style)
|
| 162 |
+
ax.plot(xx, yy, lw=1, color='black')
|
| 163 |
+
ax.plot(xx, yy, 'o', color='tab:red', markersize=3)
|
| 164 |
+
|
| 165 |
+
ax.set_ylim(-.5, 1.5)
|
| 166 |
+
ax.set_axis_off()
|
| 167 |
+
fig.show()
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
CapStyle.input_description = "{" \
|
| 171 |
+
+ ", ".join([f"'{cs.name}'" for cs in CapStyle]) \
|
| 172 |
+
+ "}"
|
| 173 |
+
|
| 174 |
+
_docstring.interpd.register(
|
| 175 |
+
JoinStyle=JoinStyle.input_description,
|
| 176 |
+
CapStyle=CapStyle.input_description,
|
| 177 |
+
)
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_mathtext.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_mathtext_data.py
ADDED
|
@@ -0,0 +1,1742 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
font data tables for truetype and afm computer modern fonts
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from __future__ import annotations
|
| 6 |
+
from typing import overload
|
| 7 |
+
|
| 8 |
+
latex_to_bakoma = {
|
| 9 |
+
'\\__sqrt__' : ('cmex10', 0x70),
|
| 10 |
+
'\\bigcap' : ('cmex10', 0x5c),
|
| 11 |
+
'\\bigcup' : ('cmex10', 0x5b),
|
| 12 |
+
'\\bigodot' : ('cmex10', 0x4b),
|
| 13 |
+
'\\bigoplus' : ('cmex10', 0x4d),
|
| 14 |
+
'\\bigotimes' : ('cmex10', 0x4f),
|
| 15 |
+
'\\biguplus' : ('cmex10', 0x5d),
|
| 16 |
+
'\\bigvee' : ('cmex10', 0x5f),
|
| 17 |
+
'\\bigwedge' : ('cmex10', 0x5e),
|
| 18 |
+
'\\coprod' : ('cmex10', 0x61),
|
| 19 |
+
'\\int' : ('cmex10', 0x5a),
|
| 20 |
+
'\\langle' : ('cmex10', 0xad),
|
| 21 |
+
'\\leftangle' : ('cmex10', 0xad),
|
| 22 |
+
'\\leftbrace' : ('cmex10', 0xa9),
|
| 23 |
+
'\\oint' : ('cmex10', 0x49),
|
| 24 |
+
'\\prod' : ('cmex10', 0x59),
|
| 25 |
+
'\\rangle' : ('cmex10', 0xae),
|
| 26 |
+
'\\rightangle' : ('cmex10', 0xae),
|
| 27 |
+
'\\rightbrace' : ('cmex10', 0xaa),
|
| 28 |
+
'\\sum' : ('cmex10', 0x58),
|
| 29 |
+
'\\widehat' : ('cmex10', 0x62),
|
| 30 |
+
'\\widetilde' : ('cmex10', 0x65),
|
| 31 |
+
'\\{' : ('cmex10', 0xa9),
|
| 32 |
+
'\\}' : ('cmex10', 0xaa),
|
| 33 |
+
'{' : ('cmex10', 0xa9),
|
| 34 |
+
'}' : ('cmex10', 0xaa),
|
| 35 |
+
|
| 36 |
+
',' : ('cmmi10', 0x3b),
|
| 37 |
+
'.' : ('cmmi10', 0x3a),
|
| 38 |
+
'/' : ('cmmi10', 0x3d),
|
| 39 |
+
'<' : ('cmmi10', 0x3c),
|
| 40 |
+
'>' : ('cmmi10', 0x3e),
|
| 41 |
+
'\\alpha' : ('cmmi10', 0xae),
|
| 42 |
+
'\\beta' : ('cmmi10', 0xaf),
|
| 43 |
+
'\\chi' : ('cmmi10', 0xc2),
|
| 44 |
+
'\\combiningrightarrowabove' : ('cmmi10', 0x7e),
|
| 45 |
+
'\\delta' : ('cmmi10', 0xb1),
|
| 46 |
+
'\\ell' : ('cmmi10', 0x60),
|
| 47 |
+
'\\epsilon' : ('cmmi10', 0xb2),
|
| 48 |
+
'\\eta' : ('cmmi10', 0xb4),
|
| 49 |
+
'\\flat' : ('cmmi10', 0x5b),
|
| 50 |
+
'\\frown' : ('cmmi10', 0x5f),
|
| 51 |
+
'\\gamma' : ('cmmi10', 0xb0),
|
| 52 |
+
'\\imath' : ('cmmi10', 0x7b),
|
| 53 |
+
'\\iota' : ('cmmi10', 0xb6),
|
| 54 |
+
'\\jmath' : ('cmmi10', 0x7c),
|
| 55 |
+
'\\kappa' : ('cmmi10', 0x2219),
|
| 56 |
+
'\\lambda' : ('cmmi10', 0xb8),
|
| 57 |
+
'\\leftharpoondown' : ('cmmi10', 0x29),
|
| 58 |
+
'\\leftharpoonup' : ('cmmi10', 0x28),
|
| 59 |
+
'\\mu' : ('cmmi10', 0xb9),
|
| 60 |
+
'\\natural' : ('cmmi10', 0x5c),
|
| 61 |
+
'\\nu' : ('cmmi10', 0xba),
|
| 62 |
+
'\\omega' : ('cmmi10', 0x21),
|
| 63 |
+
'\\phi' : ('cmmi10', 0xc1),
|
| 64 |
+
'\\pi' : ('cmmi10', 0xbc),
|
| 65 |
+
'\\psi' : ('cmmi10', 0xc3),
|
| 66 |
+
'\\rho' : ('cmmi10', 0xbd),
|
| 67 |
+
'\\rightharpoondown' : ('cmmi10', 0x2b),
|
| 68 |
+
'\\rightharpoonup' : ('cmmi10', 0x2a),
|
| 69 |
+
'\\sharp' : ('cmmi10', 0x5d),
|
| 70 |
+
'\\sigma' : ('cmmi10', 0xbe),
|
| 71 |
+
'\\smile' : ('cmmi10', 0x5e),
|
| 72 |
+
'\\tau' : ('cmmi10', 0xbf),
|
| 73 |
+
'\\theta' : ('cmmi10', 0xb5),
|
| 74 |
+
'\\triangleleft' : ('cmmi10', 0x2f),
|
| 75 |
+
'\\triangleright' : ('cmmi10', 0x2e),
|
| 76 |
+
'\\upsilon' : ('cmmi10', 0xc0),
|
| 77 |
+
'\\varepsilon' : ('cmmi10', 0x22),
|
| 78 |
+
'\\varphi' : ('cmmi10', 0x27),
|
| 79 |
+
'\\varrho' : ('cmmi10', 0x25),
|
| 80 |
+
'\\varsigma' : ('cmmi10', 0x26),
|
| 81 |
+
'\\vartheta' : ('cmmi10', 0x23),
|
| 82 |
+
'\\wp' : ('cmmi10', 0x7d),
|
| 83 |
+
'\\xi' : ('cmmi10', 0xbb),
|
| 84 |
+
'\\zeta' : ('cmmi10', 0xb3),
|
| 85 |
+
|
| 86 |
+
'!' : ('cmr10', 0x21),
|
| 87 |
+
'%' : ('cmr10', 0x25),
|
| 88 |
+
'&' : ('cmr10', 0x26),
|
| 89 |
+
'(' : ('cmr10', 0x28),
|
| 90 |
+
')' : ('cmr10', 0x29),
|
| 91 |
+
'+' : ('cmr10', 0x2b),
|
| 92 |
+
'0' : ('cmr10', 0x30),
|
| 93 |
+
'1' : ('cmr10', 0x31),
|
| 94 |
+
'2' : ('cmr10', 0x32),
|
| 95 |
+
'3' : ('cmr10', 0x33),
|
| 96 |
+
'4' : ('cmr10', 0x34),
|
| 97 |
+
'5' : ('cmr10', 0x35),
|
| 98 |
+
'6' : ('cmr10', 0x36),
|
| 99 |
+
'7' : ('cmr10', 0x37),
|
| 100 |
+
'8' : ('cmr10', 0x38),
|
| 101 |
+
'9' : ('cmr10', 0x39),
|
| 102 |
+
':' : ('cmr10', 0x3a),
|
| 103 |
+
';' : ('cmr10', 0x3b),
|
| 104 |
+
'=' : ('cmr10', 0x3d),
|
| 105 |
+
'?' : ('cmr10', 0x3f),
|
| 106 |
+
'@' : ('cmr10', 0x40),
|
| 107 |
+
'[' : ('cmr10', 0x5b),
|
| 108 |
+
'\\#' : ('cmr10', 0x23),
|
| 109 |
+
'\\$' : ('cmr10', 0x24),
|
| 110 |
+
'\\%' : ('cmr10', 0x25),
|
| 111 |
+
'\\Delta' : ('cmr10', 0xa2),
|
| 112 |
+
'\\Gamma' : ('cmr10', 0xa1),
|
| 113 |
+
'\\Lambda' : ('cmr10', 0xa4),
|
| 114 |
+
'\\Omega' : ('cmr10', 0xad),
|
| 115 |
+
'\\Phi' : ('cmr10', 0xa9),
|
| 116 |
+
'\\Pi' : ('cmr10', 0xa6),
|
| 117 |
+
'\\Psi' : ('cmr10', 0xaa),
|
| 118 |
+
'\\Sigma' : ('cmr10', 0xa7),
|
| 119 |
+
'\\Theta' : ('cmr10', 0xa3),
|
| 120 |
+
'\\Upsilon' : ('cmr10', 0xa8),
|
| 121 |
+
'\\Xi' : ('cmr10', 0xa5),
|
| 122 |
+
'\\circumflexaccent' : ('cmr10', 0x5e),
|
| 123 |
+
'\\combiningacuteaccent' : ('cmr10', 0xb6),
|
| 124 |
+
'\\combiningbreve' : ('cmr10', 0xb8),
|
| 125 |
+
'\\combiningdiaeresis' : ('cmr10', 0xc4),
|
| 126 |
+
'\\combiningdotabove' : ('cmr10', 0x5f),
|
| 127 |
+
'\\combininggraveaccent' : ('cmr10', 0xb5),
|
| 128 |
+
'\\combiningoverline' : ('cmr10', 0xb9),
|
| 129 |
+
'\\combiningtilde' : ('cmr10', 0x7e),
|
| 130 |
+
'\\leftbracket' : ('cmr10', 0x5b),
|
| 131 |
+
'\\leftparen' : ('cmr10', 0x28),
|
| 132 |
+
'\\rightbracket' : ('cmr10', 0x5d),
|
| 133 |
+
'\\rightparen' : ('cmr10', 0x29),
|
| 134 |
+
'\\widebar' : ('cmr10', 0xb9),
|
| 135 |
+
']' : ('cmr10', 0x5d),
|
| 136 |
+
|
| 137 |
+
'*' : ('cmsy10', 0xa4),
|
| 138 |
+
'\N{MINUS SIGN}' : ('cmsy10', 0xa1),
|
| 139 |
+
'\\Downarrow' : ('cmsy10', 0x2b),
|
| 140 |
+
'\\Im' : ('cmsy10', 0x3d),
|
| 141 |
+
'\\Leftarrow' : ('cmsy10', 0x28),
|
| 142 |
+
'\\Leftrightarrow' : ('cmsy10', 0x2c),
|
| 143 |
+
'\\P' : ('cmsy10', 0x7b),
|
| 144 |
+
'\\Re' : ('cmsy10', 0x3c),
|
| 145 |
+
'\\Rightarrow' : ('cmsy10', 0x29),
|
| 146 |
+
'\\S' : ('cmsy10', 0x78),
|
| 147 |
+
'\\Uparrow' : ('cmsy10', 0x2a),
|
| 148 |
+
'\\Updownarrow' : ('cmsy10', 0x6d),
|
| 149 |
+
'\\Vert' : ('cmsy10', 0x6b),
|
| 150 |
+
'\\aleph' : ('cmsy10', 0x40),
|
| 151 |
+
'\\approx' : ('cmsy10', 0xbc),
|
| 152 |
+
'\\ast' : ('cmsy10', 0xa4),
|
| 153 |
+
'\\asymp' : ('cmsy10', 0xb3),
|
| 154 |
+
'\\backslash' : ('cmsy10', 0x6e),
|
| 155 |
+
'\\bigcirc' : ('cmsy10', 0xb0),
|
| 156 |
+
'\\bigtriangledown' : ('cmsy10', 0x35),
|
| 157 |
+
'\\bigtriangleup' : ('cmsy10', 0x34),
|
| 158 |
+
'\\bot' : ('cmsy10', 0x3f),
|
| 159 |
+
'\\bullet' : ('cmsy10', 0xb2),
|
| 160 |
+
'\\cap' : ('cmsy10', 0x5c),
|
| 161 |
+
'\\cdot' : ('cmsy10', 0xa2),
|
| 162 |
+
'\\circ' : ('cmsy10', 0xb1),
|
| 163 |
+
'\\clubsuit' : ('cmsy10', 0x7c),
|
| 164 |
+
'\\cup' : ('cmsy10', 0x5b),
|
| 165 |
+
'\\dag' : ('cmsy10', 0x79),
|
| 166 |
+
'\\dashv' : ('cmsy10', 0x61),
|
| 167 |
+
'\\ddag' : ('cmsy10', 0x7a),
|
| 168 |
+
'\\diamond' : ('cmsy10', 0xa6),
|
| 169 |
+
'\\diamondsuit' : ('cmsy10', 0x7d),
|
| 170 |
+
'\\div' : ('cmsy10', 0xa5),
|
| 171 |
+
'\\downarrow' : ('cmsy10', 0x23),
|
| 172 |
+
'\\emptyset' : ('cmsy10', 0x3b),
|
| 173 |
+
'\\equiv' : ('cmsy10', 0xb4),
|
| 174 |
+
'\\exists' : ('cmsy10', 0x39),
|
| 175 |
+
'\\forall' : ('cmsy10', 0x38),
|
| 176 |
+
'\\geq' : ('cmsy10', 0xb8),
|
| 177 |
+
'\\gg' : ('cmsy10', 0xc0),
|
| 178 |
+
'\\heartsuit' : ('cmsy10', 0x7e),
|
| 179 |
+
'\\in' : ('cmsy10', 0x32),
|
| 180 |
+
'\\infty' : ('cmsy10', 0x31),
|
| 181 |
+
'\\lbrace' : ('cmsy10', 0x66),
|
| 182 |
+
'\\lceil' : ('cmsy10', 0x64),
|
| 183 |
+
'\\leftarrow' : ('cmsy10', 0xc3),
|
| 184 |
+
'\\leftrightarrow' : ('cmsy10', 0x24),
|
| 185 |
+
'\\leq' : ('cmsy10', 0x2219),
|
| 186 |
+
'\\lfloor' : ('cmsy10', 0x62),
|
| 187 |
+
'\\ll' : ('cmsy10', 0xbf),
|
| 188 |
+
'\\mid' : ('cmsy10', 0x6a),
|
| 189 |
+
'\\mp' : ('cmsy10', 0xa8),
|
| 190 |
+
'\\nabla' : ('cmsy10', 0x72),
|
| 191 |
+
'\\nearrow' : ('cmsy10', 0x25),
|
| 192 |
+
'\\neg' : ('cmsy10', 0x3a),
|
| 193 |
+
'\\ni' : ('cmsy10', 0x33),
|
| 194 |
+
'\\nwarrow' : ('cmsy10', 0x2d),
|
| 195 |
+
'\\odot' : ('cmsy10', 0xaf),
|
| 196 |
+
'\\ominus' : ('cmsy10', 0xaa),
|
| 197 |
+
'\\oplus' : ('cmsy10', 0xa9),
|
| 198 |
+
'\\oslash' : ('cmsy10', 0xae),
|
| 199 |
+
'\\otimes' : ('cmsy10', 0xad),
|
| 200 |
+
'\\pm' : ('cmsy10', 0xa7),
|
| 201 |
+
'\\prec' : ('cmsy10', 0xc1),
|
| 202 |
+
'\\preceq' : ('cmsy10', 0xb9),
|
| 203 |
+
'\\prime' : ('cmsy10', 0x30),
|
| 204 |
+
'\\propto' : ('cmsy10', 0x2f),
|
| 205 |
+
'\\rbrace' : ('cmsy10', 0x67),
|
| 206 |
+
'\\rceil' : ('cmsy10', 0x65),
|
| 207 |
+
'\\rfloor' : ('cmsy10', 0x63),
|
| 208 |
+
'\\rightarrow' : ('cmsy10', 0x21),
|
| 209 |
+
'\\searrow' : ('cmsy10', 0x26),
|
| 210 |
+
'\\sim' : ('cmsy10', 0xbb),
|
| 211 |
+
'\\simeq' : ('cmsy10', 0x27),
|
| 212 |
+
'\\slash' : ('cmsy10', 0x36),
|
| 213 |
+
'\\spadesuit' : ('cmsy10', 0xc4),
|
| 214 |
+
'\\sqcap' : ('cmsy10', 0x75),
|
| 215 |
+
'\\sqcup' : ('cmsy10', 0x74),
|
| 216 |
+
'\\sqsubseteq' : ('cmsy10', 0x76),
|
| 217 |
+
'\\sqsupseteq' : ('cmsy10', 0x77),
|
| 218 |
+
'\\subset' : ('cmsy10', 0xbd),
|
| 219 |
+
'\\subseteq' : ('cmsy10', 0xb5),
|
| 220 |
+
'\\succ' : ('cmsy10', 0xc2),
|
| 221 |
+
'\\succeq' : ('cmsy10', 0xba),
|
| 222 |
+
'\\supset' : ('cmsy10', 0xbe),
|
| 223 |
+
'\\supseteq' : ('cmsy10', 0xb6),
|
| 224 |
+
'\\swarrow' : ('cmsy10', 0x2e),
|
| 225 |
+
'\\times' : ('cmsy10', 0xa3),
|
| 226 |
+
'\\to' : ('cmsy10', 0x21),
|
| 227 |
+
'\\top' : ('cmsy10', 0x3e),
|
| 228 |
+
'\\uparrow' : ('cmsy10', 0x22),
|
| 229 |
+
'\\updownarrow' : ('cmsy10', 0x6c),
|
| 230 |
+
'\\uplus' : ('cmsy10', 0x5d),
|
| 231 |
+
'\\vdash' : ('cmsy10', 0x60),
|
| 232 |
+
'\\vee' : ('cmsy10', 0x5f),
|
| 233 |
+
'\\vert' : ('cmsy10', 0x6a),
|
| 234 |
+
'\\wedge' : ('cmsy10', 0x5e),
|
| 235 |
+
'\\wr' : ('cmsy10', 0x6f),
|
| 236 |
+
'\\|' : ('cmsy10', 0x6b),
|
| 237 |
+
'|' : ('cmsy10', 0x6a),
|
| 238 |
+
|
| 239 |
+
'\\_' : ('cmtt10', 0x5f)
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
# Automatically generated.
|
| 243 |
+
|
| 244 |
+
type12uni = {
|
| 245 |
+
'aring' : 229,
|
| 246 |
+
'quotedblright' : 8221,
|
| 247 |
+
'V' : 86,
|
| 248 |
+
'dollar' : 36,
|
| 249 |
+
'four' : 52,
|
| 250 |
+
'Yacute' : 221,
|
| 251 |
+
'P' : 80,
|
| 252 |
+
'underscore' : 95,
|
| 253 |
+
'p' : 112,
|
| 254 |
+
'Otilde' : 213,
|
| 255 |
+
'perthousand' : 8240,
|
| 256 |
+
'zero' : 48,
|
| 257 |
+
'dotlessi' : 305,
|
| 258 |
+
'Scaron' : 352,
|
| 259 |
+
'zcaron' : 382,
|
| 260 |
+
'egrave' : 232,
|
| 261 |
+
'section' : 167,
|
| 262 |
+
'Icircumflex' : 206,
|
| 263 |
+
'ntilde' : 241,
|
| 264 |
+
'ampersand' : 38,
|
| 265 |
+
'dotaccent' : 729,
|
| 266 |
+
'degree' : 176,
|
| 267 |
+
'K' : 75,
|
| 268 |
+
'acircumflex' : 226,
|
| 269 |
+
'Aring' : 197,
|
| 270 |
+
'k' : 107,
|
| 271 |
+
'smalltilde' : 732,
|
| 272 |
+
'Agrave' : 192,
|
| 273 |
+
'divide' : 247,
|
| 274 |
+
'ocircumflex' : 244,
|
| 275 |
+
'asciitilde' : 126,
|
| 276 |
+
'two' : 50,
|
| 277 |
+
'E' : 69,
|
| 278 |
+
'scaron' : 353,
|
| 279 |
+
'F' : 70,
|
| 280 |
+
'bracketleft' : 91,
|
| 281 |
+
'asciicircum' : 94,
|
| 282 |
+
'f' : 102,
|
| 283 |
+
'ordmasculine' : 186,
|
| 284 |
+
'mu' : 181,
|
| 285 |
+
'paragraph' : 182,
|
| 286 |
+
'nine' : 57,
|
| 287 |
+
'v' : 118,
|
| 288 |
+
'guilsinglleft' : 8249,
|
| 289 |
+
'backslash' : 92,
|
| 290 |
+
'six' : 54,
|
| 291 |
+
'A' : 65,
|
| 292 |
+
'icircumflex' : 238,
|
| 293 |
+
'a' : 97,
|
| 294 |
+
'ogonek' : 731,
|
| 295 |
+
'q' : 113,
|
| 296 |
+
'oacute' : 243,
|
| 297 |
+
'ograve' : 242,
|
| 298 |
+
'edieresis' : 235,
|
| 299 |
+
'comma' : 44,
|
| 300 |
+
'otilde' : 245,
|
| 301 |
+
'guillemotright' : 187,
|
| 302 |
+
'ecircumflex' : 234,
|
| 303 |
+
'greater' : 62,
|
| 304 |
+
'uacute' : 250,
|
| 305 |
+
'L' : 76,
|
| 306 |
+
'bullet' : 8226,
|
| 307 |
+
'cedilla' : 184,
|
| 308 |
+
'ydieresis' : 255,
|
| 309 |
+
'l' : 108,
|
| 310 |
+
'logicalnot' : 172,
|
| 311 |
+
'exclamdown' : 161,
|
| 312 |
+
'endash' : 8211,
|
| 313 |
+
'agrave' : 224,
|
| 314 |
+
'Adieresis' : 196,
|
| 315 |
+
'germandbls' : 223,
|
| 316 |
+
'Odieresis' : 214,
|
| 317 |
+
'space' : 32,
|
| 318 |
+
'quoteright' : 8217,
|
| 319 |
+
'ucircumflex' : 251,
|
| 320 |
+
'G' : 71,
|
| 321 |
+
'quoteleft' : 8216,
|
| 322 |
+
'W' : 87,
|
| 323 |
+
'Q' : 81,
|
| 324 |
+
'g' : 103,
|
| 325 |
+
'w' : 119,
|
| 326 |
+
'question' : 63,
|
| 327 |
+
'one' : 49,
|
| 328 |
+
'ring' : 730,
|
| 329 |
+
'figuredash' : 8210,
|
| 330 |
+
'B' : 66,
|
| 331 |
+
'iacute' : 237,
|
| 332 |
+
'Ydieresis' : 376,
|
| 333 |
+
'R' : 82,
|
| 334 |
+
'b' : 98,
|
| 335 |
+
'r' : 114,
|
| 336 |
+
'Ccedilla' : 199,
|
| 337 |
+
'minus' : 8722,
|
| 338 |
+
'Lslash' : 321,
|
| 339 |
+
'Uacute' : 218,
|
| 340 |
+
'yacute' : 253,
|
| 341 |
+
'Ucircumflex' : 219,
|
| 342 |
+
'quotedbl' : 34,
|
| 343 |
+
'onehalf' : 189,
|
| 344 |
+
'Thorn' : 222,
|
| 345 |
+
'M' : 77,
|
| 346 |
+
'eight' : 56,
|
| 347 |
+
'multiply' : 215,
|
| 348 |
+
'grave' : 96,
|
| 349 |
+
'Ocircumflex' : 212,
|
| 350 |
+
'm' : 109,
|
| 351 |
+
'Ugrave' : 217,
|
| 352 |
+
'guilsinglright' : 8250,
|
| 353 |
+
'Ntilde' : 209,
|
| 354 |
+
'questiondown' : 191,
|
| 355 |
+
'Atilde' : 195,
|
| 356 |
+
'ccedilla' : 231,
|
| 357 |
+
'Z' : 90,
|
| 358 |
+
'copyright' : 169,
|
| 359 |
+
'yen' : 165,
|
| 360 |
+
'Eacute' : 201,
|
| 361 |
+
'H' : 72,
|
| 362 |
+
'X' : 88,
|
| 363 |
+
'Idieresis' : 207,
|
| 364 |
+
'bar' : 124,
|
| 365 |
+
'h' : 104,
|
| 366 |
+
'x' : 120,
|
| 367 |
+
'udieresis' : 252,
|
| 368 |
+
'ordfeminine' : 170,
|
| 369 |
+
'braceleft' : 123,
|
| 370 |
+
'macron' : 175,
|
| 371 |
+
'atilde' : 227,
|
| 372 |
+
'Acircumflex' : 194,
|
| 373 |
+
'Oslash' : 216,
|
| 374 |
+
'C' : 67,
|
| 375 |
+
'quotedblleft' : 8220,
|
| 376 |
+
'S' : 83,
|
| 377 |
+
'exclam' : 33,
|
| 378 |
+
'Zcaron' : 381,
|
| 379 |
+
'equal' : 61,
|
| 380 |
+
's' : 115,
|
| 381 |
+
'eth' : 240,
|
| 382 |
+
'Egrave' : 200,
|
| 383 |
+
'hyphen' : 45,
|
| 384 |
+
'period' : 46,
|
| 385 |
+
'igrave' : 236,
|
| 386 |
+
'colon' : 58,
|
| 387 |
+
'Ecircumflex' : 202,
|
| 388 |
+
'trademark' : 8482,
|
| 389 |
+
'Aacute' : 193,
|
| 390 |
+
'cent' : 162,
|
| 391 |
+
'lslash' : 322,
|
| 392 |
+
'c' : 99,
|
| 393 |
+
'N' : 78,
|
| 394 |
+
'breve' : 728,
|
| 395 |
+
'Oacute' : 211,
|
| 396 |
+
'guillemotleft' : 171,
|
| 397 |
+
'n' : 110,
|
| 398 |
+
'idieresis' : 239,
|
| 399 |
+
'braceright' : 125,
|
| 400 |
+
'seven' : 55,
|
| 401 |
+
'brokenbar' : 166,
|
| 402 |
+
'ugrave' : 249,
|
| 403 |
+
'periodcentered' : 183,
|
| 404 |
+
'sterling' : 163,
|
| 405 |
+
'I' : 73,
|
| 406 |
+
'Y' : 89,
|
| 407 |
+
'Eth' : 208,
|
| 408 |
+
'emdash' : 8212,
|
| 409 |
+
'i' : 105,
|
| 410 |
+
'daggerdbl' : 8225,
|
| 411 |
+
'y' : 121,
|
| 412 |
+
'plusminus' : 177,
|
| 413 |
+
'less' : 60,
|
| 414 |
+
'Udieresis' : 220,
|
| 415 |
+
'D' : 68,
|
| 416 |
+
'five' : 53,
|
| 417 |
+
'T' : 84,
|
| 418 |
+
'oslash' : 248,
|
| 419 |
+
'acute' : 180,
|
| 420 |
+
'd' : 100,
|
| 421 |
+
'OE' : 338,
|
| 422 |
+
'Igrave' : 204,
|
| 423 |
+
't' : 116,
|
| 424 |
+
'parenright' : 41,
|
| 425 |
+
'adieresis' : 228,
|
| 426 |
+
'quotesingle' : 39,
|
| 427 |
+
'twodotenleader' : 8229,
|
| 428 |
+
'slash' : 47,
|
| 429 |
+
'ellipsis' : 8230,
|
| 430 |
+
'numbersign' : 35,
|
| 431 |
+
'odieresis' : 246,
|
| 432 |
+
'O' : 79,
|
| 433 |
+
'oe' : 339,
|
| 434 |
+
'o' : 111,
|
| 435 |
+
'Edieresis' : 203,
|
| 436 |
+
'plus' : 43,
|
| 437 |
+
'dagger' : 8224,
|
| 438 |
+
'three' : 51,
|
| 439 |
+
'hungarumlaut' : 733,
|
| 440 |
+
'parenleft' : 40,
|
| 441 |
+
'fraction' : 8260,
|
| 442 |
+
'registered' : 174,
|
| 443 |
+
'J' : 74,
|
| 444 |
+
'dieresis' : 168,
|
| 445 |
+
'Ograve' : 210,
|
| 446 |
+
'j' : 106,
|
| 447 |
+
'z' : 122,
|
| 448 |
+
'ae' : 230,
|
| 449 |
+
'semicolon' : 59,
|
| 450 |
+
'at' : 64,
|
| 451 |
+
'Iacute' : 205,
|
| 452 |
+
'percent' : 37,
|
| 453 |
+
'bracketright' : 93,
|
| 454 |
+
'AE' : 198,
|
| 455 |
+
'asterisk' : 42,
|
| 456 |
+
'aacute' : 225,
|
| 457 |
+
'U' : 85,
|
| 458 |
+
'eacute' : 233,
|
| 459 |
+
'e' : 101,
|
| 460 |
+
'thorn' : 254,
|
| 461 |
+
'u' : 117,
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
uni2type1 = {v: k for k, v in type12uni.items()}
|
| 465 |
+
|
| 466 |
+
# The script below is to sort and format the tex2uni dict
|
| 467 |
+
|
| 468 |
+
## For decimal values: int(hex(v), 16)
|
| 469 |
+
# newtex = {k: hex(v) for k, v in tex2uni.items()}
|
| 470 |
+
# sd = dict(sorted(newtex.items(), key=lambda item: item[0]))
|
| 471 |
+
#
|
| 472 |
+
## For formatting the sorted dictionary with proper spacing
|
| 473 |
+
## the value '24' comes from finding the longest string in
|
| 474 |
+
## the newtex keys with len(max(newtex, key=len))
|
| 475 |
+
# for key in sd:
|
| 476 |
+
# print("{0:24} : {1: <s},".format("'" + key + "'", sd[key]))
|
| 477 |
+
|
| 478 |
+
tex2uni = {
|
| 479 |
+
'#' : 0x23,
|
| 480 |
+
'$' : 0x24,
|
| 481 |
+
'%' : 0x25,
|
| 482 |
+
'AA' : 0xc5,
|
| 483 |
+
'AE' : 0xc6,
|
| 484 |
+
'BbbC' : 0x2102,
|
| 485 |
+
'BbbN' : 0x2115,
|
| 486 |
+
'BbbP' : 0x2119,
|
| 487 |
+
'BbbQ' : 0x211a,
|
| 488 |
+
'BbbR' : 0x211d,
|
| 489 |
+
'BbbZ' : 0x2124,
|
| 490 |
+
'Bumpeq' : 0x224e,
|
| 491 |
+
'Cap' : 0x22d2,
|
| 492 |
+
'Colon' : 0x2237,
|
| 493 |
+
'Cup' : 0x22d3,
|
| 494 |
+
'DH' : 0xd0,
|
| 495 |
+
'Delta' : 0x394,
|
| 496 |
+
'Doteq' : 0x2251,
|
| 497 |
+
'Downarrow' : 0x21d3,
|
| 498 |
+
'Equiv' : 0x2263,
|
| 499 |
+
'Finv' : 0x2132,
|
| 500 |
+
'Game' : 0x2141,
|
| 501 |
+
'Gamma' : 0x393,
|
| 502 |
+
'H' : 0x30b,
|
| 503 |
+
'Im' : 0x2111,
|
| 504 |
+
'Join' : 0x2a1d,
|
| 505 |
+
'L' : 0x141,
|
| 506 |
+
'Lambda' : 0x39b,
|
| 507 |
+
'Ldsh' : 0x21b2,
|
| 508 |
+
'Leftarrow' : 0x21d0,
|
| 509 |
+
'Leftrightarrow' : 0x21d4,
|
| 510 |
+
'Lleftarrow' : 0x21da,
|
| 511 |
+
'Longleftarrow' : 0x27f8,
|
| 512 |
+
'Longleftrightarrow' : 0x27fa,
|
| 513 |
+
'Longrightarrow' : 0x27f9,
|
| 514 |
+
'Lsh' : 0x21b0,
|
| 515 |
+
'Nearrow' : 0x21d7,
|
| 516 |
+
'Nwarrow' : 0x21d6,
|
| 517 |
+
'O' : 0xd8,
|
| 518 |
+
'OE' : 0x152,
|
| 519 |
+
'Omega' : 0x3a9,
|
| 520 |
+
'P' : 0xb6,
|
| 521 |
+
'Phi' : 0x3a6,
|
| 522 |
+
'Pi' : 0x3a0,
|
| 523 |
+
'Psi' : 0x3a8,
|
| 524 |
+
'QED' : 0x220e,
|
| 525 |
+
'Rdsh' : 0x21b3,
|
| 526 |
+
'Re' : 0x211c,
|
| 527 |
+
'Rightarrow' : 0x21d2,
|
| 528 |
+
'Rrightarrow' : 0x21db,
|
| 529 |
+
'Rsh' : 0x21b1,
|
| 530 |
+
'S' : 0xa7,
|
| 531 |
+
'Searrow' : 0x21d8,
|
| 532 |
+
'Sigma' : 0x3a3,
|
| 533 |
+
'Subset' : 0x22d0,
|
| 534 |
+
'Supset' : 0x22d1,
|
| 535 |
+
'Swarrow' : 0x21d9,
|
| 536 |
+
'Theta' : 0x398,
|
| 537 |
+
'Thorn' : 0xde,
|
| 538 |
+
'Uparrow' : 0x21d1,
|
| 539 |
+
'Updownarrow' : 0x21d5,
|
| 540 |
+
'Upsilon' : 0x3a5,
|
| 541 |
+
'Vdash' : 0x22a9,
|
| 542 |
+
'Vert' : 0x2016,
|
| 543 |
+
'Vvdash' : 0x22aa,
|
| 544 |
+
'Xi' : 0x39e,
|
| 545 |
+
'_' : 0x5f,
|
| 546 |
+
'__sqrt__' : 0x221a,
|
| 547 |
+
'aa' : 0xe5,
|
| 548 |
+
'ac' : 0x223e,
|
| 549 |
+
'acute' : 0x301,
|
| 550 |
+
'acwopencirclearrow' : 0x21ba,
|
| 551 |
+
'adots' : 0x22f0,
|
| 552 |
+
'ae' : 0xe6,
|
| 553 |
+
'aleph' : 0x2135,
|
| 554 |
+
'alpha' : 0x3b1,
|
| 555 |
+
'amalg' : 0x2a3f,
|
| 556 |
+
'angle' : 0x2220,
|
| 557 |
+
'approx' : 0x2248,
|
| 558 |
+
'approxeq' : 0x224a,
|
| 559 |
+
'approxident' : 0x224b,
|
| 560 |
+
'arceq' : 0x2258,
|
| 561 |
+
'ast' : 0x2217,
|
| 562 |
+
'asterisk' : 0x2a,
|
| 563 |
+
'asymp' : 0x224d,
|
| 564 |
+
'backcong' : 0x224c,
|
| 565 |
+
'backepsilon' : 0x3f6,
|
| 566 |
+
'backprime' : 0x2035,
|
| 567 |
+
'backsim' : 0x223d,
|
| 568 |
+
'backsimeq' : 0x22cd,
|
| 569 |
+
'backslash' : 0x5c,
|
| 570 |
+
'bagmember' : 0x22ff,
|
| 571 |
+
'bar' : 0x304,
|
| 572 |
+
'barleftarrow' : 0x21e4,
|
| 573 |
+
'barvee' : 0x22bd,
|
| 574 |
+
'barwedge' : 0x22bc,
|
| 575 |
+
'because' : 0x2235,
|
| 576 |
+
'beta' : 0x3b2,
|
| 577 |
+
'beth' : 0x2136,
|
| 578 |
+
'between' : 0x226c,
|
| 579 |
+
'bigcap' : 0x22c2,
|
| 580 |
+
'bigcirc' : 0x25cb,
|
| 581 |
+
'bigcup' : 0x22c3,
|
| 582 |
+
'bigodot' : 0x2a00,
|
| 583 |
+
'bigoplus' : 0x2a01,
|
| 584 |
+
'bigotimes' : 0x2a02,
|
| 585 |
+
'bigsqcup' : 0x2a06,
|
| 586 |
+
'bigstar' : 0x2605,
|
| 587 |
+
'bigtriangledown' : 0x25bd,
|
| 588 |
+
'bigtriangleup' : 0x25b3,
|
| 589 |
+
'biguplus' : 0x2a04,
|
| 590 |
+
'bigvee' : 0x22c1,
|
| 591 |
+
'bigwedge' : 0x22c0,
|
| 592 |
+
'blacksquare' : 0x25a0,
|
| 593 |
+
'blacktriangle' : 0x25b4,
|
| 594 |
+
'blacktriangledown' : 0x25be,
|
| 595 |
+
'blacktriangleleft' : 0x25c0,
|
| 596 |
+
'blacktriangleright' : 0x25b6,
|
| 597 |
+
'bot' : 0x22a5,
|
| 598 |
+
'bowtie' : 0x22c8,
|
| 599 |
+
'boxbar' : 0x25eb,
|
| 600 |
+
'boxdot' : 0x22a1,
|
| 601 |
+
'boxminus' : 0x229f,
|
| 602 |
+
'boxplus' : 0x229e,
|
| 603 |
+
'boxtimes' : 0x22a0,
|
| 604 |
+
'breve' : 0x306,
|
| 605 |
+
'bullet' : 0x2219,
|
| 606 |
+
'bumpeq' : 0x224f,
|
| 607 |
+
'c' : 0x327,
|
| 608 |
+
'candra' : 0x310,
|
| 609 |
+
'cap' : 0x2229,
|
| 610 |
+
'carriagereturn' : 0x21b5,
|
| 611 |
+
'cdot' : 0x22c5,
|
| 612 |
+
'cdotp' : 0xb7,
|
| 613 |
+
'cdots' : 0x22ef,
|
| 614 |
+
'cent' : 0xa2,
|
| 615 |
+
'check' : 0x30c,
|
| 616 |
+
'checkmark' : 0x2713,
|
| 617 |
+
'chi' : 0x3c7,
|
| 618 |
+
'circ' : 0x2218,
|
| 619 |
+
'circeq' : 0x2257,
|
| 620 |
+
'circlearrowleft' : 0x21ba,
|
| 621 |
+
'circlearrowright' : 0x21bb,
|
| 622 |
+
'circledR' : 0xae,
|
| 623 |
+
'circledS' : 0x24c8,
|
| 624 |
+
'circledast' : 0x229b,
|
| 625 |
+
'circledcirc' : 0x229a,
|
| 626 |
+
'circleddash' : 0x229d,
|
| 627 |
+
'circumflexaccent' : 0x302,
|
| 628 |
+
'clubsuit' : 0x2663,
|
| 629 |
+
'clubsuitopen' : 0x2667,
|
| 630 |
+
'colon' : 0x3a,
|
| 631 |
+
'coloneq' : 0x2254,
|
| 632 |
+
'combiningacuteaccent' : 0x301,
|
| 633 |
+
'combiningbreve' : 0x306,
|
| 634 |
+
'combiningdiaeresis' : 0x308,
|
| 635 |
+
'combiningdotabove' : 0x307,
|
| 636 |
+
'combiningfourdotsabove' : 0x20dc,
|
| 637 |
+
'combininggraveaccent' : 0x300,
|
| 638 |
+
'combiningoverline' : 0x304,
|
| 639 |
+
'combiningrightarrowabove' : 0x20d7,
|
| 640 |
+
'combiningthreedotsabove' : 0x20db,
|
| 641 |
+
'combiningtilde' : 0x303,
|
| 642 |
+
'complement' : 0x2201,
|
| 643 |
+
'cong' : 0x2245,
|
| 644 |
+
'coprod' : 0x2210,
|
| 645 |
+
'copyright' : 0xa9,
|
| 646 |
+
'cup' : 0x222a,
|
| 647 |
+
'cupdot' : 0x228d,
|
| 648 |
+
'cupleftarrow' : 0x228c,
|
| 649 |
+
'curlyeqprec' : 0x22de,
|
| 650 |
+
'curlyeqsucc' : 0x22df,
|
| 651 |
+
'curlyvee' : 0x22ce,
|
| 652 |
+
'curlywedge' : 0x22cf,
|
| 653 |
+
'curvearrowleft' : 0x21b6,
|
| 654 |
+
'curvearrowright' : 0x21b7,
|
| 655 |
+
'cwopencirclearrow' : 0x21bb,
|
| 656 |
+
'd' : 0x323,
|
| 657 |
+
'dag' : 0x2020,
|
| 658 |
+
'dagger' : 0x2020,
|
| 659 |
+
'daleth' : 0x2138,
|
| 660 |
+
'danger' : 0x2621,
|
| 661 |
+
'dashleftarrow' : 0x290e,
|
| 662 |
+
'dashrightarrow' : 0x290f,
|
| 663 |
+
'dashv' : 0x22a3,
|
| 664 |
+
'ddag' : 0x2021,
|
| 665 |
+
'ddagger' : 0x2021,
|
| 666 |
+
'ddddot' : 0x20dc,
|
| 667 |
+
'dddot' : 0x20db,
|
| 668 |
+
'ddot' : 0x308,
|
| 669 |
+
'ddots' : 0x22f1,
|
| 670 |
+
'degree' : 0xb0,
|
| 671 |
+
'delta' : 0x3b4,
|
| 672 |
+
'dh' : 0xf0,
|
| 673 |
+
'diamond' : 0x22c4,
|
| 674 |
+
'diamondsuit' : 0x2662,
|
| 675 |
+
'digamma' : 0x3dd,
|
| 676 |
+
'disin' : 0x22f2,
|
| 677 |
+
'div' : 0xf7,
|
| 678 |
+
'divideontimes' : 0x22c7,
|
| 679 |
+
'dot' : 0x307,
|
| 680 |
+
'doteq' : 0x2250,
|
| 681 |
+
'doteqdot' : 0x2251,
|
| 682 |
+
'dotminus' : 0x2238,
|
| 683 |
+
'dotplus' : 0x2214,
|
| 684 |
+
'dots' : 0x2026,
|
| 685 |
+
'dotsminusdots' : 0x223a,
|
| 686 |
+
'doublebarwedge' : 0x2306,
|
| 687 |
+
'downarrow' : 0x2193,
|
| 688 |
+
'downdownarrows' : 0x21ca,
|
| 689 |
+
'downharpoonleft' : 0x21c3,
|
| 690 |
+
'downharpoonright' : 0x21c2,
|
| 691 |
+
'downzigzagarrow' : 0x21af,
|
| 692 |
+
'ell' : 0x2113,
|
| 693 |
+
'emdash' : 0x2014,
|
| 694 |
+
'emptyset' : 0x2205,
|
| 695 |
+
'endash' : 0x2013,
|
| 696 |
+
'epsilon' : 0x3b5,
|
| 697 |
+
'eqcirc' : 0x2256,
|
| 698 |
+
'eqcolon' : 0x2255,
|
| 699 |
+
'eqdef' : 0x225d,
|
| 700 |
+
'eqgtr' : 0x22dd,
|
| 701 |
+
'eqless' : 0x22dc,
|
| 702 |
+
'eqsim' : 0x2242,
|
| 703 |
+
'eqslantgtr' : 0x2a96,
|
| 704 |
+
'eqslantless' : 0x2a95,
|
| 705 |
+
'equal' : 0x3d,
|
| 706 |
+
'equalparallel' : 0x22d5,
|
| 707 |
+
'equiv' : 0x2261,
|
| 708 |
+
'eta' : 0x3b7,
|
| 709 |
+
'eth' : 0xf0,
|
| 710 |
+
'exists' : 0x2203,
|
| 711 |
+
'fallingdotseq' : 0x2252,
|
| 712 |
+
'flat' : 0x266d,
|
| 713 |
+
'forall' : 0x2200,
|
| 714 |
+
'frakC' : 0x212d,
|
| 715 |
+
'frakZ' : 0x2128,
|
| 716 |
+
'frown' : 0x2322,
|
| 717 |
+
'gamma' : 0x3b3,
|
| 718 |
+
'geq' : 0x2265,
|
| 719 |
+
'geqq' : 0x2267,
|
| 720 |
+
'geqslant' : 0x2a7e,
|
| 721 |
+
'gg' : 0x226b,
|
| 722 |
+
'ggg' : 0x22d9,
|
| 723 |
+
'gimel' : 0x2137,
|
| 724 |
+
'gnapprox' : 0x2a8a,
|
| 725 |
+
'gneqq' : 0x2269,
|
| 726 |
+
'gnsim' : 0x22e7,
|
| 727 |
+
'grave' : 0x300,
|
| 728 |
+
'greater' : 0x3e,
|
| 729 |
+
'gtrapprox' : 0x2a86,
|
| 730 |
+
'gtrdot' : 0x22d7,
|
| 731 |
+
'gtreqless' : 0x22db,
|
| 732 |
+
'gtreqqless' : 0x2a8c,
|
| 733 |
+
'gtrless' : 0x2277,
|
| 734 |
+
'gtrsim' : 0x2273,
|
| 735 |
+
'guillemotleft' : 0xab,
|
| 736 |
+
'guillemotright' : 0xbb,
|
| 737 |
+
'guilsinglleft' : 0x2039,
|
| 738 |
+
'guilsinglright' : 0x203a,
|
| 739 |
+
'hat' : 0x302,
|
| 740 |
+
'hbar' : 0x127,
|
| 741 |
+
'heartsuit' : 0x2661,
|
| 742 |
+
'hermitmatrix' : 0x22b9,
|
| 743 |
+
'hookleftarrow' : 0x21a9,
|
| 744 |
+
'hookrightarrow' : 0x21aa,
|
| 745 |
+
'hslash' : 0x210f,
|
| 746 |
+
'i' : 0x131,
|
| 747 |
+
'iiiint' : 0x2a0c,
|
| 748 |
+
'iiint' : 0x222d,
|
| 749 |
+
'iint' : 0x222c,
|
| 750 |
+
'imageof' : 0x22b7,
|
| 751 |
+
'imath' : 0x131,
|
| 752 |
+
'in' : 0x2208,
|
| 753 |
+
'increment' : 0x2206,
|
| 754 |
+
'infty' : 0x221e,
|
| 755 |
+
'int' : 0x222b,
|
| 756 |
+
'intercal' : 0x22ba,
|
| 757 |
+
'invnot' : 0x2310,
|
| 758 |
+
'iota' : 0x3b9,
|
| 759 |
+
'isinE' : 0x22f9,
|
| 760 |
+
'isindot' : 0x22f5,
|
| 761 |
+
'isinobar' : 0x22f7,
|
| 762 |
+
'isins' : 0x22f4,
|
| 763 |
+
'isinvb' : 0x22f8,
|
| 764 |
+
'jmath' : 0x237,
|
| 765 |
+
'k' : 0x328,
|
| 766 |
+
'kappa' : 0x3ba,
|
| 767 |
+
'kernelcontraction' : 0x223b,
|
| 768 |
+
'l' : 0x142,
|
| 769 |
+
'lambda' : 0x3bb,
|
| 770 |
+
'lambdabar' : 0x19b,
|
| 771 |
+
'langle' : 0x27e8,
|
| 772 |
+
'lasp' : 0x2bd,
|
| 773 |
+
'lbrace' : 0x7b,
|
| 774 |
+
'lbrack' : 0x5b,
|
| 775 |
+
'lceil' : 0x2308,
|
| 776 |
+
'ldots' : 0x2026,
|
| 777 |
+
'leadsto' : 0x21dd,
|
| 778 |
+
'leftarrow' : 0x2190,
|
| 779 |
+
'leftarrowtail' : 0x21a2,
|
| 780 |
+
'leftbrace' : 0x7b,
|
| 781 |
+
'leftharpoonaccent' : 0x20d0,
|
| 782 |
+
'leftharpoondown' : 0x21bd,
|
| 783 |
+
'leftharpoonup' : 0x21bc,
|
| 784 |
+
'leftleftarrows' : 0x21c7,
|
| 785 |
+
'leftparen' : 0x28,
|
| 786 |
+
'leftrightarrow' : 0x2194,
|
| 787 |
+
'leftrightarrows' : 0x21c6,
|
| 788 |
+
'leftrightharpoons' : 0x21cb,
|
| 789 |
+
'leftrightsquigarrow' : 0x21ad,
|
| 790 |
+
'leftsquigarrow' : 0x219c,
|
| 791 |
+
'leftthreetimes' : 0x22cb,
|
| 792 |
+
'leq' : 0x2264,
|
| 793 |
+
'leqq' : 0x2266,
|
| 794 |
+
'leqslant' : 0x2a7d,
|
| 795 |
+
'less' : 0x3c,
|
| 796 |
+
'lessapprox' : 0x2a85,
|
| 797 |
+
'lessdot' : 0x22d6,
|
| 798 |
+
'lesseqgtr' : 0x22da,
|
| 799 |
+
'lesseqqgtr' : 0x2a8b,
|
| 800 |
+
'lessgtr' : 0x2276,
|
| 801 |
+
'lesssim' : 0x2272,
|
| 802 |
+
'lfloor' : 0x230a,
|
| 803 |
+
'lgroup' : 0x27ee,
|
| 804 |
+
'lhd' : 0x25c1,
|
| 805 |
+
'll' : 0x226a,
|
| 806 |
+
'llcorner' : 0x231e,
|
| 807 |
+
'lll' : 0x22d8,
|
| 808 |
+
'lnapprox' : 0x2a89,
|
| 809 |
+
'lneqq' : 0x2268,
|
| 810 |
+
'lnsim' : 0x22e6,
|
| 811 |
+
'longleftarrow' : 0x27f5,
|
| 812 |
+
'longleftrightarrow' : 0x27f7,
|
| 813 |
+
'longmapsto' : 0x27fc,
|
| 814 |
+
'longrightarrow' : 0x27f6,
|
| 815 |
+
'looparrowleft' : 0x21ab,
|
| 816 |
+
'looparrowright' : 0x21ac,
|
| 817 |
+
'lq' : 0x2018,
|
| 818 |
+
'lrcorner' : 0x231f,
|
| 819 |
+
'ltimes' : 0x22c9,
|
| 820 |
+
'macron' : 0xaf,
|
| 821 |
+
'maltese' : 0x2720,
|
| 822 |
+
'mapsdown' : 0x21a7,
|
| 823 |
+
'mapsfrom' : 0x21a4,
|
| 824 |
+
'mapsto' : 0x21a6,
|
| 825 |
+
'mapsup' : 0x21a5,
|
| 826 |
+
'measeq' : 0x225e,
|
| 827 |
+
'measuredangle' : 0x2221,
|
| 828 |
+
'measuredrightangle' : 0x22be,
|
| 829 |
+
'merge' : 0x2a55,
|
| 830 |
+
'mho' : 0x2127,
|
| 831 |
+
'mid' : 0x2223,
|
| 832 |
+
'minus' : 0x2212,
|
| 833 |
+
'minuscolon' : 0x2239,
|
| 834 |
+
'models' : 0x22a7,
|
| 835 |
+
'mp' : 0x2213,
|
| 836 |
+
'mu' : 0x3bc,
|
| 837 |
+
'multimap' : 0x22b8,
|
| 838 |
+
'nLeftarrow' : 0x21cd,
|
| 839 |
+
'nLeftrightarrow' : 0x21ce,
|
| 840 |
+
'nRightarrow' : 0x21cf,
|
| 841 |
+
'nVDash' : 0x22af,
|
| 842 |
+
'nVdash' : 0x22ae,
|
| 843 |
+
'nabla' : 0x2207,
|
| 844 |
+
'napprox' : 0x2249,
|
| 845 |
+
'natural' : 0x266e,
|
| 846 |
+
'ncong' : 0x2247,
|
| 847 |
+
'ne' : 0x2260,
|
| 848 |
+
'nearrow' : 0x2197,
|
| 849 |
+
'neg' : 0xac,
|
| 850 |
+
'neq' : 0x2260,
|
| 851 |
+
'nequiv' : 0x2262,
|
| 852 |
+
'nexists' : 0x2204,
|
| 853 |
+
'ngeq' : 0x2271,
|
| 854 |
+
'ngtr' : 0x226f,
|
| 855 |
+
'ngtrless' : 0x2279,
|
| 856 |
+
'ngtrsim' : 0x2275,
|
| 857 |
+
'ni' : 0x220b,
|
| 858 |
+
'niobar' : 0x22fe,
|
| 859 |
+
'nis' : 0x22fc,
|
| 860 |
+
'nisd' : 0x22fa,
|
| 861 |
+
'nleftarrow' : 0x219a,
|
| 862 |
+
'nleftrightarrow' : 0x21ae,
|
| 863 |
+
'nleq' : 0x2270,
|
| 864 |
+
'nless' : 0x226e,
|
| 865 |
+
'nlessgtr' : 0x2278,
|
| 866 |
+
'nlesssim' : 0x2274,
|
| 867 |
+
'nmid' : 0x2224,
|
| 868 |
+
'not' : 0x338,
|
| 869 |
+
'notin' : 0x2209,
|
| 870 |
+
'notsmallowns' : 0x220c,
|
| 871 |
+
'nparallel' : 0x2226,
|
| 872 |
+
'nprec' : 0x2280,
|
| 873 |
+
'npreccurlyeq' : 0x22e0,
|
| 874 |
+
'nrightarrow' : 0x219b,
|
| 875 |
+
'nsim' : 0x2241,
|
| 876 |
+
'nsimeq' : 0x2244,
|
| 877 |
+
'nsqsubseteq' : 0x22e2,
|
| 878 |
+
'nsqsupseteq' : 0x22e3,
|
| 879 |
+
'nsubset' : 0x2284,
|
| 880 |
+
'nsubseteq' : 0x2288,
|
| 881 |
+
'nsucc' : 0x2281,
|
| 882 |
+
'nsucccurlyeq' : 0x22e1,
|
| 883 |
+
'nsupset' : 0x2285,
|
| 884 |
+
'nsupseteq' : 0x2289,
|
| 885 |
+
'ntriangleleft' : 0x22ea,
|
| 886 |
+
'ntrianglelefteq' : 0x22ec,
|
| 887 |
+
'ntriangleright' : 0x22eb,
|
| 888 |
+
'ntrianglerighteq' : 0x22ed,
|
| 889 |
+
'nu' : 0x3bd,
|
| 890 |
+
'nvDash' : 0x22ad,
|
| 891 |
+
'nvdash' : 0x22ac,
|
| 892 |
+
'nwarrow' : 0x2196,
|
| 893 |
+
'o' : 0xf8,
|
| 894 |
+
'obar' : 0x233d,
|
| 895 |
+
'ocirc' : 0x30a,
|
| 896 |
+
'odot' : 0x2299,
|
| 897 |
+
'oe' : 0x153,
|
| 898 |
+
'oequal' : 0x229c,
|
| 899 |
+
'oiiint' : 0x2230,
|
| 900 |
+
'oiint' : 0x222f,
|
| 901 |
+
'oint' : 0x222e,
|
| 902 |
+
'omega' : 0x3c9,
|
| 903 |
+
'ominus' : 0x2296,
|
| 904 |
+
'oplus' : 0x2295,
|
| 905 |
+
'origof' : 0x22b6,
|
| 906 |
+
'oslash' : 0x2298,
|
| 907 |
+
'otimes' : 0x2297,
|
| 908 |
+
'overarc' : 0x311,
|
| 909 |
+
'overleftarrow' : 0x20d6,
|
| 910 |
+
'overleftrightarrow' : 0x20e1,
|
| 911 |
+
'parallel' : 0x2225,
|
| 912 |
+
'partial' : 0x2202,
|
| 913 |
+
'perp' : 0x27c2,
|
| 914 |
+
'perthousand' : 0x2030,
|
| 915 |
+
'phi' : 0x3d5,
|
| 916 |
+
'pi' : 0x3c0,
|
| 917 |
+
'pitchfork' : 0x22d4,
|
| 918 |
+
'plus' : 0x2b,
|
| 919 |
+
'pm' : 0xb1,
|
| 920 |
+
'prec' : 0x227a,
|
| 921 |
+
'precapprox' : 0x2ab7,
|
| 922 |
+
'preccurlyeq' : 0x227c,
|
| 923 |
+
'preceq' : 0x227c,
|
| 924 |
+
'precnapprox' : 0x2ab9,
|
| 925 |
+
'precnsim' : 0x22e8,
|
| 926 |
+
'precsim' : 0x227e,
|
| 927 |
+
'prime' : 0x2032,
|
| 928 |
+
'prod' : 0x220f,
|
| 929 |
+
'propto' : 0x221d,
|
| 930 |
+
'prurel' : 0x22b0,
|
| 931 |
+
'psi' : 0x3c8,
|
| 932 |
+
'quad' : 0x2003,
|
| 933 |
+
'questeq' : 0x225f,
|
| 934 |
+
'rangle' : 0x27e9,
|
| 935 |
+
'rasp' : 0x2bc,
|
| 936 |
+
'ratio' : 0x2236,
|
| 937 |
+
'rbrace' : 0x7d,
|
| 938 |
+
'rbrack' : 0x5d,
|
| 939 |
+
'rceil' : 0x2309,
|
| 940 |
+
'rfloor' : 0x230b,
|
| 941 |
+
'rgroup' : 0x27ef,
|
| 942 |
+
'rhd' : 0x25b7,
|
| 943 |
+
'rho' : 0x3c1,
|
| 944 |
+
'rightModels' : 0x22ab,
|
| 945 |
+
'rightangle' : 0x221f,
|
| 946 |
+
'rightarrow' : 0x2192,
|
| 947 |
+
'rightarrowbar' : 0x21e5,
|
| 948 |
+
'rightarrowtail' : 0x21a3,
|
| 949 |
+
'rightassert' : 0x22a6,
|
| 950 |
+
'rightbrace' : 0x7d,
|
| 951 |
+
'rightharpoonaccent' : 0x20d1,
|
| 952 |
+
'rightharpoondown' : 0x21c1,
|
| 953 |
+
'rightharpoonup' : 0x21c0,
|
| 954 |
+
'rightleftarrows' : 0x21c4,
|
| 955 |
+
'rightleftharpoons' : 0x21cc,
|
| 956 |
+
'rightparen' : 0x29,
|
| 957 |
+
'rightrightarrows' : 0x21c9,
|
| 958 |
+
'rightsquigarrow' : 0x219d,
|
| 959 |
+
'rightthreetimes' : 0x22cc,
|
| 960 |
+
'rightzigzagarrow' : 0x21dd,
|
| 961 |
+
'ring' : 0x2da,
|
| 962 |
+
'risingdotseq' : 0x2253,
|
| 963 |
+
'rq' : 0x2019,
|
| 964 |
+
'rtimes' : 0x22ca,
|
| 965 |
+
'scrB' : 0x212c,
|
| 966 |
+
'scrE' : 0x2130,
|
| 967 |
+
'scrF' : 0x2131,
|
| 968 |
+
'scrH' : 0x210b,
|
| 969 |
+
'scrI' : 0x2110,
|
| 970 |
+
'scrL' : 0x2112,
|
| 971 |
+
'scrM' : 0x2133,
|
| 972 |
+
'scrR' : 0x211b,
|
| 973 |
+
'scre' : 0x212f,
|
| 974 |
+
'scrg' : 0x210a,
|
| 975 |
+
'scro' : 0x2134,
|
| 976 |
+
'scurel' : 0x22b1,
|
| 977 |
+
'searrow' : 0x2198,
|
| 978 |
+
'setminus' : 0x2216,
|
| 979 |
+
'sharp' : 0x266f,
|
| 980 |
+
'sigma' : 0x3c3,
|
| 981 |
+
'sim' : 0x223c,
|
| 982 |
+
'simeq' : 0x2243,
|
| 983 |
+
'simneqq' : 0x2246,
|
| 984 |
+
'sinewave' : 0x223f,
|
| 985 |
+
'slash' : 0x2215,
|
| 986 |
+
'smallin' : 0x220a,
|
| 987 |
+
'smallintclockwise' : 0x2231,
|
| 988 |
+
'smallointctrcclockwise' : 0x2233,
|
| 989 |
+
'smallowns' : 0x220d,
|
| 990 |
+
'smallsetminus' : 0x2216,
|
| 991 |
+
'smallvarointclockwise' : 0x2232,
|
| 992 |
+
'smile' : 0x2323,
|
| 993 |
+
'solbar' : 0x233f,
|
| 994 |
+
'spadesuit' : 0x2660,
|
| 995 |
+
'spadesuitopen' : 0x2664,
|
| 996 |
+
'sphericalangle' : 0x2222,
|
| 997 |
+
'sqcap' : 0x2293,
|
| 998 |
+
'sqcup' : 0x2294,
|
| 999 |
+
'sqsubset' : 0x228f,
|
| 1000 |
+
'sqsubseteq' : 0x2291,
|
| 1001 |
+
'sqsubsetneq' : 0x22e4,
|
| 1002 |
+
'sqsupset' : 0x2290,
|
| 1003 |
+
'sqsupseteq' : 0x2292,
|
| 1004 |
+
'sqsupsetneq' : 0x22e5,
|
| 1005 |
+
'ss' : 0xdf,
|
| 1006 |
+
'star' : 0x22c6,
|
| 1007 |
+
'stareq' : 0x225b,
|
| 1008 |
+
'sterling' : 0xa3,
|
| 1009 |
+
'subset' : 0x2282,
|
| 1010 |
+
'subseteq' : 0x2286,
|
| 1011 |
+
'subseteqq' : 0x2ac5,
|
| 1012 |
+
'subsetneq' : 0x228a,
|
| 1013 |
+
'subsetneqq' : 0x2acb,
|
| 1014 |
+
'succ' : 0x227b,
|
| 1015 |
+
'succapprox' : 0x2ab8,
|
| 1016 |
+
'succcurlyeq' : 0x227d,
|
| 1017 |
+
'succeq' : 0x227d,
|
| 1018 |
+
'succnapprox' : 0x2aba,
|
| 1019 |
+
'succnsim' : 0x22e9,
|
| 1020 |
+
'succsim' : 0x227f,
|
| 1021 |
+
'sum' : 0x2211,
|
| 1022 |
+
'supset' : 0x2283,
|
| 1023 |
+
'supseteq' : 0x2287,
|
| 1024 |
+
'supseteqq' : 0x2ac6,
|
| 1025 |
+
'supsetneq' : 0x228b,
|
| 1026 |
+
'supsetneqq' : 0x2acc,
|
| 1027 |
+
'swarrow' : 0x2199,
|
| 1028 |
+
't' : 0x361,
|
| 1029 |
+
'tau' : 0x3c4,
|
| 1030 |
+
'textasciiacute' : 0xb4,
|
| 1031 |
+
'textasciicircum' : 0x5e,
|
| 1032 |
+
'textasciigrave' : 0x60,
|
| 1033 |
+
'textasciitilde' : 0x7e,
|
| 1034 |
+
'textexclamdown' : 0xa1,
|
| 1035 |
+
'textquestiondown' : 0xbf,
|
| 1036 |
+
'textquotedblleft' : 0x201c,
|
| 1037 |
+
'textquotedblright' : 0x201d,
|
| 1038 |
+
'therefore' : 0x2234,
|
| 1039 |
+
'theta' : 0x3b8,
|
| 1040 |
+
'thickspace' : 0x2005,
|
| 1041 |
+
'thorn' : 0xfe,
|
| 1042 |
+
'tilde' : 0x303,
|
| 1043 |
+
'times' : 0xd7,
|
| 1044 |
+
'to' : 0x2192,
|
| 1045 |
+
'top' : 0x22a4,
|
| 1046 |
+
'triangle' : 0x25b3,
|
| 1047 |
+
'triangledown' : 0x25bf,
|
| 1048 |
+
'triangleeq' : 0x225c,
|
| 1049 |
+
'triangleleft' : 0x25c1,
|
| 1050 |
+
'trianglelefteq' : 0x22b4,
|
| 1051 |
+
'triangleq' : 0x225c,
|
| 1052 |
+
'triangleright' : 0x25b7,
|
| 1053 |
+
'trianglerighteq' : 0x22b5,
|
| 1054 |
+
'turnednot' : 0x2319,
|
| 1055 |
+
'twoheaddownarrow' : 0x21a1,
|
| 1056 |
+
'twoheadleftarrow' : 0x219e,
|
| 1057 |
+
'twoheadrightarrow' : 0x21a0,
|
| 1058 |
+
'twoheaduparrow' : 0x219f,
|
| 1059 |
+
'ulcorner' : 0x231c,
|
| 1060 |
+
'underbar' : 0x331,
|
| 1061 |
+
'unlhd' : 0x22b4,
|
| 1062 |
+
'unrhd' : 0x22b5,
|
| 1063 |
+
'uparrow' : 0x2191,
|
| 1064 |
+
'updownarrow' : 0x2195,
|
| 1065 |
+
'updownarrowbar' : 0x21a8,
|
| 1066 |
+
'updownarrows' : 0x21c5,
|
| 1067 |
+
'upharpoonleft' : 0x21bf,
|
| 1068 |
+
'upharpoonright' : 0x21be,
|
| 1069 |
+
'uplus' : 0x228e,
|
| 1070 |
+
'upsilon' : 0x3c5,
|
| 1071 |
+
'upuparrows' : 0x21c8,
|
| 1072 |
+
'urcorner' : 0x231d,
|
| 1073 |
+
'vDash' : 0x22a8,
|
| 1074 |
+
'varepsilon' : 0x3b5,
|
| 1075 |
+
'varisinobar' : 0x22f6,
|
| 1076 |
+
'varisins' : 0x22f3,
|
| 1077 |
+
'varkappa' : 0x3f0,
|
| 1078 |
+
'varlrtriangle' : 0x22bf,
|
| 1079 |
+
'varniobar' : 0x22fd,
|
| 1080 |
+
'varnis' : 0x22fb,
|
| 1081 |
+
'varnothing' : 0x2205,
|
| 1082 |
+
'varphi' : 0x3c6,
|
| 1083 |
+
'varpi' : 0x3d6,
|
| 1084 |
+
'varpropto' : 0x221d,
|
| 1085 |
+
'varrho' : 0x3f1,
|
| 1086 |
+
'varsigma' : 0x3c2,
|
| 1087 |
+
'vartheta' : 0x3d1,
|
| 1088 |
+
'vartriangle' : 0x25b5,
|
| 1089 |
+
'vartriangleleft' : 0x22b2,
|
| 1090 |
+
'vartriangleright' : 0x22b3,
|
| 1091 |
+
'vdash' : 0x22a2,
|
| 1092 |
+
'vdots' : 0x22ee,
|
| 1093 |
+
'vec' : 0x20d7,
|
| 1094 |
+
'vee' : 0x2228,
|
| 1095 |
+
'veebar' : 0x22bb,
|
| 1096 |
+
'veeeq' : 0x225a,
|
| 1097 |
+
'vert' : 0x7c,
|
| 1098 |
+
'wedge' : 0x2227,
|
| 1099 |
+
'wedgeq' : 0x2259,
|
| 1100 |
+
'widebar' : 0x305,
|
| 1101 |
+
'widehat' : 0x302,
|
| 1102 |
+
'widetilde' : 0x303,
|
| 1103 |
+
'wp' : 0x2118,
|
| 1104 |
+
'wr' : 0x2240,
|
| 1105 |
+
'xi' : 0x3be,
|
| 1106 |
+
'yen' : 0xa5,
|
| 1107 |
+
'zeta' : 0x3b6,
|
| 1108 |
+
'{' : 0x7b,
|
| 1109 |
+
'|' : 0x2016,
|
| 1110 |
+
'}' : 0x7d,
|
| 1111 |
+
}
|
| 1112 |
+
|
| 1113 |
+
# Each element is a 4-tuple of the form:
|
| 1114 |
+
# src_start, src_end, dst_font, dst_start
|
| 1115 |
+
|
| 1116 |
+
_EntryTypeIn = tuple[str, str, str, str | int]
|
| 1117 |
+
_EntryTypeOut = tuple[int, int, str, int]
|
| 1118 |
+
|
| 1119 |
+
_stix_virtual_fonts: dict[str, dict[str, list[_EntryTypeIn]] | list[_EntryTypeIn]] = {
|
| 1120 |
+
'bb': {
|
| 1121 |
+
"rm": [
|
| 1122 |
+
("\N{DIGIT ZERO}",
|
| 1123 |
+
"\N{DIGIT NINE}",
|
| 1124 |
+
"rm",
|
| 1125 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK DIGIT ZERO}"),
|
| 1126 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1127 |
+
"\N{LATIN CAPITAL LETTER B}",
|
| 1128 |
+
"rm",
|
| 1129 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK CAPITAL A}"),
|
| 1130 |
+
("\N{LATIN CAPITAL LETTER C}",
|
| 1131 |
+
"\N{LATIN CAPITAL LETTER C}",
|
| 1132 |
+
"rm",
|
| 1133 |
+
"\N{DOUBLE-STRUCK CAPITAL C}"),
|
| 1134 |
+
("\N{LATIN CAPITAL LETTER D}",
|
| 1135 |
+
"\N{LATIN CAPITAL LETTER G}",
|
| 1136 |
+
"rm",
|
| 1137 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK CAPITAL D}"),
|
| 1138 |
+
("\N{LATIN CAPITAL LETTER H}",
|
| 1139 |
+
"\N{LATIN CAPITAL LETTER H}",
|
| 1140 |
+
"rm",
|
| 1141 |
+
"\N{DOUBLE-STRUCK CAPITAL H}"),
|
| 1142 |
+
("\N{LATIN CAPITAL LETTER I}",
|
| 1143 |
+
"\N{LATIN CAPITAL LETTER M}",
|
| 1144 |
+
"rm",
|
| 1145 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK CAPITAL I}"),
|
| 1146 |
+
("\N{LATIN CAPITAL LETTER N}",
|
| 1147 |
+
"\N{LATIN CAPITAL LETTER N}",
|
| 1148 |
+
"rm",
|
| 1149 |
+
"\N{DOUBLE-STRUCK CAPITAL N}"),
|
| 1150 |
+
("\N{LATIN CAPITAL LETTER O}",
|
| 1151 |
+
"\N{LATIN CAPITAL LETTER O}",
|
| 1152 |
+
"rm",
|
| 1153 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK CAPITAL O}"),
|
| 1154 |
+
("\N{LATIN CAPITAL LETTER P}",
|
| 1155 |
+
"\N{LATIN CAPITAL LETTER Q}",
|
| 1156 |
+
"rm",
|
| 1157 |
+
"\N{DOUBLE-STRUCK CAPITAL P}"),
|
| 1158 |
+
("\N{LATIN CAPITAL LETTER R}",
|
| 1159 |
+
"\N{LATIN CAPITAL LETTER R}",
|
| 1160 |
+
"rm",
|
| 1161 |
+
"\N{DOUBLE-STRUCK CAPITAL R}"),
|
| 1162 |
+
("\N{LATIN CAPITAL LETTER S}",
|
| 1163 |
+
"\N{LATIN CAPITAL LETTER Y}",
|
| 1164 |
+
"rm",
|
| 1165 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK CAPITAL S}"),
|
| 1166 |
+
("\N{LATIN CAPITAL LETTER Z}",
|
| 1167 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1168 |
+
"rm",
|
| 1169 |
+
"\N{DOUBLE-STRUCK CAPITAL Z}"),
|
| 1170 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1171 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1172 |
+
"rm",
|
| 1173 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK SMALL A}"),
|
| 1174 |
+
("\N{GREEK CAPITAL LETTER GAMMA}",
|
| 1175 |
+
"\N{GREEK CAPITAL LETTER GAMMA}",
|
| 1176 |
+
"rm",
|
| 1177 |
+
"\N{DOUBLE-STRUCK CAPITAL GAMMA}"),
|
| 1178 |
+
("\N{GREEK CAPITAL LETTER PI}",
|
| 1179 |
+
"\N{GREEK CAPITAL LETTER PI}",
|
| 1180 |
+
"rm",
|
| 1181 |
+
"\N{DOUBLE-STRUCK CAPITAL PI}"),
|
| 1182 |
+
("\N{GREEK CAPITAL LETTER SIGMA}",
|
| 1183 |
+
"\N{GREEK CAPITAL LETTER SIGMA}",
|
| 1184 |
+
"rm",
|
| 1185 |
+
"\N{DOUBLE-STRUCK N-ARY SUMMATION}"),
|
| 1186 |
+
("\N{GREEK SMALL LETTER GAMMA}",
|
| 1187 |
+
"\N{GREEK SMALL LETTER GAMMA}",
|
| 1188 |
+
"rm",
|
| 1189 |
+
"\N{DOUBLE-STRUCK SMALL GAMMA}"),
|
| 1190 |
+
("\N{GREEK SMALL LETTER PI}",
|
| 1191 |
+
"\N{GREEK SMALL LETTER PI}",
|
| 1192 |
+
"rm",
|
| 1193 |
+
"\N{DOUBLE-STRUCK SMALL PI}"),
|
| 1194 |
+
],
|
| 1195 |
+
"it": [
|
| 1196 |
+
("\N{DIGIT ZERO}",
|
| 1197 |
+
"\N{DIGIT NINE}",
|
| 1198 |
+
"rm",
|
| 1199 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK DIGIT ZERO}"),
|
| 1200 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1201 |
+
"\N{LATIN CAPITAL LETTER B}",
|
| 1202 |
+
"it",
|
| 1203 |
+
0xe154),
|
| 1204 |
+
("\N{LATIN CAPITAL LETTER C}",
|
| 1205 |
+
"\N{LATIN CAPITAL LETTER C}",
|
| 1206 |
+
"it",
|
| 1207 |
+
"\N{DOUBLE-STRUCK CAPITAL C}"),
|
| 1208 |
+
("\N{LATIN CAPITAL LETTER D}",
|
| 1209 |
+
"\N{LATIN CAPITAL LETTER D}",
|
| 1210 |
+
"it",
|
| 1211 |
+
"\N{DOUBLE-STRUCK ITALIC CAPITAL D}"),
|
| 1212 |
+
("\N{LATIN CAPITAL LETTER E}",
|
| 1213 |
+
"\N{LATIN CAPITAL LETTER G}",
|
| 1214 |
+
"it",
|
| 1215 |
+
0xe156),
|
| 1216 |
+
("\N{LATIN CAPITAL LETTER H}",
|
| 1217 |
+
"\N{LATIN CAPITAL LETTER H}",
|
| 1218 |
+
"it",
|
| 1219 |
+
"\N{DOUBLE-STRUCK CAPITAL H}"),
|
| 1220 |
+
("\N{LATIN CAPITAL LETTER I}",
|
| 1221 |
+
"\N{LATIN CAPITAL LETTER M}",
|
| 1222 |
+
"it",
|
| 1223 |
+
0xe159),
|
| 1224 |
+
("\N{LATIN CAPITAL LETTER N}",
|
| 1225 |
+
"\N{LATIN CAPITAL LETTER N}",
|
| 1226 |
+
"it",
|
| 1227 |
+
"\N{DOUBLE-STRUCK CAPITAL N}"),
|
| 1228 |
+
("\N{LATIN CAPITAL LETTER O}",
|
| 1229 |
+
"\N{LATIN CAPITAL LETTER O}",
|
| 1230 |
+
"it",
|
| 1231 |
+
0xe15e),
|
| 1232 |
+
("\N{LATIN CAPITAL LETTER P}",
|
| 1233 |
+
"\N{LATIN CAPITAL LETTER Q}",
|
| 1234 |
+
"it",
|
| 1235 |
+
"\N{DOUBLE-STRUCK CAPITAL P}"),
|
| 1236 |
+
("\N{LATIN CAPITAL LETTER R}",
|
| 1237 |
+
"\N{LATIN CAPITAL LETTER R}",
|
| 1238 |
+
"it",
|
| 1239 |
+
"\N{DOUBLE-STRUCK CAPITAL R}"),
|
| 1240 |
+
("\N{LATIN CAPITAL LETTER S}",
|
| 1241 |
+
"\N{LATIN CAPITAL LETTER Y}",
|
| 1242 |
+
"it",
|
| 1243 |
+
0xe15f),
|
| 1244 |
+
("\N{LATIN CAPITAL LETTER Z}",
|
| 1245 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1246 |
+
"it",
|
| 1247 |
+
"\N{DOUBLE-STRUCK CAPITAL Z}"),
|
| 1248 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1249 |
+
"\N{LATIN SMALL LETTER C}",
|
| 1250 |
+
"it",
|
| 1251 |
+
0xe166),
|
| 1252 |
+
("\N{LATIN SMALL LETTER D}",
|
| 1253 |
+
"\N{LATIN SMALL LETTER E}",
|
| 1254 |
+
"it",
|
| 1255 |
+
"\N{DOUBLE-STRUCK ITALIC SMALL D}"),
|
| 1256 |
+
("\N{LATIN SMALL LETTER F}",
|
| 1257 |
+
"\N{LATIN SMALL LETTER H}",
|
| 1258 |
+
"it",
|
| 1259 |
+
0xe169),
|
| 1260 |
+
("\N{LATIN SMALL LETTER I}",
|
| 1261 |
+
"\N{LATIN SMALL LETTER J}",
|
| 1262 |
+
"it",
|
| 1263 |
+
"\N{DOUBLE-STRUCK ITALIC SMALL I}"),
|
| 1264 |
+
("\N{LATIN SMALL LETTER K}",
|
| 1265 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1266 |
+
"it",
|
| 1267 |
+
0xe16c),
|
| 1268 |
+
("\N{GREEK CAPITAL LETTER GAMMA}",
|
| 1269 |
+
"\N{GREEK CAPITAL LETTER GAMMA}",
|
| 1270 |
+
"it",
|
| 1271 |
+
"\N{DOUBLE-STRUCK CAPITAL GAMMA}"), # \Gamma (not in beta STIX fonts)
|
| 1272 |
+
("\N{GREEK CAPITAL LETTER PI}",
|
| 1273 |
+
"\N{GREEK CAPITAL LETTER PI}",
|
| 1274 |
+
"it",
|
| 1275 |
+
"\N{DOUBLE-STRUCK CAPITAL PI}"),
|
| 1276 |
+
("\N{GREEK CAPITAL LETTER SIGMA}",
|
| 1277 |
+
"\N{GREEK CAPITAL LETTER SIGMA}",
|
| 1278 |
+
"it",
|
| 1279 |
+
"\N{DOUBLE-STRUCK N-ARY SUMMATION}"), # \Sigma (not in beta STIX fonts)
|
| 1280 |
+
("\N{GREEK SMALL LETTER GAMMA}",
|
| 1281 |
+
"\N{GREEK SMALL LETTER GAMMA}",
|
| 1282 |
+
"it",
|
| 1283 |
+
"\N{DOUBLE-STRUCK SMALL GAMMA}"), # \gamma (not in beta STIX fonts)
|
| 1284 |
+
("\N{GREEK SMALL LETTER PI}",
|
| 1285 |
+
"\N{GREEK SMALL LETTER PI}",
|
| 1286 |
+
"it",
|
| 1287 |
+
"\N{DOUBLE-STRUCK SMALL PI}"),
|
| 1288 |
+
],
|
| 1289 |
+
"bf": [
|
| 1290 |
+
("\N{DIGIT ZERO}",
|
| 1291 |
+
"\N{DIGIT NINE}",
|
| 1292 |
+
"rm",
|
| 1293 |
+
"\N{MATHEMATICAL DOUBLE-STRUCK DIGIT ZERO}"),
|
| 1294 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1295 |
+
"\N{LATIN CAPITAL LETTER B}",
|
| 1296 |
+
"bf",
|
| 1297 |
+
0xe38a),
|
| 1298 |
+
("\N{LATIN CAPITAL LETTER C}",
|
| 1299 |
+
"\N{LATIN CAPITAL LETTER C}",
|
| 1300 |
+
"bf",
|
| 1301 |
+
"\N{DOUBLE-STRUCK CAPITAL C}"),
|
| 1302 |
+
("\N{LATIN CAPITAL LETTER D}",
|
| 1303 |
+
"\N{LATIN CAPITAL LETTER D}",
|
| 1304 |
+
"bf",
|
| 1305 |
+
"\N{DOUBLE-STRUCK ITALIC CAPITAL D}"),
|
| 1306 |
+
("\N{LATIN CAPITAL LETTER E}",
|
| 1307 |
+
"\N{LATIN CAPITAL LETTER G}",
|
| 1308 |
+
"bf",
|
| 1309 |
+
0xe38d),
|
| 1310 |
+
("\N{LATIN CAPITAL LETTER H}",
|
| 1311 |
+
"\N{LATIN CAPITAL LETTER H}",
|
| 1312 |
+
"bf",
|
| 1313 |
+
"\N{DOUBLE-STRUCK CAPITAL H}"),
|
| 1314 |
+
("\N{LATIN CAPITAL LETTER I}",
|
| 1315 |
+
"\N{LATIN CAPITAL LETTER M}",
|
| 1316 |
+
"bf",
|
| 1317 |
+
0xe390),
|
| 1318 |
+
("\N{LATIN CAPITAL LETTER N}",
|
| 1319 |
+
"\N{LATIN CAPITAL LETTER N}",
|
| 1320 |
+
"bf",
|
| 1321 |
+
"\N{DOUBLE-STRUCK CAPITAL N}"),
|
| 1322 |
+
("\N{LATIN CAPITAL LETTER O}",
|
| 1323 |
+
"\N{LATIN CAPITAL LETTER O}",
|
| 1324 |
+
"bf",
|
| 1325 |
+
0xe395),
|
| 1326 |
+
("\N{LATIN CAPITAL LETTER P}",
|
| 1327 |
+
"\N{LATIN CAPITAL LETTER Q}",
|
| 1328 |
+
"bf",
|
| 1329 |
+
"\N{DOUBLE-STRUCK CAPITAL P}"),
|
| 1330 |
+
("\N{LATIN CAPITAL LETTER R}",
|
| 1331 |
+
"\N{LATIN CAPITAL LETTER R}",
|
| 1332 |
+
"bf",
|
| 1333 |
+
"\N{DOUBLE-STRUCK CAPITAL R}"),
|
| 1334 |
+
("\N{LATIN CAPITAL LETTER S}",
|
| 1335 |
+
"\N{LATIN CAPITAL LETTER Y}",
|
| 1336 |
+
"bf",
|
| 1337 |
+
0xe396),
|
| 1338 |
+
("\N{LATIN CAPITAL LETTER Z}",
|
| 1339 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1340 |
+
"bf",
|
| 1341 |
+
"\N{DOUBLE-STRUCK CAPITAL Z}"),
|
| 1342 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1343 |
+
"\N{LATIN SMALL LETTER C}",
|
| 1344 |
+
"bf",
|
| 1345 |
+
0xe39d),
|
| 1346 |
+
("\N{LATIN SMALL LETTER D}",
|
| 1347 |
+
"\N{LATIN SMALL LETTER E}",
|
| 1348 |
+
"bf",
|
| 1349 |
+
"\N{DOUBLE-STRUCK ITALIC SMALL D}"),
|
| 1350 |
+
("\N{LATIN SMALL LETTER F}",
|
| 1351 |
+
"\N{LATIN SMALL LETTER H}",
|
| 1352 |
+
"bf",
|
| 1353 |
+
0xe3a2),
|
| 1354 |
+
("\N{LATIN SMALL LETTER I}",
|
| 1355 |
+
"\N{LATIN SMALL LETTER J}",
|
| 1356 |
+
"bf",
|
| 1357 |
+
"\N{DOUBLE-STRUCK ITALIC SMALL I}"),
|
| 1358 |
+
("\N{LATIN SMALL LETTER K}",
|
| 1359 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1360 |
+
"bf",
|
| 1361 |
+
0xe3a7),
|
| 1362 |
+
("\N{GREEK CAPITAL LETTER GAMMA}",
|
| 1363 |
+
"\N{GREEK CAPITAL LETTER GAMMA}",
|
| 1364 |
+
"bf",
|
| 1365 |
+
"\N{DOUBLE-STRUCK CAPITAL GAMMA}"),
|
| 1366 |
+
("\N{GREEK CAPITAL LETTER PI}",
|
| 1367 |
+
"\N{GREEK CAPITAL LETTER PI}",
|
| 1368 |
+
"bf",
|
| 1369 |
+
"\N{DOUBLE-STRUCK CAPITAL PI}"),
|
| 1370 |
+
("\N{GREEK CAPITAL LETTER SIGMA}",
|
| 1371 |
+
"\N{GREEK CAPITAL LETTER SIGMA}",
|
| 1372 |
+
"bf",
|
| 1373 |
+
"\N{DOUBLE-STRUCK N-ARY SUMMATION}"),
|
| 1374 |
+
("\N{GREEK SMALL LETTER GAMMA}",
|
| 1375 |
+
"\N{GREEK SMALL LETTER GAMMA}",
|
| 1376 |
+
"bf",
|
| 1377 |
+
"\N{DOUBLE-STRUCK SMALL GAMMA}"),
|
| 1378 |
+
("\N{GREEK SMALL LETTER PI}",
|
| 1379 |
+
"\N{GREEK SMALL LETTER PI}",
|
| 1380 |
+
"bf",
|
| 1381 |
+
"\N{DOUBLE-STRUCK SMALL PI}"),
|
| 1382 |
+
],
|
| 1383 |
+
},
|
| 1384 |
+
'cal': [
|
| 1385 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1386 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1387 |
+
"it",
|
| 1388 |
+
0xe22d),
|
| 1389 |
+
],
|
| 1390 |
+
'frak': {
|
| 1391 |
+
"rm": [
|
| 1392 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1393 |
+
"\N{LATIN CAPITAL LETTER B}",
|
| 1394 |
+
"rm",
|
| 1395 |
+
"\N{MATHEMATICAL FRAKTUR CAPITAL A}"),
|
| 1396 |
+
("\N{LATIN CAPITAL LETTER C}",
|
| 1397 |
+
"\N{LATIN CAPITAL LETTER C}",
|
| 1398 |
+
"rm",
|
| 1399 |
+
"\N{BLACK-LETTER CAPITAL C}"),
|
| 1400 |
+
("\N{LATIN CAPITAL LETTER D}",
|
| 1401 |
+
"\N{LATIN CAPITAL LETTER G}",
|
| 1402 |
+
"rm",
|
| 1403 |
+
"\N{MATHEMATICAL FRAKTUR CAPITAL D}"),
|
| 1404 |
+
("\N{LATIN CAPITAL LETTER H}",
|
| 1405 |
+
"\N{LATIN CAPITAL LETTER H}",
|
| 1406 |
+
"rm",
|
| 1407 |
+
"\N{BLACK-LETTER CAPITAL H}"),
|
| 1408 |
+
("\N{LATIN CAPITAL LETTER I}",
|
| 1409 |
+
"\N{LATIN CAPITAL LETTER I}",
|
| 1410 |
+
"rm",
|
| 1411 |
+
"\N{BLACK-LETTER CAPITAL I}"),
|
| 1412 |
+
("\N{LATIN CAPITAL LETTER J}",
|
| 1413 |
+
"\N{LATIN CAPITAL LETTER Q}",
|
| 1414 |
+
"rm",
|
| 1415 |
+
"\N{MATHEMATICAL FRAKTUR CAPITAL J}"),
|
| 1416 |
+
("\N{LATIN CAPITAL LETTER R}",
|
| 1417 |
+
"\N{LATIN CAPITAL LETTER R}",
|
| 1418 |
+
"rm",
|
| 1419 |
+
"\N{BLACK-LETTER CAPITAL R}"),
|
| 1420 |
+
("\N{LATIN CAPITAL LETTER S}",
|
| 1421 |
+
"\N{LATIN CAPITAL LETTER Y}",
|
| 1422 |
+
"rm",
|
| 1423 |
+
"\N{MATHEMATICAL FRAKTUR CAPITAL S}"),
|
| 1424 |
+
("\N{LATIN CAPITAL LETTER Z}",
|
| 1425 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1426 |
+
"rm",
|
| 1427 |
+
"\N{BLACK-LETTER CAPITAL Z}"),
|
| 1428 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1429 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1430 |
+
"rm",
|
| 1431 |
+
"\N{MATHEMATICAL FRAKTUR SMALL A}"),
|
| 1432 |
+
],
|
| 1433 |
+
"bf": [
|
| 1434 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1435 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1436 |
+
"bf",
|
| 1437 |
+
"\N{MATHEMATICAL BOLD FRAKTUR CAPITAL A}"),
|
| 1438 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1439 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1440 |
+
"bf",
|
| 1441 |
+
"\N{MATHEMATICAL BOLD FRAKTUR SMALL A}"),
|
| 1442 |
+
],
|
| 1443 |
+
},
|
| 1444 |
+
'scr': [
|
| 1445 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1446 |
+
"\N{LATIN CAPITAL LETTER A}",
|
| 1447 |
+
"it",
|
| 1448 |
+
"\N{MATHEMATICAL SCRIPT CAPITAL A}"),
|
| 1449 |
+
("\N{LATIN CAPITAL LETTER B}",
|
| 1450 |
+
"\N{LATIN CAPITAL LETTER B}",
|
| 1451 |
+
"it",
|
| 1452 |
+
"\N{SCRIPT CAPITAL B}"),
|
| 1453 |
+
("\N{LATIN CAPITAL LETTER C}",
|
| 1454 |
+
"\N{LATIN CAPITAL LETTER D}",
|
| 1455 |
+
"it",
|
| 1456 |
+
"\N{MATHEMATICAL SCRIPT CAPITAL C}"),
|
| 1457 |
+
("\N{LATIN CAPITAL LETTER E}",
|
| 1458 |
+
"\N{LATIN CAPITAL LETTER F}",
|
| 1459 |
+
"it",
|
| 1460 |
+
"\N{SCRIPT CAPITAL E}"),
|
| 1461 |
+
("\N{LATIN CAPITAL LETTER G}",
|
| 1462 |
+
"\N{LATIN CAPITAL LETTER G}",
|
| 1463 |
+
"it",
|
| 1464 |
+
"\N{MATHEMATICAL SCRIPT CAPITAL G}"),
|
| 1465 |
+
("\N{LATIN CAPITAL LETTER H}",
|
| 1466 |
+
"\N{LATIN CAPITAL LETTER H}",
|
| 1467 |
+
"it",
|
| 1468 |
+
"\N{SCRIPT CAPITAL H}"),
|
| 1469 |
+
("\N{LATIN CAPITAL LETTER I}",
|
| 1470 |
+
"\N{LATIN CAPITAL LETTER I}",
|
| 1471 |
+
"it",
|
| 1472 |
+
"\N{SCRIPT CAPITAL I}"),
|
| 1473 |
+
("\N{LATIN CAPITAL LETTER J}",
|
| 1474 |
+
"\N{LATIN CAPITAL LETTER K}",
|
| 1475 |
+
"it",
|
| 1476 |
+
"\N{MATHEMATICAL SCRIPT CAPITAL J}"),
|
| 1477 |
+
("\N{LATIN CAPITAL LETTER L}",
|
| 1478 |
+
"\N{LATIN CAPITAL LETTER L}",
|
| 1479 |
+
"it",
|
| 1480 |
+
"\N{SCRIPT CAPITAL L}"),
|
| 1481 |
+
("\N{LATIN CAPITAL LETTER M}",
|
| 1482 |
+
"\N{LATIN CAPITAL LETTER M}",
|
| 1483 |
+
"it",
|
| 1484 |
+
"\N{SCRIPT CAPITAL M}"),
|
| 1485 |
+
("\N{LATIN CAPITAL LETTER N}",
|
| 1486 |
+
"\N{LATIN CAPITAL LETTER Q}",
|
| 1487 |
+
"it",
|
| 1488 |
+
"\N{MATHEMATICAL SCRIPT CAPITAL N}"),
|
| 1489 |
+
("\N{LATIN CAPITAL LETTER R}",
|
| 1490 |
+
"\N{LATIN CAPITAL LETTER R}",
|
| 1491 |
+
"it",
|
| 1492 |
+
"\N{SCRIPT CAPITAL R}"),
|
| 1493 |
+
("\N{LATIN CAPITAL LETTER S}",
|
| 1494 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1495 |
+
"it",
|
| 1496 |
+
"\N{MATHEMATICAL SCRIPT CAPITAL S}"),
|
| 1497 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1498 |
+
"\N{LATIN SMALL LETTER D}",
|
| 1499 |
+
"it",
|
| 1500 |
+
"\N{MATHEMATICAL SCRIPT SMALL A}"),
|
| 1501 |
+
("\N{LATIN SMALL LETTER E}",
|
| 1502 |
+
"\N{LATIN SMALL LETTER E}",
|
| 1503 |
+
"it",
|
| 1504 |
+
"\N{SCRIPT SMALL E}"),
|
| 1505 |
+
("\N{LATIN SMALL LETTER F}",
|
| 1506 |
+
"\N{LATIN SMALL LETTER F}",
|
| 1507 |
+
"it",
|
| 1508 |
+
"\N{MATHEMATICAL SCRIPT SMALL F}"),
|
| 1509 |
+
("\N{LATIN SMALL LETTER G}",
|
| 1510 |
+
"\N{LATIN SMALL LETTER G}",
|
| 1511 |
+
"it",
|
| 1512 |
+
"\N{SCRIPT SMALL G}"),
|
| 1513 |
+
("\N{LATIN SMALL LETTER H}",
|
| 1514 |
+
"\N{LATIN SMALL LETTER N}",
|
| 1515 |
+
"it",
|
| 1516 |
+
"\N{MATHEMATICAL SCRIPT SMALL H}"),
|
| 1517 |
+
("\N{LATIN SMALL LETTER O}",
|
| 1518 |
+
"\N{LATIN SMALL LETTER O}",
|
| 1519 |
+
"it",
|
| 1520 |
+
"\N{SCRIPT SMALL O}"),
|
| 1521 |
+
("\N{LATIN SMALL LETTER P}",
|
| 1522 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1523 |
+
"it",
|
| 1524 |
+
"\N{MATHEMATICAL SCRIPT SMALL P}"),
|
| 1525 |
+
],
|
| 1526 |
+
'sf': {
|
| 1527 |
+
"rm": [
|
| 1528 |
+
("\N{DIGIT ZERO}",
|
| 1529 |
+
"\N{DIGIT NINE}",
|
| 1530 |
+
"rm",
|
| 1531 |
+
"\N{MATHEMATICAL SANS-SERIF DIGIT ZERO}"),
|
| 1532 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1533 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1534 |
+
"rm",
|
| 1535 |
+
"\N{MATHEMATICAL SANS-SERIF CAPITAL A}"),
|
| 1536 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1537 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1538 |
+
"rm",
|
| 1539 |
+
"\N{MATHEMATICAL SANS-SERIF SMALL A}"),
|
| 1540 |
+
("\N{GREEK CAPITAL LETTER ALPHA}",
|
| 1541 |
+
"\N{GREEK CAPITAL LETTER OMEGA}",
|
| 1542 |
+
"rm",
|
| 1543 |
+
0xe17d),
|
| 1544 |
+
("\N{GREEK SMALL LETTER ALPHA}",
|
| 1545 |
+
"\N{GREEK SMALL LETTER OMEGA}",
|
| 1546 |
+
"rm",
|
| 1547 |
+
0xe196),
|
| 1548 |
+
("\N{GREEK THETA SYMBOL}",
|
| 1549 |
+
"\N{GREEK THETA SYMBOL}",
|
| 1550 |
+
"rm",
|
| 1551 |
+
0xe1b0),
|
| 1552 |
+
("\N{GREEK PHI SYMBOL}",
|
| 1553 |
+
"\N{GREEK PHI SYMBOL}",
|
| 1554 |
+
"rm",
|
| 1555 |
+
0xe1b1),
|
| 1556 |
+
("\N{GREEK PI SYMBOL}",
|
| 1557 |
+
"\N{GREEK PI SYMBOL}",
|
| 1558 |
+
"rm",
|
| 1559 |
+
0xe1b3),
|
| 1560 |
+
("\N{GREEK RHO SYMBOL}",
|
| 1561 |
+
"\N{GREEK RHO SYMBOL}",
|
| 1562 |
+
"rm",
|
| 1563 |
+
0xe1b2),
|
| 1564 |
+
("\N{GREEK LUNATE EPSILON SYMBOL}",
|
| 1565 |
+
"\N{GREEK LUNATE EPSILON SYMBOL}",
|
| 1566 |
+
"rm",
|
| 1567 |
+
0xe1af),
|
| 1568 |
+
("\N{PARTIAL DIFFERENTIAL}",
|
| 1569 |
+
"\N{PARTIAL DIFFERENTIAL}",
|
| 1570 |
+
"rm",
|
| 1571 |
+
0xe17c),
|
| 1572 |
+
],
|
| 1573 |
+
"it": [
|
| 1574 |
+
# These numerals are actually upright. We don't actually
|
| 1575 |
+
# want italic numerals ever.
|
| 1576 |
+
("\N{DIGIT ZERO}",
|
| 1577 |
+
"\N{DIGIT NINE}",
|
| 1578 |
+
"rm",
|
| 1579 |
+
"\N{MATHEMATICAL SANS-SERIF DIGIT ZERO}"),
|
| 1580 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1581 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1582 |
+
"it",
|
| 1583 |
+
"\N{MATHEMATICAL SANS-SERIF ITALIC CAPITAL A}"),
|
| 1584 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1585 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1586 |
+
"it",
|
| 1587 |
+
"\N{MATHEMATICAL SANS-SERIF ITALIC SMALL A}"),
|
| 1588 |
+
("\N{GREEK CAPITAL LETTER ALPHA}",
|
| 1589 |
+
"\N{GREEK CAPITAL LETTER OMEGA}",
|
| 1590 |
+
"rm",
|
| 1591 |
+
0xe17d),
|
| 1592 |
+
("\N{GREEK SMALL LETTER ALPHA}",
|
| 1593 |
+
"\N{GREEK SMALL LETTER OMEGA}",
|
| 1594 |
+
"it",
|
| 1595 |
+
0xe1d8),
|
| 1596 |
+
("\N{GREEK THETA SYMBOL}",
|
| 1597 |
+
"\N{GREEK THETA SYMBOL}",
|
| 1598 |
+
"it",
|
| 1599 |
+
0xe1f2),
|
| 1600 |
+
("\N{GREEK PHI SYMBOL}",
|
| 1601 |
+
"\N{GREEK PHI SYMBOL}",
|
| 1602 |
+
"it",
|
| 1603 |
+
0xe1f3),
|
| 1604 |
+
("\N{GREEK PI SYMBOL}",
|
| 1605 |
+
"\N{GREEK PI SYMBOL}",
|
| 1606 |
+
"it",
|
| 1607 |
+
0xe1f5),
|
| 1608 |
+
("\N{GREEK RHO SYMBOL}",
|
| 1609 |
+
"\N{GREEK RHO SYMBOL}",
|
| 1610 |
+
"it",
|
| 1611 |
+
0xe1f4),
|
| 1612 |
+
("\N{GREEK LUNATE EPSILON SYMBOL}",
|
| 1613 |
+
"\N{GREEK LUNATE EPSILON SYMBOL}",
|
| 1614 |
+
"it",
|
| 1615 |
+
0xe1f1),
|
| 1616 |
+
],
|
| 1617 |
+
"bf": [
|
| 1618 |
+
("\N{DIGIT ZERO}",
|
| 1619 |
+
"\N{DIGIT NINE}",
|
| 1620 |
+
"bf",
|
| 1621 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD DIGIT ZERO}"),
|
| 1622 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1623 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1624 |
+
"bf",
|
| 1625 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD CAPITAL A}"),
|
| 1626 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1627 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1628 |
+
"bf",
|
| 1629 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD SMALL A}"),
|
| 1630 |
+
("\N{GREEK CAPITAL LETTER ALPHA}",
|
| 1631 |
+
"\N{GREEK CAPITAL LETTER OMEGA}",
|
| 1632 |
+
"bf",
|
| 1633 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD CAPITAL ALPHA}"),
|
| 1634 |
+
("\N{GREEK SMALL LETTER ALPHA}",
|
| 1635 |
+
"\N{GREEK SMALL LETTER OMEGA}",
|
| 1636 |
+
"bf",
|
| 1637 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD SMALL ALPHA}"),
|
| 1638 |
+
("\N{GREEK THETA SYMBOL}",
|
| 1639 |
+
"\N{GREEK THETA SYMBOL}",
|
| 1640 |
+
"bf",
|
| 1641 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD THETA SYMBOL}"),
|
| 1642 |
+
("\N{GREEK PHI SYMBOL}",
|
| 1643 |
+
"\N{GREEK PHI SYMBOL}",
|
| 1644 |
+
"bf",
|
| 1645 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD PHI SYMBOL}"),
|
| 1646 |
+
("\N{GREEK PI SYMBOL}",
|
| 1647 |
+
"\N{GREEK PI SYMBOL}",
|
| 1648 |
+
"bf",
|
| 1649 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD PI SYMBOL}"),
|
| 1650 |
+
("\N{GREEK KAPPA SYMBOL}",
|
| 1651 |
+
"\N{GREEK KAPPA SYMBOL}",
|
| 1652 |
+
"bf",
|
| 1653 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD KAPPA SYMBOL}"),
|
| 1654 |
+
("\N{GREEK RHO SYMBOL}",
|
| 1655 |
+
"\N{GREEK RHO SYMBOL}",
|
| 1656 |
+
"bf",
|
| 1657 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD RHO SYMBOL}"),
|
| 1658 |
+
("\N{GREEK LUNATE EPSILON SYMBOL}",
|
| 1659 |
+
"\N{GREEK LUNATE EPSILON SYMBOL}",
|
| 1660 |
+
"bf",
|
| 1661 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD EPSILON SYMBOL}"),
|
| 1662 |
+
("\N{PARTIAL DIFFERENTIAL}",
|
| 1663 |
+
"\N{PARTIAL DIFFERENTIAL}",
|
| 1664 |
+
"bf",
|
| 1665 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD PARTIAL DIFFERENTIAL}"),
|
| 1666 |
+
("\N{NABLA}",
|
| 1667 |
+
"\N{NABLA}",
|
| 1668 |
+
"bf",
|
| 1669 |
+
"\N{MATHEMATICAL SANS-SERIF BOLD NABLA}"),
|
| 1670 |
+
],
|
| 1671 |
+
"bfit": [
|
| 1672 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1673 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1674 |
+
"bfit",
|
| 1675 |
+
"\N{MATHEMATICAL BOLD ITALIC CAPITAL A}"),
|
| 1676 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1677 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1678 |
+
"bfit",
|
| 1679 |
+
"\N{MATHEMATICAL BOLD ITALIC SMALL A}"),
|
| 1680 |
+
("\N{GREEK CAPITAL LETTER GAMMA}",
|
| 1681 |
+
"\N{GREEK CAPITAL LETTER OMEGA}",
|
| 1682 |
+
"bfit",
|
| 1683 |
+
"\N{MATHEMATICAL BOLD ITALIC CAPITAL GAMMA}"),
|
| 1684 |
+
("\N{GREEK SMALL LETTER ALPHA}",
|
| 1685 |
+
"\N{GREEK SMALL LETTER OMEGA}",
|
| 1686 |
+
"bfit",
|
| 1687 |
+
"\N{MATHEMATICAL BOLD ITALIC SMALL ALPHA}"),
|
| 1688 |
+
],
|
| 1689 |
+
},
|
| 1690 |
+
'tt': [
|
| 1691 |
+
("\N{DIGIT ZERO}",
|
| 1692 |
+
"\N{DIGIT NINE}",
|
| 1693 |
+
"rm",
|
| 1694 |
+
"\N{MATHEMATICAL MONOSPACE DIGIT ZERO}"),
|
| 1695 |
+
("\N{LATIN CAPITAL LETTER A}",
|
| 1696 |
+
"\N{LATIN CAPITAL LETTER Z}",
|
| 1697 |
+
"rm",
|
| 1698 |
+
"\N{MATHEMATICAL MONOSPACE CAPITAL A}"),
|
| 1699 |
+
("\N{LATIN SMALL LETTER A}",
|
| 1700 |
+
"\N{LATIN SMALL LETTER Z}",
|
| 1701 |
+
"rm",
|
| 1702 |
+
"\N{MATHEMATICAL MONOSPACE SMALL A}")
|
| 1703 |
+
],
|
| 1704 |
+
}
|
| 1705 |
+
|
| 1706 |
+
|
| 1707 |
+
@overload
|
| 1708 |
+
def _normalize_stix_fontcodes(d: _EntryTypeIn) -> _EntryTypeOut: ...
|
| 1709 |
+
|
| 1710 |
+
|
| 1711 |
+
@overload
|
| 1712 |
+
def _normalize_stix_fontcodes(d: list[_EntryTypeIn]) -> list[_EntryTypeOut]: ...
|
| 1713 |
+
|
| 1714 |
+
|
| 1715 |
+
@overload
|
| 1716 |
+
def _normalize_stix_fontcodes(d: dict[str, list[_EntryTypeIn] |
|
| 1717 |
+
dict[str, list[_EntryTypeIn]]]
|
| 1718 |
+
) -> dict[str, list[_EntryTypeOut] |
|
| 1719 |
+
dict[str, list[_EntryTypeOut]]]: ...
|
| 1720 |
+
|
| 1721 |
+
|
| 1722 |
+
def _normalize_stix_fontcodes(d):
|
| 1723 |
+
if isinstance(d, tuple):
|
| 1724 |
+
return tuple(ord(x) if isinstance(x, str) and len(x) == 1 else x for x in d)
|
| 1725 |
+
elif isinstance(d, list):
|
| 1726 |
+
return [_normalize_stix_fontcodes(x) for x in d]
|
| 1727 |
+
elif isinstance(d, dict):
|
| 1728 |
+
return {k: _normalize_stix_fontcodes(v) for k, v in d.items()}
|
| 1729 |
+
|
| 1730 |
+
|
| 1731 |
+
stix_virtual_fonts: dict[str, dict[str, list[_EntryTypeOut]] | list[_EntryTypeOut]]
|
| 1732 |
+
stix_virtual_fonts = _normalize_stix_fontcodes(_stix_virtual_fonts)
|
| 1733 |
+
|
| 1734 |
+
# Free redundant list now that it has been normalized
|
| 1735 |
+
del _stix_virtual_fonts
|
| 1736 |
+
|
| 1737 |
+
# Fix some incorrect glyphs.
|
| 1738 |
+
stix_glyph_fixes = {
|
| 1739 |
+
# Cap and Cup glyphs are swapped.
|
| 1740 |
+
0x22d2: 0x22d3,
|
| 1741 |
+
0x22d3: 0x22d2,
|
| 1742 |
+
}
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_path.pyi
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Sequence
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
from .transforms import BboxBase
|
| 6 |
+
|
| 7 |
+
def affine_transform(points: np.ndarray, trans: np.ndarray) -> np.ndarray: ...
|
| 8 |
+
def count_bboxes_overlapping_bbox(bbox: BboxBase, bboxes: Sequence[BboxBase]) -> int: ...
|
| 9 |
+
def update_path_extents(path, trans, rect, minpos, ignore): ...
|
infer_4_30_0/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: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_qhull.pyi
ADDED
|
File without changes
|
infer_4_30_0/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
|
infer_4_30_0/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: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/_version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
version = "3.10.1"
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/artist.py
ADDED
|
@@ -0,0 +1,1855 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections import namedtuple
|
| 2 |
+
import contextlib
|
| 3 |
+
from functools import cache, reduce, wraps
|
| 4 |
+
import inspect
|
| 5 |
+
from inspect import Signature, Parameter
|
| 6 |
+
import logging
|
| 7 |
+
from numbers import Number, Real
|
| 8 |
+
import operator
|
| 9 |
+
import re
|
| 10 |
+
import warnings
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
|
| 14 |
+
import matplotlib as mpl
|
| 15 |
+
from . import _api, cbook
|
| 16 |
+
from .path import Path
|
| 17 |
+
from .transforms import (BboxBase, Bbox, IdentityTransform, Transform, TransformedBbox,
|
| 18 |
+
TransformedPatchPath, TransformedPath)
|
| 19 |
+
|
| 20 |
+
_log = logging.getLogger(__name__)
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _prevent_rasterization(draw):
|
| 24 |
+
# We assume that by default artists are not allowed to rasterize (unless
|
| 25 |
+
# its draw method is explicitly decorated). If it is being drawn after a
|
| 26 |
+
# rasterized artist and it has reached a raster_depth of 0, we stop
|
| 27 |
+
# rasterization so that it does not affect the behavior of normal artist
|
| 28 |
+
# (e.g., change in dpi).
|
| 29 |
+
|
| 30 |
+
@wraps(draw)
|
| 31 |
+
def draw_wrapper(artist, renderer, *args, **kwargs):
|
| 32 |
+
if renderer._raster_depth == 0 and renderer._rasterizing:
|
| 33 |
+
# Only stop when we are not in a rasterized parent
|
| 34 |
+
# and something has been rasterized since last stop.
|
| 35 |
+
renderer.stop_rasterizing()
|
| 36 |
+
renderer._rasterizing = False
|
| 37 |
+
|
| 38 |
+
return draw(artist, renderer, *args, **kwargs)
|
| 39 |
+
|
| 40 |
+
draw_wrapper._supports_rasterization = False
|
| 41 |
+
return draw_wrapper
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def allow_rasterization(draw):
|
| 45 |
+
"""
|
| 46 |
+
Decorator for Artist.draw method. Provides routines
|
| 47 |
+
that run before and after the draw call. The before and after functions
|
| 48 |
+
are useful for changing artist-dependent renderer attributes or making
|
| 49 |
+
other setup function calls, such as starting and flushing a mixed-mode
|
| 50 |
+
renderer.
|
| 51 |
+
"""
|
| 52 |
+
|
| 53 |
+
@wraps(draw)
|
| 54 |
+
def draw_wrapper(artist, renderer):
|
| 55 |
+
try:
|
| 56 |
+
if artist.get_rasterized():
|
| 57 |
+
if renderer._raster_depth == 0 and not renderer._rasterizing:
|
| 58 |
+
renderer.start_rasterizing()
|
| 59 |
+
renderer._rasterizing = True
|
| 60 |
+
renderer._raster_depth += 1
|
| 61 |
+
else:
|
| 62 |
+
if renderer._raster_depth == 0 and renderer._rasterizing:
|
| 63 |
+
# Only stop when we are not in a rasterized parent
|
| 64 |
+
# and something has be rasterized since last stop
|
| 65 |
+
renderer.stop_rasterizing()
|
| 66 |
+
renderer._rasterizing = False
|
| 67 |
+
|
| 68 |
+
if artist.get_agg_filter() is not None:
|
| 69 |
+
renderer.start_filter()
|
| 70 |
+
|
| 71 |
+
return draw(artist, renderer)
|
| 72 |
+
finally:
|
| 73 |
+
if artist.get_agg_filter() is not None:
|
| 74 |
+
renderer.stop_filter(artist.get_agg_filter())
|
| 75 |
+
if artist.get_rasterized():
|
| 76 |
+
renderer._raster_depth -= 1
|
| 77 |
+
if (renderer._rasterizing and (fig := artist.get_figure(root=True)) and
|
| 78 |
+
fig.suppressComposite):
|
| 79 |
+
# restart rasterizing to prevent merging
|
| 80 |
+
renderer.stop_rasterizing()
|
| 81 |
+
renderer.start_rasterizing()
|
| 82 |
+
|
| 83 |
+
draw_wrapper._supports_rasterization = True
|
| 84 |
+
return draw_wrapper
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def _finalize_rasterization(draw):
|
| 88 |
+
"""
|
| 89 |
+
Decorator for Artist.draw method. Needed on the outermost artist, i.e.
|
| 90 |
+
Figure, to finish up if the render is still in rasterized mode.
|
| 91 |
+
"""
|
| 92 |
+
@wraps(draw)
|
| 93 |
+
def draw_wrapper(artist, renderer, *args, **kwargs):
|
| 94 |
+
result = draw(artist, renderer, *args, **kwargs)
|
| 95 |
+
if renderer._rasterizing:
|
| 96 |
+
renderer.stop_rasterizing()
|
| 97 |
+
renderer._rasterizing = False
|
| 98 |
+
return result
|
| 99 |
+
return draw_wrapper
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def _stale_axes_callback(self, val):
|
| 103 |
+
if self.axes:
|
| 104 |
+
self.axes.stale = val
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
_XYPair = namedtuple("_XYPair", "x y")
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
class _Unset:
|
| 111 |
+
def __repr__(self):
|
| 112 |
+
return "<UNSET>"
|
| 113 |
+
_UNSET = _Unset()
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
class Artist:
|
| 117 |
+
"""
|
| 118 |
+
Abstract base class for objects that render into a FigureCanvas.
|
| 119 |
+
|
| 120 |
+
Typically, all visible elements in a figure are subclasses of Artist.
|
| 121 |
+
"""
|
| 122 |
+
|
| 123 |
+
zorder = 0
|
| 124 |
+
|
| 125 |
+
def __init_subclass__(cls):
|
| 126 |
+
|
| 127 |
+
# Decorate draw() method so that all artists are able to stop
|
| 128 |
+
# rastrization when necessary. If the artist's draw method is already
|
| 129 |
+
# decorated (has a `_supports_rasterization` attribute), it won't be
|
| 130 |
+
# decorated.
|
| 131 |
+
|
| 132 |
+
if not hasattr(cls.draw, "_supports_rasterization"):
|
| 133 |
+
cls.draw = _prevent_rasterization(cls.draw)
|
| 134 |
+
|
| 135 |
+
# Inject custom set() methods into the subclass with signature and
|
| 136 |
+
# docstring based on the subclasses' properties.
|
| 137 |
+
|
| 138 |
+
if not hasattr(cls.set, '_autogenerated_signature'):
|
| 139 |
+
# Don't overwrite cls.set if the subclass or one of its parents
|
| 140 |
+
# has defined a set method set itself.
|
| 141 |
+
# If there was no explicit definition, cls.set is inherited from
|
| 142 |
+
# the hierarchy of auto-generated set methods, which hold the
|
| 143 |
+
# flag _autogenerated_signature.
|
| 144 |
+
return
|
| 145 |
+
|
| 146 |
+
cls.set = lambda self, **kwargs: Artist.set(self, **kwargs)
|
| 147 |
+
cls.set.__name__ = "set"
|
| 148 |
+
cls.set.__qualname__ = f"{cls.__qualname__}.set"
|
| 149 |
+
cls._update_set_signature_and_docstring()
|
| 150 |
+
|
| 151 |
+
_PROPERTIES_EXCLUDED_FROM_SET = [
|
| 152 |
+
'navigate_mode', # not a user-facing function
|
| 153 |
+
'figure', # changing the figure is such a profound operation
|
| 154 |
+
# that we don't want this in set()
|
| 155 |
+
'3d_properties', # cannot be used as a keyword due to leading digit
|
| 156 |
+
]
|
| 157 |
+
|
| 158 |
+
@classmethod
|
| 159 |
+
def _update_set_signature_and_docstring(cls):
|
| 160 |
+
"""
|
| 161 |
+
Update the signature of the set function to list all properties
|
| 162 |
+
as keyword arguments.
|
| 163 |
+
|
| 164 |
+
Property aliases are not listed in the signature for brevity, but
|
| 165 |
+
are still accepted as keyword arguments.
|
| 166 |
+
"""
|
| 167 |
+
cls.set.__signature__ = Signature(
|
| 168 |
+
[Parameter("self", Parameter.POSITIONAL_OR_KEYWORD),
|
| 169 |
+
*[Parameter(prop, Parameter.KEYWORD_ONLY, default=_UNSET)
|
| 170 |
+
for prop in ArtistInspector(cls).get_setters()
|
| 171 |
+
if prop not in Artist._PROPERTIES_EXCLUDED_FROM_SET]])
|
| 172 |
+
cls.set._autogenerated_signature = True
|
| 173 |
+
|
| 174 |
+
cls.set.__doc__ = (
|
| 175 |
+
"Set multiple properties at once.\n\n"
|
| 176 |
+
"Supported properties are\n\n"
|
| 177 |
+
+ kwdoc(cls))
|
| 178 |
+
|
| 179 |
+
def __init__(self):
|
| 180 |
+
self._stale = True
|
| 181 |
+
self.stale_callback = None
|
| 182 |
+
self._axes = None
|
| 183 |
+
self._parent_figure = None
|
| 184 |
+
|
| 185 |
+
self._transform = None
|
| 186 |
+
self._transformSet = False
|
| 187 |
+
self._visible = True
|
| 188 |
+
self._animated = False
|
| 189 |
+
self._alpha = None
|
| 190 |
+
self.clipbox = None
|
| 191 |
+
self._clippath = None
|
| 192 |
+
self._clipon = True
|
| 193 |
+
self._label = ''
|
| 194 |
+
self._picker = None
|
| 195 |
+
self._rasterized = False
|
| 196 |
+
self._agg_filter = None
|
| 197 |
+
# Normally, artist classes need to be queried for mouseover info if and
|
| 198 |
+
# only if they override get_cursor_data.
|
| 199 |
+
self._mouseover = type(self).get_cursor_data != Artist.get_cursor_data
|
| 200 |
+
self._callbacks = cbook.CallbackRegistry(signals=["pchanged"])
|
| 201 |
+
try:
|
| 202 |
+
self.axes = None
|
| 203 |
+
except AttributeError:
|
| 204 |
+
# Handle self.axes as a read-only property, as in Figure.
|
| 205 |
+
pass
|
| 206 |
+
self._remove_method = None
|
| 207 |
+
self._url = None
|
| 208 |
+
self._gid = None
|
| 209 |
+
self._snap = None
|
| 210 |
+
self._sketch = mpl.rcParams['path.sketch']
|
| 211 |
+
self._path_effects = mpl.rcParams['path.effects']
|
| 212 |
+
self._sticky_edges = _XYPair([], [])
|
| 213 |
+
self._in_layout = True
|
| 214 |
+
|
| 215 |
+
def __getstate__(self):
|
| 216 |
+
d = self.__dict__.copy()
|
| 217 |
+
d['stale_callback'] = None
|
| 218 |
+
return d
|
| 219 |
+
|
| 220 |
+
def remove(self):
|
| 221 |
+
"""
|
| 222 |
+
Remove the artist from the figure if possible.
|
| 223 |
+
|
| 224 |
+
The effect will not be visible until the figure is redrawn, e.g.,
|
| 225 |
+
with `.FigureCanvasBase.draw_idle`. Call `~.axes.Axes.relim` to
|
| 226 |
+
update the Axes limits if desired.
|
| 227 |
+
|
| 228 |
+
Note: `~.axes.Axes.relim` will not see collections even if the
|
| 229 |
+
collection was added to the Axes with *autolim* = True.
|
| 230 |
+
|
| 231 |
+
Note: there is no support for removing the artist's legend entry.
|
| 232 |
+
"""
|
| 233 |
+
|
| 234 |
+
# There is no method to set the callback. Instead, the parent should
|
| 235 |
+
# set the _remove_method attribute directly. This would be a
|
| 236 |
+
# protected attribute if Python supported that sort of thing. The
|
| 237 |
+
# callback has one parameter, which is the child to be removed.
|
| 238 |
+
if self._remove_method is not None:
|
| 239 |
+
self._remove_method(self)
|
| 240 |
+
# clear stale callback
|
| 241 |
+
self.stale_callback = None
|
| 242 |
+
_ax_flag = False
|
| 243 |
+
if hasattr(self, 'axes') and self.axes:
|
| 244 |
+
# remove from the mouse hit list
|
| 245 |
+
self.axes._mouseover_set.discard(self)
|
| 246 |
+
self.axes.stale = True
|
| 247 |
+
self.axes = None # decouple the artist from the Axes
|
| 248 |
+
_ax_flag = True
|
| 249 |
+
|
| 250 |
+
if (fig := self.get_figure(root=False)) is not None:
|
| 251 |
+
if not _ax_flag:
|
| 252 |
+
fig.stale = True
|
| 253 |
+
self._parent_figure = None
|
| 254 |
+
|
| 255 |
+
else:
|
| 256 |
+
raise NotImplementedError('cannot remove artist')
|
| 257 |
+
# TODO: the fix for the collections relim problem is to move the
|
| 258 |
+
# limits calculation into the artist itself, including the property of
|
| 259 |
+
# whether or not the artist should affect the limits. Then there will
|
| 260 |
+
# be no distinction between axes.add_line, axes.add_patch, etc.
|
| 261 |
+
# TODO: add legend support
|
| 262 |
+
|
| 263 |
+
def have_units(self):
|
| 264 |
+
"""Return whether units are set on any axis."""
|
| 265 |
+
ax = self.axes
|
| 266 |
+
return ax and any(axis.have_units() for axis in ax._axis_map.values())
|
| 267 |
+
|
| 268 |
+
def convert_xunits(self, x):
|
| 269 |
+
"""
|
| 270 |
+
Convert *x* using the unit type of the xaxis.
|
| 271 |
+
|
| 272 |
+
If the artist is not contained in an Axes or if the xaxis does not
|
| 273 |
+
have units, *x* itself is returned.
|
| 274 |
+
"""
|
| 275 |
+
ax = getattr(self, 'axes', None)
|
| 276 |
+
if ax is None or ax.xaxis is None:
|
| 277 |
+
return x
|
| 278 |
+
return ax.xaxis.convert_units(x)
|
| 279 |
+
|
| 280 |
+
def convert_yunits(self, y):
|
| 281 |
+
"""
|
| 282 |
+
Convert *y* using the unit type of the yaxis.
|
| 283 |
+
|
| 284 |
+
If the artist is not contained in an Axes or if the yaxis does not
|
| 285 |
+
have units, *y* itself is returned.
|
| 286 |
+
"""
|
| 287 |
+
ax = getattr(self, 'axes', None)
|
| 288 |
+
if ax is None or ax.yaxis is None:
|
| 289 |
+
return y
|
| 290 |
+
return ax.yaxis.convert_units(y)
|
| 291 |
+
|
| 292 |
+
@property
|
| 293 |
+
def axes(self):
|
| 294 |
+
"""The `~.axes.Axes` instance the artist resides in, or *None*."""
|
| 295 |
+
return self._axes
|
| 296 |
+
|
| 297 |
+
@axes.setter
|
| 298 |
+
def axes(self, new_axes):
|
| 299 |
+
if (new_axes is not None and self._axes is not None
|
| 300 |
+
and new_axes != self._axes):
|
| 301 |
+
raise ValueError("Can not reset the Axes. You are probably trying to reuse "
|
| 302 |
+
"an artist in more than one Axes which is not supported")
|
| 303 |
+
self._axes = new_axes
|
| 304 |
+
if new_axes is not None and new_axes is not self:
|
| 305 |
+
self.stale_callback = _stale_axes_callback
|
| 306 |
+
|
| 307 |
+
@property
|
| 308 |
+
def stale(self):
|
| 309 |
+
"""
|
| 310 |
+
Whether the artist is 'stale' and needs to be re-drawn for the output
|
| 311 |
+
to match the internal state of the artist.
|
| 312 |
+
"""
|
| 313 |
+
return self._stale
|
| 314 |
+
|
| 315 |
+
@stale.setter
|
| 316 |
+
def stale(self, val):
|
| 317 |
+
self._stale = val
|
| 318 |
+
|
| 319 |
+
# if the artist is animated it does not take normal part in the
|
| 320 |
+
# draw stack and is not expected to be drawn as part of the normal
|
| 321 |
+
# draw loop (when not saving) so do not propagate this change
|
| 322 |
+
if self._animated:
|
| 323 |
+
return
|
| 324 |
+
|
| 325 |
+
if val and self.stale_callback is not None:
|
| 326 |
+
self.stale_callback(self, val)
|
| 327 |
+
|
| 328 |
+
def get_window_extent(self, renderer=None):
|
| 329 |
+
"""
|
| 330 |
+
Get the artist's bounding box in display space.
|
| 331 |
+
|
| 332 |
+
The bounding box' width and height are nonnegative.
|
| 333 |
+
|
| 334 |
+
Subclasses should override for inclusion in the bounding box
|
| 335 |
+
"tight" calculation. Default is to return an empty bounding
|
| 336 |
+
box at 0, 0.
|
| 337 |
+
|
| 338 |
+
Be careful when using this function, the results will not update
|
| 339 |
+
if the artist window extent of the artist changes. The extent
|
| 340 |
+
can change due to any changes in the transform stack, such as
|
| 341 |
+
changing the Axes limits, the figure size, or the canvas used
|
| 342 |
+
(as is done when saving a figure). This can lead to unexpected
|
| 343 |
+
behavior where interactive figures will look fine on the screen,
|
| 344 |
+
but will save incorrectly.
|
| 345 |
+
"""
|
| 346 |
+
return Bbox([[0, 0], [0, 0]])
|
| 347 |
+
|
| 348 |
+
def get_tightbbox(self, renderer=None):
|
| 349 |
+
"""
|
| 350 |
+
Like `.Artist.get_window_extent`, but includes any clipping.
|
| 351 |
+
|
| 352 |
+
Parameters
|
| 353 |
+
----------
|
| 354 |
+
renderer : `~matplotlib.backend_bases.RendererBase` subclass, optional
|
| 355 |
+
renderer that will be used to draw the figures (i.e.
|
| 356 |
+
``fig.canvas.get_renderer()``)
|
| 357 |
+
|
| 358 |
+
Returns
|
| 359 |
+
-------
|
| 360 |
+
`.Bbox` or None
|
| 361 |
+
The enclosing bounding box (in figure pixel coordinates).
|
| 362 |
+
Returns None if clipping results in no intersection.
|
| 363 |
+
"""
|
| 364 |
+
bbox = self.get_window_extent(renderer)
|
| 365 |
+
if self.get_clip_on():
|
| 366 |
+
clip_box = self.get_clip_box()
|
| 367 |
+
if clip_box is not None:
|
| 368 |
+
bbox = Bbox.intersection(bbox, clip_box)
|
| 369 |
+
clip_path = self.get_clip_path()
|
| 370 |
+
if clip_path is not None and bbox is not None:
|
| 371 |
+
clip_path = clip_path.get_fully_transformed_path()
|
| 372 |
+
bbox = Bbox.intersection(bbox, clip_path.get_extents())
|
| 373 |
+
return bbox
|
| 374 |
+
|
| 375 |
+
def add_callback(self, func):
|
| 376 |
+
"""
|
| 377 |
+
Add a callback function that will be called whenever one of the
|
| 378 |
+
`.Artist`'s properties changes.
|
| 379 |
+
|
| 380 |
+
Parameters
|
| 381 |
+
----------
|
| 382 |
+
func : callable
|
| 383 |
+
The callback function. It must have the signature::
|
| 384 |
+
|
| 385 |
+
def func(artist: Artist) -> Any
|
| 386 |
+
|
| 387 |
+
where *artist* is the calling `.Artist`. Return values may exist
|
| 388 |
+
but are ignored.
|
| 389 |
+
|
| 390 |
+
Returns
|
| 391 |
+
-------
|
| 392 |
+
int
|
| 393 |
+
The observer id associated with the callback. This id can be
|
| 394 |
+
used for removing the callback with `.remove_callback` later.
|
| 395 |
+
|
| 396 |
+
See Also
|
| 397 |
+
--------
|
| 398 |
+
remove_callback
|
| 399 |
+
"""
|
| 400 |
+
# Wrapping func in a lambda ensures it can be connected multiple times
|
| 401 |
+
# and never gets weakref-gc'ed.
|
| 402 |
+
return self._callbacks.connect("pchanged", lambda: func(self))
|
| 403 |
+
|
| 404 |
+
def remove_callback(self, oid):
|
| 405 |
+
"""
|
| 406 |
+
Remove a callback based on its observer id.
|
| 407 |
+
|
| 408 |
+
See Also
|
| 409 |
+
--------
|
| 410 |
+
add_callback
|
| 411 |
+
"""
|
| 412 |
+
self._callbacks.disconnect(oid)
|
| 413 |
+
|
| 414 |
+
def pchanged(self):
|
| 415 |
+
"""
|
| 416 |
+
Call all of the registered callbacks.
|
| 417 |
+
|
| 418 |
+
This function is triggered internally when a property is changed.
|
| 419 |
+
|
| 420 |
+
See Also
|
| 421 |
+
--------
|
| 422 |
+
add_callback
|
| 423 |
+
remove_callback
|
| 424 |
+
"""
|
| 425 |
+
self._callbacks.process("pchanged")
|
| 426 |
+
|
| 427 |
+
def is_transform_set(self):
|
| 428 |
+
"""
|
| 429 |
+
Return whether the Artist has an explicitly set transform.
|
| 430 |
+
|
| 431 |
+
This is *True* after `.set_transform` has been called.
|
| 432 |
+
"""
|
| 433 |
+
return self._transformSet
|
| 434 |
+
|
| 435 |
+
def set_transform(self, t):
|
| 436 |
+
"""
|
| 437 |
+
Set the artist transform.
|
| 438 |
+
|
| 439 |
+
Parameters
|
| 440 |
+
----------
|
| 441 |
+
t : `~matplotlib.transforms.Transform`
|
| 442 |
+
"""
|
| 443 |
+
self._transform = t
|
| 444 |
+
self._transformSet = True
|
| 445 |
+
self.pchanged()
|
| 446 |
+
self.stale = True
|
| 447 |
+
|
| 448 |
+
def get_transform(self):
|
| 449 |
+
"""Return the `.Transform` instance used by this artist."""
|
| 450 |
+
if self._transform is None:
|
| 451 |
+
self._transform = IdentityTransform()
|
| 452 |
+
elif (not isinstance(self._transform, Transform)
|
| 453 |
+
and hasattr(self._transform, '_as_mpl_transform')):
|
| 454 |
+
self._transform = self._transform._as_mpl_transform(self.axes)
|
| 455 |
+
return self._transform
|
| 456 |
+
|
| 457 |
+
def get_children(self):
|
| 458 |
+
r"""Return a list of the child `.Artist`\s of this `.Artist`."""
|
| 459 |
+
return []
|
| 460 |
+
|
| 461 |
+
def _different_canvas(self, event):
|
| 462 |
+
"""
|
| 463 |
+
Check whether an *event* occurred on a canvas other that this artist's canvas.
|
| 464 |
+
|
| 465 |
+
If this method returns True, the event definitely occurred on a different
|
| 466 |
+
canvas; if it returns False, either it occurred on the same canvas, or we may
|
| 467 |
+
not have enough information to know.
|
| 468 |
+
|
| 469 |
+
Subclasses should start their definition of `contains` as follows::
|
| 470 |
+
|
| 471 |
+
if self._different_canvas(mouseevent):
|
| 472 |
+
return False, {}
|
| 473 |
+
# subclass-specific implementation follows
|
| 474 |
+
"""
|
| 475 |
+
return (getattr(event, "canvas", None) is not None
|
| 476 |
+
and (fig := self.get_figure(root=True)) is not None
|
| 477 |
+
and event.canvas is not fig.canvas)
|
| 478 |
+
|
| 479 |
+
def contains(self, mouseevent):
|
| 480 |
+
"""
|
| 481 |
+
Test whether the artist contains the mouse event.
|
| 482 |
+
|
| 483 |
+
Parameters
|
| 484 |
+
----------
|
| 485 |
+
mouseevent : `~matplotlib.backend_bases.MouseEvent`
|
| 486 |
+
|
| 487 |
+
Returns
|
| 488 |
+
-------
|
| 489 |
+
contains : bool
|
| 490 |
+
Whether any values are within the radius.
|
| 491 |
+
details : dict
|
| 492 |
+
An artist-specific dictionary of details of the event context,
|
| 493 |
+
such as which points are contained in the pick radius. See the
|
| 494 |
+
individual Artist subclasses for details.
|
| 495 |
+
"""
|
| 496 |
+
_log.warning("%r needs 'contains' method", self.__class__.__name__)
|
| 497 |
+
return False, {}
|
| 498 |
+
|
| 499 |
+
def pickable(self):
|
| 500 |
+
"""
|
| 501 |
+
Return whether the artist is pickable.
|
| 502 |
+
|
| 503 |
+
See Also
|
| 504 |
+
--------
|
| 505 |
+
.Artist.set_picker, .Artist.get_picker, .Artist.pick
|
| 506 |
+
"""
|
| 507 |
+
return self.get_figure(root=False) is not None and self._picker is not None
|
| 508 |
+
|
| 509 |
+
def pick(self, mouseevent):
|
| 510 |
+
"""
|
| 511 |
+
Process a pick event.
|
| 512 |
+
|
| 513 |
+
Each child artist will fire a pick event if *mouseevent* is over
|
| 514 |
+
the artist and the artist has picker set.
|
| 515 |
+
|
| 516 |
+
See Also
|
| 517 |
+
--------
|
| 518 |
+
.Artist.set_picker, .Artist.get_picker, .Artist.pickable
|
| 519 |
+
"""
|
| 520 |
+
from .backend_bases import PickEvent # Circular import.
|
| 521 |
+
# Pick self
|
| 522 |
+
if self.pickable():
|
| 523 |
+
picker = self.get_picker()
|
| 524 |
+
if callable(picker):
|
| 525 |
+
inside, prop = picker(self, mouseevent)
|
| 526 |
+
else:
|
| 527 |
+
inside, prop = self.contains(mouseevent)
|
| 528 |
+
if inside:
|
| 529 |
+
PickEvent("pick_event", self.get_figure(root=True).canvas,
|
| 530 |
+
mouseevent, self, **prop)._process()
|
| 531 |
+
|
| 532 |
+
# Pick children
|
| 533 |
+
for a in self.get_children():
|
| 534 |
+
# make sure the event happened in the same Axes
|
| 535 |
+
ax = getattr(a, 'axes', None)
|
| 536 |
+
if (isinstance(a, mpl.figure.SubFigure)
|
| 537 |
+
or mouseevent.inaxes is None or ax is None
|
| 538 |
+
or mouseevent.inaxes == ax):
|
| 539 |
+
# we need to check if mouseevent.inaxes is None
|
| 540 |
+
# because some objects associated with an Axes (e.g., a
|
| 541 |
+
# tick label) can be outside the bounding box of the
|
| 542 |
+
# Axes and inaxes will be None
|
| 543 |
+
# also check that ax is None so that it traverse objects
|
| 544 |
+
# which do not have an axes property but children might
|
| 545 |
+
a.pick(mouseevent)
|
| 546 |
+
|
| 547 |
+
def set_picker(self, picker):
|
| 548 |
+
"""
|
| 549 |
+
Define the picking behavior of the artist.
|
| 550 |
+
|
| 551 |
+
Parameters
|
| 552 |
+
----------
|
| 553 |
+
picker : None or bool or float or callable
|
| 554 |
+
This can be one of the following:
|
| 555 |
+
|
| 556 |
+
- *None*: Picking is disabled for this artist (default).
|
| 557 |
+
|
| 558 |
+
- A boolean: If *True* then picking will be enabled and the
|
| 559 |
+
artist will fire a pick event if the mouse event is over
|
| 560 |
+
the artist.
|
| 561 |
+
|
| 562 |
+
- A float: If picker is a number it is interpreted as an
|
| 563 |
+
epsilon tolerance in points and the artist will fire
|
| 564 |
+
off an event if its data is within epsilon of the mouse
|
| 565 |
+
event. For some artists like lines and patch collections,
|
| 566 |
+
the artist may provide additional data to the pick event
|
| 567 |
+
that is generated, e.g., the indices of the data within
|
| 568 |
+
epsilon of the pick event
|
| 569 |
+
|
| 570 |
+
- A function: If picker is callable, it is a user supplied
|
| 571 |
+
function which determines whether the artist is hit by the
|
| 572 |
+
mouse event::
|
| 573 |
+
|
| 574 |
+
hit, props = picker(artist, mouseevent)
|
| 575 |
+
|
| 576 |
+
to determine the hit test. if the mouse event is over the
|
| 577 |
+
artist, return *hit=True* and props is a dictionary of
|
| 578 |
+
properties you want added to the PickEvent attributes.
|
| 579 |
+
"""
|
| 580 |
+
self._picker = picker
|
| 581 |
+
|
| 582 |
+
def get_picker(self):
|
| 583 |
+
"""
|
| 584 |
+
Return the picking behavior of the artist.
|
| 585 |
+
|
| 586 |
+
The possible values are described in `.Artist.set_picker`.
|
| 587 |
+
|
| 588 |
+
See Also
|
| 589 |
+
--------
|
| 590 |
+
.Artist.set_picker, .Artist.pickable, .Artist.pick
|
| 591 |
+
"""
|
| 592 |
+
return self._picker
|
| 593 |
+
|
| 594 |
+
def get_url(self):
|
| 595 |
+
"""Return the url."""
|
| 596 |
+
return self._url
|
| 597 |
+
|
| 598 |
+
def set_url(self, url):
|
| 599 |
+
"""
|
| 600 |
+
Set the url for the artist.
|
| 601 |
+
|
| 602 |
+
Parameters
|
| 603 |
+
----------
|
| 604 |
+
url : str
|
| 605 |
+
"""
|
| 606 |
+
self._url = url
|
| 607 |
+
|
| 608 |
+
def get_gid(self):
|
| 609 |
+
"""Return the group id."""
|
| 610 |
+
return self._gid
|
| 611 |
+
|
| 612 |
+
def set_gid(self, gid):
|
| 613 |
+
"""
|
| 614 |
+
Set the (group) id for the artist.
|
| 615 |
+
|
| 616 |
+
Parameters
|
| 617 |
+
----------
|
| 618 |
+
gid : str
|
| 619 |
+
"""
|
| 620 |
+
self._gid = gid
|
| 621 |
+
|
| 622 |
+
def get_snap(self):
|
| 623 |
+
"""
|
| 624 |
+
Return the snap setting.
|
| 625 |
+
|
| 626 |
+
See `.set_snap` for details.
|
| 627 |
+
"""
|
| 628 |
+
if mpl.rcParams['path.snap']:
|
| 629 |
+
return self._snap
|
| 630 |
+
else:
|
| 631 |
+
return False
|
| 632 |
+
|
| 633 |
+
def set_snap(self, snap):
|
| 634 |
+
"""
|
| 635 |
+
Set the snapping behavior.
|
| 636 |
+
|
| 637 |
+
Snapping aligns positions with the pixel grid, which results in
|
| 638 |
+
clearer images. For example, if a black line of 1px width was
|
| 639 |
+
defined at a position in between two pixels, the resulting image
|
| 640 |
+
would contain the interpolated value of that line in the pixel grid,
|
| 641 |
+
which would be a grey value on both adjacent pixel positions. In
|
| 642 |
+
contrast, snapping will move the line to the nearest integer pixel
|
| 643 |
+
value, so that the resulting image will really contain a 1px wide
|
| 644 |
+
black line.
|
| 645 |
+
|
| 646 |
+
Snapping is currently only supported by the Agg and MacOSX backends.
|
| 647 |
+
|
| 648 |
+
Parameters
|
| 649 |
+
----------
|
| 650 |
+
snap : bool or None
|
| 651 |
+
Possible values:
|
| 652 |
+
|
| 653 |
+
- *True*: Snap vertices to the nearest pixel center.
|
| 654 |
+
- *False*: Do not modify vertex positions.
|
| 655 |
+
- *None*: (auto) If the path contains only rectilinear line
|
| 656 |
+
segments, round to the nearest pixel center.
|
| 657 |
+
"""
|
| 658 |
+
self._snap = snap
|
| 659 |
+
self.stale = True
|
| 660 |
+
|
| 661 |
+
def get_sketch_params(self):
|
| 662 |
+
"""
|
| 663 |
+
Return the sketch parameters for the artist.
|
| 664 |
+
|
| 665 |
+
Returns
|
| 666 |
+
-------
|
| 667 |
+
tuple or None
|
| 668 |
+
|
| 669 |
+
A 3-tuple with the following elements:
|
| 670 |
+
|
| 671 |
+
- *scale*: The amplitude of the wiggle perpendicular to the
|
| 672 |
+
source line.
|
| 673 |
+
- *length*: The length of the wiggle along the line.
|
| 674 |
+
- *randomness*: The scale factor by which the length is
|
| 675 |
+
shrunken or expanded.
|
| 676 |
+
|
| 677 |
+
Returns *None* if no sketch parameters were set.
|
| 678 |
+
"""
|
| 679 |
+
return self._sketch
|
| 680 |
+
|
| 681 |
+
def set_sketch_params(self, scale=None, length=None, randomness=None):
|
| 682 |
+
"""
|
| 683 |
+
Set the sketch parameters.
|
| 684 |
+
|
| 685 |
+
Parameters
|
| 686 |
+
----------
|
| 687 |
+
scale : float, optional
|
| 688 |
+
The amplitude of the wiggle perpendicular to the source
|
| 689 |
+
line, in pixels. If scale is `None`, or not provided, no
|
| 690 |
+
sketch filter will be provided.
|
| 691 |
+
length : float, optional
|
| 692 |
+
The length of the wiggle along the line, in pixels
|
| 693 |
+
(default 128.0)
|
| 694 |
+
randomness : float, optional
|
| 695 |
+
The scale factor by which the length is shrunken or
|
| 696 |
+
expanded (default 16.0)
|
| 697 |
+
|
| 698 |
+
The PGF backend uses this argument as an RNG seed and not as
|
| 699 |
+
described above. Using the same seed yields the same random shape.
|
| 700 |
+
|
| 701 |
+
.. ACCEPTS: (scale: float, length: float, randomness: float)
|
| 702 |
+
"""
|
| 703 |
+
if scale is None:
|
| 704 |
+
self._sketch = None
|
| 705 |
+
else:
|
| 706 |
+
self._sketch = (scale, length or 128.0, randomness or 16.0)
|
| 707 |
+
self.stale = True
|
| 708 |
+
|
| 709 |
+
def set_path_effects(self, path_effects):
|
| 710 |
+
"""
|
| 711 |
+
Set the path effects.
|
| 712 |
+
|
| 713 |
+
Parameters
|
| 714 |
+
----------
|
| 715 |
+
path_effects : list of `.AbstractPathEffect`
|
| 716 |
+
"""
|
| 717 |
+
self._path_effects = path_effects
|
| 718 |
+
self.stale = True
|
| 719 |
+
|
| 720 |
+
def get_path_effects(self):
|
| 721 |
+
return self._path_effects
|
| 722 |
+
|
| 723 |
+
def get_figure(self, root=False):
|
| 724 |
+
"""
|
| 725 |
+
Return the `.Figure` or `.SubFigure` instance the artist belongs to.
|
| 726 |
+
|
| 727 |
+
Parameters
|
| 728 |
+
----------
|
| 729 |
+
root : bool, default=False
|
| 730 |
+
If False, return the (Sub)Figure this artist is on. If True,
|
| 731 |
+
return the root Figure for a nested tree of SubFigures.
|
| 732 |
+
"""
|
| 733 |
+
if root and self._parent_figure is not None:
|
| 734 |
+
return self._parent_figure.get_figure(root=True)
|
| 735 |
+
|
| 736 |
+
return self._parent_figure
|
| 737 |
+
|
| 738 |
+
def set_figure(self, fig):
|
| 739 |
+
"""
|
| 740 |
+
Set the `.Figure` or `.SubFigure` instance the artist belongs to.
|
| 741 |
+
|
| 742 |
+
Parameters
|
| 743 |
+
----------
|
| 744 |
+
fig : `~matplotlib.figure.Figure` or `~matplotlib.figure.SubFigure`
|
| 745 |
+
"""
|
| 746 |
+
# if this is a no-op just return
|
| 747 |
+
if self._parent_figure is fig:
|
| 748 |
+
return
|
| 749 |
+
# if we currently have a figure (the case of both `self.figure`
|
| 750 |
+
# and *fig* being none is taken care of above) we then user is
|
| 751 |
+
# trying to change the figure an artist is associated with which
|
| 752 |
+
# is not allowed for the same reason as adding the same instance
|
| 753 |
+
# to more than one Axes
|
| 754 |
+
if self._parent_figure is not None:
|
| 755 |
+
raise RuntimeError("Can not put single artist in "
|
| 756 |
+
"more than one figure")
|
| 757 |
+
self._parent_figure = fig
|
| 758 |
+
if self._parent_figure and self._parent_figure is not self:
|
| 759 |
+
self.pchanged()
|
| 760 |
+
self.stale = True
|
| 761 |
+
|
| 762 |
+
figure = property(get_figure, set_figure,
|
| 763 |
+
doc=("The (Sub)Figure that the artist is on. For more "
|
| 764 |
+
"control, use the `get_figure` method."))
|
| 765 |
+
|
| 766 |
+
def set_clip_box(self, clipbox):
|
| 767 |
+
"""
|
| 768 |
+
Set the artist's clip `.Bbox`.
|
| 769 |
+
|
| 770 |
+
Parameters
|
| 771 |
+
----------
|
| 772 |
+
clipbox : `~matplotlib.transforms.BboxBase` or None
|
| 773 |
+
Will typically be created from a `.TransformedBbox`. For instance,
|
| 774 |
+
``TransformedBbox(Bbox([[0, 0], [1, 1]]), ax.transAxes)`` is the default
|
| 775 |
+
clipping for an artist added to an Axes.
|
| 776 |
+
|
| 777 |
+
"""
|
| 778 |
+
_api.check_isinstance((BboxBase, None), clipbox=clipbox)
|
| 779 |
+
if clipbox != self.clipbox:
|
| 780 |
+
self.clipbox = clipbox
|
| 781 |
+
self.pchanged()
|
| 782 |
+
self.stale = True
|
| 783 |
+
|
| 784 |
+
def set_clip_path(self, path, transform=None):
|
| 785 |
+
"""
|
| 786 |
+
Set the artist's clip path.
|
| 787 |
+
|
| 788 |
+
Parameters
|
| 789 |
+
----------
|
| 790 |
+
path : `~matplotlib.patches.Patch` or `.Path` or `.TransformedPath` or None
|
| 791 |
+
The clip path. If given a `.Path`, *transform* must be provided as
|
| 792 |
+
well. If *None*, a previously set clip path is removed.
|
| 793 |
+
transform : `~matplotlib.transforms.Transform`, optional
|
| 794 |
+
Only used if *path* is a `.Path`, in which case the given `.Path`
|
| 795 |
+
is converted to a `.TransformedPath` using *transform*.
|
| 796 |
+
|
| 797 |
+
Notes
|
| 798 |
+
-----
|
| 799 |
+
For efficiency, if *path* is a `.Rectangle` this method will set the
|
| 800 |
+
clipping box to the corresponding rectangle and set the clipping path
|
| 801 |
+
to ``None``.
|
| 802 |
+
|
| 803 |
+
For technical reasons (support of `~.Artist.set`), a tuple
|
| 804 |
+
(*path*, *transform*) is also accepted as a single positional
|
| 805 |
+
parameter.
|
| 806 |
+
|
| 807 |
+
.. ACCEPTS: Patch or (Path, Transform) or None
|
| 808 |
+
"""
|
| 809 |
+
from matplotlib.patches import Patch, Rectangle
|
| 810 |
+
|
| 811 |
+
success = False
|
| 812 |
+
if transform is None:
|
| 813 |
+
if isinstance(path, Rectangle):
|
| 814 |
+
self.clipbox = TransformedBbox(Bbox.unit(),
|
| 815 |
+
path.get_transform())
|
| 816 |
+
self._clippath = None
|
| 817 |
+
success = True
|
| 818 |
+
elif isinstance(path, Patch):
|
| 819 |
+
self._clippath = TransformedPatchPath(path)
|
| 820 |
+
success = True
|
| 821 |
+
elif isinstance(path, tuple):
|
| 822 |
+
path, transform = path
|
| 823 |
+
|
| 824 |
+
if path is None:
|
| 825 |
+
self._clippath = None
|
| 826 |
+
success = True
|
| 827 |
+
elif isinstance(path, Path):
|
| 828 |
+
self._clippath = TransformedPath(path, transform)
|
| 829 |
+
success = True
|
| 830 |
+
elif isinstance(path, TransformedPatchPath):
|
| 831 |
+
self._clippath = path
|
| 832 |
+
success = True
|
| 833 |
+
elif isinstance(path, TransformedPath):
|
| 834 |
+
self._clippath = path
|
| 835 |
+
success = True
|
| 836 |
+
|
| 837 |
+
if not success:
|
| 838 |
+
raise TypeError(
|
| 839 |
+
"Invalid arguments to set_clip_path, of type "
|
| 840 |
+
f"{type(path).__name__} and {type(transform).__name__}")
|
| 841 |
+
# This may result in the callbacks being hit twice, but guarantees they
|
| 842 |
+
# will be hit at least once.
|
| 843 |
+
self.pchanged()
|
| 844 |
+
self.stale = True
|
| 845 |
+
|
| 846 |
+
def get_alpha(self):
|
| 847 |
+
"""
|
| 848 |
+
Return the alpha value used for blending - not supported on all
|
| 849 |
+
backends.
|
| 850 |
+
"""
|
| 851 |
+
return self._alpha
|
| 852 |
+
|
| 853 |
+
def get_visible(self):
|
| 854 |
+
"""Return the visibility."""
|
| 855 |
+
return self._visible
|
| 856 |
+
|
| 857 |
+
def get_animated(self):
|
| 858 |
+
"""Return whether the artist is animated."""
|
| 859 |
+
return self._animated
|
| 860 |
+
|
| 861 |
+
def get_in_layout(self):
|
| 862 |
+
"""
|
| 863 |
+
Return boolean flag, ``True`` if artist is included in layout
|
| 864 |
+
calculations.
|
| 865 |
+
|
| 866 |
+
E.g. :ref:`constrainedlayout_guide`,
|
| 867 |
+
`.Figure.tight_layout()`, and
|
| 868 |
+
``fig.savefig(fname, bbox_inches='tight')``.
|
| 869 |
+
"""
|
| 870 |
+
return self._in_layout
|
| 871 |
+
|
| 872 |
+
def _fully_clipped_to_axes(self):
|
| 873 |
+
"""
|
| 874 |
+
Return a boolean flag, ``True`` if the artist is clipped to the Axes
|
| 875 |
+
and can thus be skipped in layout calculations. Requires `get_clip_on`
|
| 876 |
+
is True, one of `clip_box` or `clip_path` is set, ``clip_box.extents``
|
| 877 |
+
is equivalent to ``ax.bbox.extents`` (if set), and ``clip_path._patch``
|
| 878 |
+
is equivalent to ``ax.patch`` (if set).
|
| 879 |
+
"""
|
| 880 |
+
# Note that ``clip_path.get_fully_transformed_path().get_extents()``
|
| 881 |
+
# cannot be directly compared to ``axes.bbox.extents`` because the
|
| 882 |
+
# extents may be undefined (i.e. equivalent to ``Bbox.null()``)
|
| 883 |
+
# before the associated artist is drawn, and this method is meant
|
| 884 |
+
# to determine whether ``axes.get_tightbbox()`` may bypass drawing
|
| 885 |
+
clip_box = self.get_clip_box()
|
| 886 |
+
clip_path = self.get_clip_path()
|
| 887 |
+
return (self.axes is not None
|
| 888 |
+
and self.get_clip_on()
|
| 889 |
+
and (clip_box is not None or clip_path is not None)
|
| 890 |
+
and (clip_box is None
|
| 891 |
+
or np.all(clip_box.extents == self.axes.bbox.extents))
|
| 892 |
+
and (clip_path is None
|
| 893 |
+
or isinstance(clip_path, TransformedPatchPath)
|
| 894 |
+
and clip_path._patch is self.axes.patch))
|
| 895 |
+
|
| 896 |
+
def get_clip_on(self):
|
| 897 |
+
"""Return whether the artist uses clipping."""
|
| 898 |
+
return self._clipon
|
| 899 |
+
|
| 900 |
+
def get_clip_box(self):
|
| 901 |
+
"""Return the clipbox."""
|
| 902 |
+
return self.clipbox
|
| 903 |
+
|
| 904 |
+
def get_clip_path(self):
|
| 905 |
+
"""Return the clip path."""
|
| 906 |
+
return self._clippath
|
| 907 |
+
|
| 908 |
+
def get_transformed_clip_path_and_affine(self):
|
| 909 |
+
"""
|
| 910 |
+
Return the clip path with the non-affine part of its
|
| 911 |
+
transformation applied, and the remaining affine part of its
|
| 912 |
+
transformation.
|
| 913 |
+
"""
|
| 914 |
+
if self._clippath is not None:
|
| 915 |
+
return self._clippath.get_transformed_path_and_affine()
|
| 916 |
+
return None, None
|
| 917 |
+
|
| 918 |
+
def set_clip_on(self, b):
|
| 919 |
+
"""
|
| 920 |
+
Set whether the artist uses clipping.
|
| 921 |
+
|
| 922 |
+
When False, artists will be visible outside the Axes which
|
| 923 |
+
can lead to unexpected results.
|
| 924 |
+
|
| 925 |
+
Parameters
|
| 926 |
+
----------
|
| 927 |
+
b : bool
|
| 928 |
+
"""
|
| 929 |
+
self._clipon = b
|
| 930 |
+
# This may result in the callbacks being hit twice, but ensures they
|
| 931 |
+
# are hit at least once
|
| 932 |
+
self.pchanged()
|
| 933 |
+
self.stale = True
|
| 934 |
+
|
| 935 |
+
def _set_gc_clip(self, gc):
|
| 936 |
+
"""Set the clip properly for the gc."""
|
| 937 |
+
if self._clipon:
|
| 938 |
+
if self.clipbox is not None:
|
| 939 |
+
gc.set_clip_rectangle(self.clipbox)
|
| 940 |
+
gc.set_clip_path(self._clippath)
|
| 941 |
+
else:
|
| 942 |
+
gc.set_clip_rectangle(None)
|
| 943 |
+
gc.set_clip_path(None)
|
| 944 |
+
|
| 945 |
+
def get_rasterized(self):
|
| 946 |
+
"""Return whether the artist is to be rasterized."""
|
| 947 |
+
return self._rasterized
|
| 948 |
+
|
| 949 |
+
def set_rasterized(self, rasterized):
|
| 950 |
+
"""
|
| 951 |
+
Force rasterized (bitmap) drawing for vector graphics output.
|
| 952 |
+
|
| 953 |
+
Rasterized drawing is not supported by all artists. If you try to
|
| 954 |
+
enable this on an artist that does not support it, the command has no
|
| 955 |
+
effect and a warning will be issued.
|
| 956 |
+
|
| 957 |
+
This setting is ignored for pixel-based output.
|
| 958 |
+
|
| 959 |
+
See also :doc:`/gallery/misc/rasterization_demo`.
|
| 960 |
+
|
| 961 |
+
Parameters
|
| 962 |
+
----------
|
| 963 |
+
rasterized : bool
|
| 964 |
+
"""
|
| 965 |
+
supports_rasterization = getattr(self.draw,
|
| 966 |
+
"_supports_rasterization", False)
|
| 967 |
+
if rasterized and not supports_rasterization:
|
| 968 |
+
_api.warn_external(f"Rasterization of '{self}' will be ignored")
|
| 969 |
+
|
| 970 |
+
self._rasterized = rasterized
|
| 971 |
+
|
| 972 |
+
def get_agg_filter(self):
|
| 973 |
+
"""Return filter function to be used for agg filter."""
|
| 974 |
+
return self._agg_filter
|
| 975 |
+
|
| 976 |
+
def set_agg_filter(self, filter_func):
|
| 977 |
+
"""
|
| 978 |
+
Set the agg filter.
|
| 979 |
+
|
| 980 |
+
Parameters
|
| 981 |
+
----------
|
| 982 |
+
filter_func : callable
|
| 983 |
+
A filter function, which takes a (m, n, depth) float array
|
| 984 |
+
and a dpi value, and returns a (m, n, depth) array and two
|
| 985 |
+
offsets from the bottom left corner of the image
|
| 986 |
+
|
| 987 |
+
.. ACCEPTS: a filter function, which takes a (m, n, 3) float array
|
| 988 |
+
and a dpi value, and returns a (m, n, 3) array and two offsets
|
| 989 |
+
from the bottom left corner of the image
|
| 990 |
+
"""
|
| 991 |
+
self._agg_filter = filter_func
|
| 992 |
+
self.stale = True
|
| 993 |
+
|
| 994 |
+
def draw(self, renderer):
|
| 995 |
+
"""
|
| 996 |
+
Draw the Artist (and its children) using the given renderer.
|
| 997 |
+
|
| 998 |
+
This has no effect if the artist is not visible (`.Artist.get_visible`
|
| 999 |
+
returns False).
|
| 1000 |
+
|
| 1001 |
+
Parameters
|
| 1002 |
+
----------
|
| 1003 |
+
renderer : `~matplotlib.backend_bases.RendererBase` subclass.
|
| 1004 |
+
|
| 1005 |
+
Notes
|
| 1006 |
+
-----
|
| 1007 |
+
This method is overridden in the Artist subclasses.
|
| 1008 |
+
"""
|
| 1009 |
+
if not self.get_visible():
|
| 1010 |
+
return
|
| 1011 |
+
self.stale = False
|
| 1012 |
+
|
| 1013 |
+
def set_alpha(self, alpha):
|
| 1014 |
+
"""
|
| 1015 |
+
Set the alpha value used for blending - not supported on all backends.
|
| 1016 |
+
|
| 1017 |
+
Parameters
|
| 1018 |
+
----------
|
| 1019 |
+
alpha : float or None
|
| 1020 |
+
*alpha* must be within the 0-1 range, inclusive.
|
| 1021 |
+
"""
|
| 1022 |
+
if alpha is not None and not isinstance(alpha, Real):
|
| 1023 |
+
raise TypeError(
|
| 1024 |
+
f'alpha must be numeric or None, not {type(alpha)}')
|
| 1025 |
+
if alpha is not None and not (0 <= alpha <= 1):
|
| 1026 |
+
raise ValueError(f'alpha ({alpha}) is outside 0-1 range')
|
| 1027 |
+
if alpha != self._alpha:
|
| 1028 |
+
self._alpha = alpha
|
| 1029 |
+
self.pchanged()
|
| 1030 |
+
self.stale = True
|
| 1031 |
+
|
| 1032 |
+
def _set_alpha_for_array(self, alpha):
|
| 1033 |
+
"""
|
| 1034 |
+
Set the alpha value used for blending - not supported on all backends.
|
| 1035 |
+
|
| 1036 |
+
Parameters
|
| 1037 |
+
----------
|
| 1038 |
+
alpha : array-like or float or None
|
| 1039 |
+
All values must be within the 0-1 range, inclusive.
|
| 1040 |
+
Masked values and nans are not supported.
|
| 1041 |
+
"""
|
| 1042 |
+
if isinstance(alpha, str):
|
| 1043 |
+
raise TypeError("alpha must be numeric or None, not a string")
|
| 1044 |
+
if not np.iterable(alpha):
|
| 1045 |
+
Artist.set_alpha(self, alpha)
|
| 1046 |
+
return
|
| 1047 |
+
alpha = np.asarray(alpha)
|
| 1048 |
+
if not (0 <= alpha.min() and alpha.max() <= 1):
|
| 1049 |
+
raise ValueError('alpha must be between 0 and 1, inclusive, '
|
| 1050 |
+
f'but min is {alpha.min()}, max is {alpha.max()}')
|
| 1051 |
+
self._alpha = alpha
|
| 1052 |
+
self.pchanged()
|
| 1053 |
+
self.stale = True
|
| 1054 |
+
|
| 1055 |
+
def set_visible(self, b):
|
| 1056 |
+
"""
|
| 1057 |
+
Set the artist's visibility.
|
| 1058 |
+
|
| 1059 |
+
Parameters
|
| 1060 |
+
----------
|
| 1061 |
+
b : bool
|
| 1062 |
+
"""
|
| 1063 |
+
if b != self._visible:
|
| 1064 |
+
self._visible = b
|
| 1065 |
+
self.pchanged()
|
| 1066 |
+
self.stale = True
|
| 1067 |
+
|
| 1068 |
+
def set_animated(self, b):
|
| 1069 |
+
"""
|
| 1070 |
+
Set whether the artist is intended to be used in an animation.
|
| 1071 |
+
|
| 1072 |
+
If True, the artist is excluded from regular drawing of the figure.
|
| 1073 |
+
You have to call `.Figure.draw_artist` / `.Axes.draw_artist`
|
| 1074 |
+
explicitly on the artist. This approach is used to speed up animations
|
| 1075 |
+
using blitting.
|
| 1076 |
+
|
| 1077 |
+
See also `matplotlib.animation` and
|
| 1078 |
+
:ref:`blitting`.
|
| 1079 |
+
|
| 1080 |
+
Parameters
|
| 1081 |
+
----------
|
| 1082 |
+
b : bool
|
| 1083 |
+
"""
|
| 1084 |
+
if self._animated != b:
|
| 1085 |
+
self._animated = b
|
| 1086 |
+
self.pchanged()
|
| 1087 |
+
|
| 1088 |
+
def set_in_layout(self, in_layout):
|
| 1089 |
+
"""
|
| 1090 |
+
Set if artist is to be included in layout calculations,
|
| 1091 |
+
E.g. :ref:`constrainedlayout_guide`,
|
| 1092 |
+
`.Figure.tight_layout()`, and
|
| 1093 |
+
``fig.savefig(fname, bbox_inches='tight')``.
|
| 1094 |
+
|
| 1095 |
+
Parameters
|
| 1096 |
+
----------
|
| 1097 |
+
in_layout : bool
|
| 1098 |
+
"""
|
| 1099 |
+
self._in_layout = in_layout
|
| 1100 |
+
|
| 1101 |
+
def get_label(self):
|
| 1102 |
+
"""Return the label used for this artist in the legend."""
|
| 1103 |
+
return self._label
|
| 1104 |
+
|
| 1105 |
+
def set_label(self, s):
|
| 1106 |
+
"""
|
| 1107 |
+
Set a label that will be displayed in the legend.
|
| 1108 |
+
|
| 1109 |
+
Parameters
|
| 1110 |
+
----------
|
| 1111 |
+
s : object
|
| 1112 |
+
*s* will be converted to a string by calling `str`.
|
| 1113 |
+
"""
|
| 1114 |
+
label = str(s) if s is not None else None
|
| 1115 |
+
if label != self._label:
|
| 1116 |
+
self._label = label
|
| 1117 |
+
self.pchanged()
|
| 1118 |
+
self.stale = True
|
| 1119 |
+
|
| 1120 |
+
def get_zorder(self):
|
| 1121 |
+
"""Return the artist's zorder."""
|
| 1122 |
+
return self.zorder
|
| 1123 |
+
|
| 1124 |
+
def set_zorder(self, level):
|
| 1125 |
+
"""
|
| 1126 |
+
Set the zorder for the artist. Artists with lower zorder
|
| 1127 |
+
values are drawn first.
|
| 1128 |
+
|
| 1129 |
+
Parameters
|
| 1130 |
+
----------
|
| 1131 |
+
level : float
|
| 1132 |
+
"""
|
| 1133 |
+
if level is None:
|
| 1134 |
+
level = self.__class__.zorder
|
| 1135 |
+
if level != self.zorder:
|
| 1136 |
+
self.zorder = level
|
| 1137 |
+
self.pchanged()
|
| 1138 |
+
self.stale = True
|
| 1139 |
+
|
| 1140 |
+
@property
|
| 1141 |
+
def sticky_edges(self):
|
| 1142 |
+
"""
|
| 1143 |
+
``x`` and ``y`` sticky edge lists for autoscaling.
|
| 1144 |
+
|
| 1145 |
+
When performing autoscaling, if a data limit coincides with a value in
|
| 1146 |
+
the corresponding sticky_edges list, then no margin will be added--the
|
| 1147 |
+
view limit "sticks" to the edge. A typical use case is histograms,
|
| 1148 |
+
where one usually expects no margin on the bottom edge (0) of the
|
| 1149 |
+
histogram.
|
| 1150 |
+
|
| 1151 |
+
Moreover, margin expansion "bumps" against sticky edges and cannot
|
| 1152 |
+
cross them. For example, if the upper data limit is 1.0, the upper
|
| 1153 |
+
view limit computed by simple margin application is 1.2, but there is a
|
| 1154 |
+
sticky edge at 1.1, then the actual upper view limit will be 1.1.
|
| 1155 |
+
|
| 1156 |
+
This attribute cannot be assigned to; however, the ``x`` and ``y``
|
| 1157 |
+
lists can be modified in place as needed.
|
| 1158 |
+
|
| 1159 |
+
Examples
|
| 1160 |
+
--------
|
| 1161 |
+
>>> artist.sticky_edges.x[:] = (xmin, xmax)
|
| 1162 |
+
>>> artist.sticky_edges.y[:] = (ymin, ymax)
|
| 1163 |
+
|
| 1164 |
+
"""
|
| 1165 |
+
return self._sticky_edges
|
| 1166 |
+
|
| 1167 |
+
def update_from(self, other):
|
| 1168 |
+
"""Copy properties from *other* to *self*."""
|
| 1169 |
+
self._transform = other._transform
|
| 1170 |
+
self._transformSet = other._transformSet
|
| 1171 |
+
self._visible = other._visible
|
| 1172 |
+
self._alpha = other._alpha
|
| 1173 |
+
self.clipbox = other.clipbox
|
| 1174 |
+
self._clipon = other._clipon
|
| 1175 |
+
self._clippath = other._clippath
|
| 1176 |
+
self._label = other._label
|
| 1177 |
+
self._sketch = other._sketch
|
| 1178 |
+
self._path_effects = other._path_effects
|
| 1179 |
+
self.sticky_edges.x[:] = other.sticky_edges.x.copy()
|
| 1180 |
+
self.sticky_edges.y[:] = other.sticky_edges.y.copy()
|
| 1181 |
+
self.pchanged()
|
| 1182 |
+
self.stale = True
|
| 1183 |
+
|
| 1184 |
+
def properties(self):
|
| 1185 |
+
"""Return a dictionary of all the properties of the artist."""
|
| 1186 |
+
return ArtistInspector(self).properties()
|
| 1187 |
+
|
| 1188 |
+
def _update_props(self, props, errfmt):
|
| 1189 |
+
"""
|
| 1190 |
+
Helper for `.Artist.set` and `.Artist.update`.
|
| 1191 |
+
|
| 1192 |
+
*errfmt* is used to generate error messages for invalid property
|
| 1193 |
+
names; it gets formatted with ``type(self)`` for "{cls}" and the
|
| 1194 |
+
property name for "{prop_name}".
|
| 1195 |
+
"""
|
| 1196 |
+
ret = []
|
| 1197 |
+
with cbook._setattr_cm(self, eventson=False):
|
| 1198 |
+
for k, v in props.items():
|
| 1199 |
+
# Allow attributes we want to be able to update through
|
| 1200 |
+
# art.update, art.set, setp.
|
| 1201 |
+
if k == "axes":
|
| 1202 |
+
ret.append(setattr(self, k, v))
|
| 1203 |
+
else:
|
| 1204 |
+
func = getattr(self, f"set_{k}", None)
|
| 1205 |
+
if not callable(func):
|
| 1206 |
+
raise AttributeError(
|
| 1207 |
+
errfmt.format(cls=type(self), prop_name=k),
|
| 1208 |
+
name=k)
|
| 1209 |
+
ret.append(func(v))
|
| 1210 |
+
if ret:
|
| 1211 |
+
self.pchanged()
|
| 1212 |
+
self.stale = True
|
| 1213 |
+
return ret
|
| 1214 |
+
|
| 1215 |
+
def update(self, props):
|
| 1216 |
+
"""
|
| 1217 |
+
Update this artist's properties from the dict *props*.
|
| 1218 |
+
|
| 1219 |
+
Parameters
|
| 1220 |
+
----------
|
| 1221 |
+
props : dict
|
| 1222 |
+
"""
|
| 1223 |
+
return self._update_props(
|
| 1224 |
+
props, "{cls.__name__!r} object has no property {prop_name!r}")
|
| 1225 |
+
|
| 1226 |
+
def _internal_update(self, kwargs):
|
| 1227 |
+
"""
|
| 1228 |
+
Update artist properties without prenormalizing them, but generating
|
| 1229 |
+
errors as if calling `set`.
|
| 1230 |
+
|
| 1231 |
+
The lack of prenormalization is to maintain backcompatibility.
|
| 1232 |
+
"""
|
| 1233 |
+
return self._update_props(
|
| 1234 |
+
kwargs, "{cls.__name__}.set() got an unexpected keyword argument "
|
| 1235 |
+
"{prop_name!r}")
|
| 1236 |
+
|
| 1237 |
+
def set(self, **kwargs):
|
| 1238 |
+
# docstring and signature are auto-generated via
|
| 1239 |
+
# Artist._update_set_signature_and_docstring() at the end of the
|
| 1240 |
+
# module.
|
| 1241 |
+
return self._internal_update(cbook.normalize_kwargs(kwargs, self))
|
| 1242 |
+
|
| 1243 |
+
@contextlib.contextmanager
|
| 1244 |
+
def _cm_set(self, **kwargs):
|
| 1245 |
+
"""
|
| 1246 |
+
`.Artist.set` context-manager that restores original values at exit.
|
| 1247 |
+
"""
|
| 1248 |
+
orig_vals = {k: getattr(self, f"get_{k}")() for k in kwargs}
|
| 1249 |
+
try:
|
| 1250 |
+
self.set(**kwargs)
|
| 1251 |
+
yield
|
| 1252 |
+
finally:
|
| 1253 |
+
self.set(**orig_vals)
|
| 1254 |
+
|
| 1255 |
+
def findobj(self, match=None, include_self=True):
|
| 1256 |
+
"""
|
| 1257 |
+
Find artist objects.
|
| 1258 |
+
|
| 1259 |
+
Recursively find all `.Artist` instances contained in the artist.
|
| 1260 |
+
|
| 1261 |
+
Parameters
|
| 1262 |
+
----------
|
| 1263 |
+
match
|
| 1264 |
+
A filter criterion for the matches. This can be
|
| 1265 |
+
|
| 1266 |
+
- *None*: Return all objects contained in artist.
|
| 1267 |
+
- A function with signature ``def match(artist: Artist) -> bool``.
|
| 1268 |
+
The result will only contain artists for which the function
|
| 1269 |
+
returns *True*.
|
| 1270 |
+
- A class instance: e.g., `.Line2D`. The result will only contain
|
| 1271 |
+
artists of this class or its subclasses (``isinstance`` check).
|
| 1272 |
+
|
| 1273 |
+
include_self : bool
|
| 1274 |
+
Include *self* in the list to be checked for a match.
|
| 1275 |
+
|
| 1276 |
+
Returns
|
| 1277 |
+
-------
|
| 1278 |
+
list of `.Artist`
|
| 1279 |
+
|
| 1280 |
+
"""
|
| 1281 |
+
if match is None: # always return True
|
| 1282 |
+
def matchfunc(x):
|
| 1283 |
+
return True
|
| 1284 |
+
elif isinstance(match, type) and issubclass(match, Artist):
|
| 1285 |
+
def matchfunc(x):
|
| 1286 |
+
return isinstance(x, match)
|
| 1287 |
+
elif callable(match):
|
| 1288 |
+
matchfunc = match
|
| 1289 |
+
else:
|
| 1290 |
+
raise ValueError('match must be None, a matplotlib.artist.Artist '
|
| 1291 |
+
'subclass, or a callable')
|
| 1292 |
+
|
| 1293 |
+
artists = reduce(operator.iadd,
|
| 1294 |
+
[c.findobj(matchfunc) for c in self.get_children()], [])
|
| 1295 |
+
if include_self and matchfunc(self):
|
| 1296 |
+
artists.append(self)
|
| 1297 |
+
return artists
|
| 1298 |
+
|
| 1299 |
+
def get_cursor_data(self, event):
|
| 1300 |
+
"""
|
| 1301 |
+
Return the cursor data for a given event.
|
| 1302 |
+
|
| 1303 |
+
.. note::
|
| 1304 |
+
This method is intended to be overridden by artist subclasses.
|
| 1305 |
+
As an end-user of Matplotlib you will most likely not call this
|
| 1306 |
+
method yourself.
|
| 1307 |
+
|
| 1308 |
+
Cursor data can be used by Artists to provide additional context
|
| 1309 |
+
information for a given event. The default implementation just returns
|
| 1310 |
+
*None*.
|
| 1311 |
+
|
| 1312 |
+
Subclasses can override the method and return arbitrary data. However,
|
| 1313 |
+
when doing so, they must ensure that `.format_cursor_data` can convert
|
| 1314 |
+
the data to a string representation.
|
| 1315 |
+
|
| 1316 |
+
The only current use case is displaying the z-value of an `.AxesImage`
|
| 1317 |
+
in the status bar of a plot window, while moving the mouse.
|
| 1318 |
+
|
| 1319 |
+
Parameters
|
| 1320 |
+
----------
|
| 1321 |
+
event : `~matplotlib.backend_bases.MouseEvent`
|
| 1322 |
+
|
| 1323 |
+
See Also
|
| 1324 |
+
--------
|
| 1325 |
+
format_cursor_data
|
| 1326 |
+
|
| 1327 |
+
"""
|
| 1328 |
+
return None
|
| 1329 |
+
|
| 1330 |
+
def format_cursor_data(self, data):
|
| 1331 |
+
"""
|
| 1332 |
+
Return a string representation of *data*.
|
| 1333 |
+
|
| 1334 |
+
.. note::
|
| 1335 |
+
This method is intended to be overridden by artist subclasses.
|
| 1336 |
+
As an end-user of Matplotlib you will most likely not call this
|
| 1337 |
+
method yourself.
|
| 1338 |
+
|
| 1339 |
+
The default implementation converts ints and floats and arrays of ints
|
| 1340 |
+
and floats into a comma-separated string enclosed in square brackets,
|
| 1341 |
+
unless the artist has an associated colorbar, in which case scalar
|
| 1342 |
+
values are formatted using the colorbar's formatter.
|
| 1343 |
+
|
| 1344 |
+
See Also
|
| 1345 |
+
--------
|
| 1346 |
+
get_cursor_data
|
| 1347 |
+
"""
|
| 1348 |
+
if np.ndim(data) == 0 and hasattr(self, "_format_cursor_data_override"):
|
| 1349 |
+
# workaround for ScalarMappable to be able to define its own
|
| 1350 |
+
# format_cursor_data(). See ScalarMappable._format_cursor_data_override
|
| 1351 |
+
# for details.
|
| 1352 |
+
return self._format_cursor_data_override(data)
|
| 1353 |
+
else:
|
| 1354 |
+
try:
|
| 1355 |
+
data[0]
|
| 1356 |
+
except (TypeError, IndexError):
|
| 1357 |
+
data = [data]
|
| 1358 |
+
data_str = ', '.join(f'{item:0.3g}' for item in data
|
| 1359 |
+
if isinstance(item, Number))
|
| 1360 |
+
return "[" + data_str + "]"
|
| 1361 |
+
|
| 1362 |
+
def get_mouseover(self):
|
| 1363 |
+
"""
|
| 1364 |
+
Return whether this artist is queried for custom context information
|
| 1365 |
+
when the mouse cursor moves over it.
|
| 1366 |
+
"""
|
| 1367 |
+
return self._mouseover
|
| 1368 |
+
|
| 1369 |
+
def set_mouseover(self, mouseover):
|
| 1370 |
+
"""
|
| 1371 |
+
Set whether this artist is queried for custom context information when
|
| 1372 |
+
the mouse cursor moves over it.
|
| 1373 |
+
|
| 1374 |
+
Parameters
|
| 1375 |
+
----------
|
| 1376 |
+
mouseover : bool
|
| 1377 |
+
|
| 1378 |
+
See Also
|
| 1379 |
+
--------
|
| 1380 |
+
get_cursor_data
|
| 1381 |
+
.ToolCursorPosition
|
| 1382 |
+
.NavigationToolbar2
|
| 1383 |
+
"""
|
| 1384 |
+
self._mouseover = bool(mouseover)
|
| 1385 |
+
ax = self.axes
|
| 1386 |
+
if ax:
|
| 1387 |
+
if self._mouseover:
|
| 1388 |
+
ax._mouseover_set.add(self)
|
| 1389 |
+
else:
|
| 1390 |
+
ax._mouseover_set.discard(self)
|
| 1391 |
+
|
| 1392 |
+
mouseover = property(get_mouseover, set_mouseover) # backcompat.
|
| 1393 |
+
|
| 1394 |
+
|
| 1395 |
+
def _get_tightbbox_for_layout_only(obj, *args, **kwargs):
|
| 1396 |
+
"""
|
| 1397 |
+
Matplotlib's `.Axes.get_tightbbox` and `.Axis.get_tightbbox` support a
|
| 1398 |
+
*for_layout_only* kwarg; this helper tries to use the kwarg but skips it
|
| 1399 |
+
when encountering third-party subclasses that do not support it.
|
| 1400 |
+
"""
|
| 1401 |
+
try:
|
| 1402 |
+
return obj.get_tightbbox(*args, **{**kwargs, "for_layout_only": True})
|
| 1403 |
+
except TypeError:
|
| 1404 |
+
return obj.get_tightbbox(*args, **kwargs)
|
| 1405 |
+
|
| 1406 |
+
|
| 1407 |
+
class ArtistInspector:
|
| 1408 |
+
"""
|
| 1409 |
+
A helper class to inspect an `~matplotlib.artist.Artist` and return
|
| 1410 |
+
information about its settable properties and their current values.
|
| 1411 |
+
"""
|
| 1412 |
+
|
| 1413 |
+
def __init__(self, o):
|
| 1414 |
+
r"""
|
| 1415 |
+
Initialize the artist inspector with an `Artist` or an iterable of
|
| 1416 |
+
`Artist`\s. If an iterable is used, we assume it is a homogeneous
|
| 1417 |
+
sequence (all `Artist`\s are of the same type) and it is your
|
| 1418 |
+
responsibility to make sure this is so.
|
| 1419 |
+
"""
|
| 1420 |
+
if not isinstance(o, Artist):
|
| 1421 |
+
if np.iterable(o):
|
| 1422 |
+
o = list(o)
|
| 1423 |
+
if len(o):
|
| 1424 |
+
o = o[0]
|
| 1425 |
+
|
| 1426 |
+
self.oorig = o
|
| 1427 |
+
if not isinstance(o, type):
|
| 1428 |
+
o = type(o)
|
| 1429 |
+
self.o = o
|
| 1430 |
+
|
| 1431 |
+
self.aliasd = self.get_aliases()
|
| 1432 |
+
|
| 1433 |
+
def get_aliases(self):
|
| 1434 |
+
"""
|
| 1435 |
+
Get a dict mapping property fullnames to sets of aliases for each alias
|
| 1436 |
+
in the :class:`~matplotlib.artist.ArtistInspector`.
|
| 1437 |
+
|
| 1438 |
+
e.g., for lines::
|
| 1439 |
+
|
| 1440 |
+
{'markerfacecolor': {'mfc'},
|
| 1441 |
+
'linewidth' : {'lw'},
|
| 1442 |
+
}
|
| 1443 |
+
"""
|
| 1444 |
+
names = [name for name in dir(self.o)
|
| 1445 |
+
if name.startswith(('set_', 'get_'))
|
| 1446 |
+
and callable(getattr(self.o, name))]
|
| 1447 |
+
aliases = {}
|
| 1448 |
+
for name in names:
|
| 1449 |
+
func = getattr(self.o, name)
|
| 1450 |
+
if not self.is_alias(func):
|
| 1451 |
+
continue
|
| 1452 |
+
propname = re.search(f"`({name[:4]}.*)`", # get_.*/set_.*
|
| 1453 |
+
inspect.getdoc(func)).group(1)
|
| 1454 |
+
aliases.setdefault(propname[4:], set()).add(name[4:])
|
| 1455 |
+
return aliases
|
| 1456 |
+
|
| 1457 |
+
_get_valid_values_regex = re.compile(
|
| 1458 |
+
r"\n\s*(?:\.\.\s+)?ACCEPTS:\s*((?:.|\n)*?)(?:$|(?:\n\n))"
|
| 1459 |
+
)
|
| 1460 |
+
|
| 1461 |
+
def get_valid_values(self, attr):
|
| 1462 |
+
"""
|
| 1463 |
+
Get the legal arguments for the setter associated with *attr*.
|
| 1464 |
+
|
| 1465 |
+
This is done by querying the docstring of the setter for a line that
|
| 1466 |
+
begins with "ACCEPTS:" or ".. ACCEPTS:", and then by looking for a
|
| 1467 |
+
numpydoc-style documentation for the setter's first argument.
|
| 1468 |
+
"""
|
| 1469 |
+
|
| 1470 |
+
name = 'set_%s' % attr
|
| 1471 |
+
if not hasattr(self.o, name):
|
| 1472 |
+
raise AttributeError(f'{self.o} has no function {name}')
|
| 1473 |
+
func = getattr(self.o, name)
|
| 1474 |
+
|
| 1475 |
+
if hasattr(func, '_kwarg_doc'):
|
| 1476 |
+
return func._kwarg_doc
|
| 1477 |
+
|
| 1478 |
+
docstring = inspect.getdoc(func)
|
| 1479 |
+
if docstring is None:
|
| 1480 |
+
return 'unknown'
|
| 1481 |
+
|
| 1482 |
+
if docstring.startswith('Alias for '):
|
| 1483 |
+
return None
|
| 1484 |
+
|
| 1485 |
+
match = self._get_valid_values_regex.search(docstring)
|
| 1486 |
+
if match is not None:
|
| 1487 |
+
return re.sub("\n *", " ", match.group(1))
|
| 1488 |
+
|
| 1489 |
+
# Much faster than list(inspect.signature(func).parameters)[1],
|
| 1490 |
+
# although barely relevant wrt. matplotlib's total import time.
|
| 1491 |
+
param_name = func.__code__.co_varnames[1]
|
| 1492 |
+
# We could set the presence * based on whether the parameter is a
|
| 1493 |
+
# varargs (it can't be a varkwargs) but it's not really worth it.
|
| 1494 |
+
match = re.search(fr"(?m)^ *\*?{param_name} : (.+)", docstring)
|
| 1495 |
+
if match:
|
| 1496 |
+
return match.group(1)
|
| 1497 |
+
|
| 1498 |
+
return 'unknown'
|
| 1499 |
+
|
| 1500 |
+
def _replace_path(self, source_class):
|
| 1501 |
+
"""
|
| 1502 |
+
Changes the full path to the public API path that is used
|
| 1503 |
+
in sphinx. This is needed for links to work.
|
| 1504 |
+
"""
|
| 1505 |
+
replace_dict = {'_base._AxesBase': 'Axes',
|
| 1506 |
+
'_axes.Axes': 'Axes'}
|
| 1507 |
+
for key, value in replace_dict.items():
|
| 1508 |
+
source_class = source_class.replace(key, value)
|
| 1509 |
+
return source_class
|
| 1510 |
+
|
| 1511 |
+
def get_setters(self):
|
| 1512 |
+
"""
|
| 1513 |
+
Get the attribute strings with setters for object.
|
| 1514 |
+
|
| 1515 |
+
For example, for a line, return ``['markerfacecolor', 'linewidth',
|
| 1516 |
+
....]``.
|
| 1517 |
+
"""
|
| 1518 |
+
setters = []
|
| 1519 |
+
for name in dir(self.o):
|
| 1520 |
+
if not name.startswith('set_'):
|
| 1521 |
+
continue
|
| 1522 |
+
func = getattr(self.o, name)
|
| 1523 |
+
if (not callable(func)
|
| 1524 |
+
or self.number_of_parameters(func) < 2
|
| 1525 |
+
or self.is_alias(func)):
|
| 1526 |
+
continue
|
| 1527 |
+
setters.append(name[4:])
|
| 1528 |
+
return setters
|
| 1529 |
+
|
| 1530 |
+
@staticmethod
|
| 1531 |
+
@cache
|
| 1532 |
+
def number_of_parameters(func):
|
| 1533 |
+
"""Return number of parameters of the callable *func*."""
|
| 1534 |
+
return len(inspect.signature(func).parameters)
|
| 1535 |
+
|
| 1536 |
+
@staticmethod
|
| 1537 |
+
@cache
|
| 1538 |
+
def is_alias(method):
|
| 1539 |
+
"""
|
| 1540 |
+
Return whether the object *method* is an alias for another method.
|
| 1541 |
+
"""
|
| 1542 |
+
|
| 1543 |
+
ds = inspect.getdoc(method)
|
| 1544 |
+
if ds is None:
|
| 1545 |
+
return False
|
| 1546 |
+
|
| 1547 |
+
return ds.startswith('Alias for ')
|
| 1548 |
+
|
| 1549 |
+
def aliased_name(self, s):
|
| 1550 |
+
"""
|
| 1551 |
+
Return 'PROPNAME or alias' if *s* has an alias, else return 'PROPNAME'.
|
| 1552 |
+
|
| 1553 |
+
For example, for the line markerfacecolor property, which has an
|
| 1554 |
+
alias, return 'markerfacecolor or mfc' and for the transform
|
| 1555 |
+
property, which does not, return 'transform'.
|
| 1556 |
+
"""
|
| 1557 |
+
aliases = ''.join(' or %s' % x for x in sorted(self.aliasd.get(s, [])))
|
| 1558 |
+
return s + aliases
|
| 1559 |
+
|
| 1560 |
+
_NOT_LINKABLE = {
|
| 1561 |
+
# A set of property setter methods that are not available in our
|
| 1562 |
+
# current docs. This is a workaround used to prevent trying to link
|
| 1563 |
+
# these setters which would lead to "target reference not found"
|
| 1564 |
+
# warnings during doc build.
|
| 1565 |
+
'matplotlib.image._ImageBase.set_alpha',
|
| 1566 |
+
'matplotlib.image._ImageBase.set_array',
|
| 1567 |
+
'matplotlib.image._ImageBase.set_data',
|
| 1568 |
+
'matplotlib.image._ImageBase.set_filternorm',
|
| 1569 |
+
'matplotlib.image._ImageBase.set_filterrad',
|
| 1570 |
+
'matplotlib.image._ImageBase.set_interpolation',
|
| 1571 |
+
'matplotlib.image._ImageBase.set_interpolation_stage',
|
| 1572 |
+
'matplotlib.image._ImageBase.set_resample',
|
| 1573 |
+
'matplotlib.text._AnnotationBase.set_annotation_clip',
|
| 1574 |
+
}
|
| 1575 |
+
|
| 1576 |
+
def aliased_name_rest(self, s, target):
|
| 1577 |
+
"""
|
| 1578 |
+
Return 'PROPNAME or alias' if *s* has an alias, else return 'PROPNAME',
|
| 1579 |
+
formatted for reST.
|
| 1580 |
+
|
| 1581 |
+
For example, for the line markerfacecolor property, which has an
|
| 1582 |
+
alias, return 'markerfacecolor or mfc' and for the transform
|
| 1583 |
+
property, which does not, return 'transform'.
|
| 1584 |
+
"""
|
| 1585 |
+
# workaround to prevent "reference target not found"
|
| 1586 |
+
if target in self._NOT_LINKABLE:
|
| 1587 |
+
return f'``{s}``'
|
| 1588 |
+
|
| 1589 |
+
aliases = ''.join(
|
| 1590 |
+
f' or :meth:`{a} <{target}>`' for a in sorted(self.aliasd.get(s, [])))
|
| 1591 |
+
return f':meth:`{s} <{target}>`{aliases}'
|
| 1592 |
+
|
| 1593 |
+
def pprint_setters(self, prop=None, leadingspace=2):
|
| 1594 |
+
"""
|
| 1595 |
+
If *prop* is *None*, return a list of strings of all settable
|
| 1596 |
+
properties and their valid values.
|
| 1597 |
+
|
| 1598 |
+
If *prop* is not *None*, it is a valid property name and that
|
| 1599 |
+
property will be returned as a string of property : valid
|
| 1600 |
+
values.
|
| 1601 |
+
"""
|
| 1602 |
+
if leadingspace:
|
| 1603 |
+
pad = ' ' * leadingspace
|
| 1604 |
+
else:
|
| 1605 |
+
pad = ''
|
| 1606 |
+
if prop is not None:
|
| 1607 |
+
accepts = self.get_valid_values(prop)
|
| 1608 |
+
return f'{pad}{prop}: {accepts}'
|
| 1609 |
+
|
| 1610 |
+
lines = []
|
| 1611 |
+
for prop in sorted(self.get_setters()):
|
| 1612 |
+
accepts = self.get_valid_values(prop)
|
| 1613 |
+
name = self.aliased_name(prop)
|
| 1614 |
+
lines.append(f'{pad}{name}: {accepts}')
|
| 1615 |
+
return lines
|
| 1616 |
+
|
| 1617 |
+
def pprint_setters_rest(self, prop=None, leadingspace=4):
|
| 1618 |
+
"""
|
| 1619 |
+
If *prop* is *None*, return a list of reST-formatted strings of all
|
| 1620 |
+
settable properties and their valid values.
|
| 1621 |
+
|
| 1622 |
+
If *prop* is not *None*, it is a valid property name and that
|
| 1623 |
+
property will be returned as a string of "property : valid"
|
| 1624 |
+
values.
|
| 1625 |
+
"""
|
| 1626 |
+
if leadingspace:
|
| 1627 |
+
pad = ' ' * leadingspace
|
| 1628 |
+
else:
|
| 1629 |
+
pad = ''
|
| 1630 |
+
if prop is not None:
|
| 1631 |
+
accepts = self.get_valid_values(prop)
|
| 1632 |
+
return f'{pad}{prop}: {accepts}'
|
| 1633 |
+
|
| 1634 |
+
prop_and_qualnames = []
|
| 1635 |
+
for prop in sorted(self.get_setters()):
|
| 1636 |
+
# Find the parent method which actually provides the docstring.
|
| 1637 |
+
for cls in self.o.__mro__:
|
| 1638 |
+
method = getattr(cls, f"set_{prop}", None)
|
| 1639 |
+
if method and method.__doc__ is not None:
|
| 1640 |
+
break
|
| 1641 |
+
else: # No docstring available.
|
| 1642 |
+
method = getattr(self.o, f"set_{prop}")
|
| 1643 |
+
prop_and_qualnames.append(
|
| 1644 |
+
(prop, f"{method.__module__}.{method.__qualname__}"))
|
| 1645 |
+
|
| 1646 |
+
names = [self.aliased_name_rest(prop, target)
|
| 1647 |
+
.replace('_base._AxesBase', 'Axes')
|
| 1648 |
+
.replace('_axes.Axes', 'Axes')
|
| 1649 |
+
for prop, target in prop_and_qualnames]
|
| 1650 |
+
accepts = [self.get_valid_values(prop)
|
| 1651 |
+
for prop, _ in prop_and_qualnames]
|
| 1652 |
+
|
| 1653 |
+
col0_len = max(len(n) for n in names)
|
| 1654 |
+
col1_len = max(len(a) for a in accepts)
|
| 1655 |
+
table_formatstr = pad + ' ' + '=' * col0_len + ' ' + '=' * col1_len
|
| 1656 |
+
|
| 1657 |
+
return [
|
| 1658 |
+
'',
|
| 1659 |
+
pad + '.. table::',
|
| 1660 |
+
pad + ' :class: property-table',
|
| 1661 |
+
'',
|
| 1662 |
+
table_formatstr,
|
| 1663 |
+
pad + ' ' + 'Property'.ljust(col0_len)
|
| 1664 |
+
+ ' ' + 'Description'.ljust(col1_len),
|
| 1665 |
+
table_formatstr,
|
| 1666 |
+
*[pad + ' ' + n.ljust(col0_len) + ' ' + a.ljust(col1_len)
|
| 1667 |
+
for n, a in zip(names, accepts)],
|
| 1668 |
+
table_formatstr,
|
| 1669 |
+
'',
|
| 1670 |
+
]
|
| 1671 |
+
|
| 1672 |
+
def properties(self):
|
| 1673 |
+
"""Return a dictionary mapping property name -> value."""
|
| 1674 |
+
o = self.oorig
|
| 1675 |
+
getters = [name for name in dir(o)
|
| 1676 |
+
if name.startswith('get_') and callable(getattr(o, name))]
|
| 1677 |
+
getters.sort()
|
| 1678 |
+
d = {}
|
| 1679 |
+
for name in getters:
|
| 1680 |
+
func = getattr(o, name)
|
| 1681 |
+
if self.is_alias(func):
|
| 1682 |
+
continue
|
| 1683 |
+
try:
|
| 1684 |
+
with warnings.catch_warnings():
|
| 1685 |
+
warnings.simplefilter('ignore')
|
| 1686 |
+
val = func()
|
| 1687 |
+
except Exception:
|
| 1688 |
+
continue
|
| 1689 |
+
else:
|
| 1690 |
+
d[name[4:]] = val
|
| 1691 |
+
return d
|
| 1692 |
+
|
| 1693 |
+
def pprint_getters(self):
|
| 1694 |
+
"""Return the getters and actual values as list of strings."""
|
| 1695 |
+
lines = []
|
| 1696 |
+
for name, val in sorted(self.properties().items()):
|
| 1697 |
+
if getattr(val, 'shape', ()) != () and len(val) > 6:
|
| 1698 |
+
s = str(val[:6]) + '...'
|
| 1699 |
+
else:
|
| 1700 |
+
s = str(val)
|
| 1701 |
+
s = s.replace('\n', ' ')
|
| 1702 |
+
if len(s) > 50:
|
| 1703 |
+
s = s[:50] + '...'
|
| 1704 |
+
name = self.aliased_name(name)
|
| 1705 |
+
lines.append(f' {name} = {s}')
|
| 1706 |
+
return lines
|
| 1707 |
+
|
| 1708 |
+
|
| 1709 |
+
def getp(obj, property=None):
|
| 1710 |
+
"""
|
| 1711 |
+
Return the value of an `.Artist`'s *property*, or print all of them.
|
| 1712 |
+
|
| 1713 |
+
Parameters
|
| 1714 |
+
----------
|
| 1715 |
+
obj : `~matplotlib.artist.Artist`
|
| 1716 |
+
The queried artist; e.g., a `.Line2D`, a `.Text`, or an `~.axes.Axes`.
|
| 1717 |
+
|
| 1718 |
+
property : str or None, default: None
|
| 1719 |
+
If *property* is 'somename', this function returns
|
| 1720 |
+
``obj.get_somename()``.
|
| 1721 |
+
|
| 1722 |
+
If it's None (or unset), it *prints* all gettable properties from
|
| 1723 |
+
*obj*. Many properties have aliases for shorter typing, e.g. 'lw' is
|
| 1724 |
+
an alias for 'linewidth'. In the output, aliases and full property
|
| 1725 |
+
names will be listed as:
|
| 1726 |
+
|
| 1727 |
+
property or alias = value
|
| 1728 |
+
|
| 1729 |
+
e.g.:
|
| 1730 |
+
|
| 1731 |
+
linewidth or lw = 2
|
| 1732 |
+
|
| 1733 |
+
See Also
|
| 1734 |
+
--------
|
| 1735 |
+
setp
|
| 1736 |
+
"""
|
| 1737 |
+
if property is None:
|
| 1738 |
+
insp = ArtistInspector(obj)
|
| 1739 |
+
ret = insp.pprint_getters()
|
| 1740 |
+
print('\n'.join(ret))
|
| 1741 |
+
return
|
| 1742 |
+
return getattr(obj, 'get_' + property)()
|
| 1743 |
+
|
| 1744 |
+
# alias
|
| 1745 |
+
get = getp
|
| 1746 |
+
|
| 1747 |
+
|
| 1748 |
+
def setp(obj, *args, file=None, **kwargs):
|
| 1749 |
+
"""
|
| 1750 |
+
Set one or more properties on an `.Artist`, or list allowed values.
|
| 1751 |
+
|
| 1752 |
+
Parameters
|
| 1753 |
+
----------
|
| 1754 |
+
obj : `~matplotlib.artist.Artist` or list of `.Artist`
|
| 1755 |
+
The artist(s) whose properties are being set or queried. When setting
|
| 1756 |
+
properties, all artists are affected; when querying the allowed values,
|
| 1757 |
+
only the first instance in the sequence is queried.
|
| 1758 |
+
|
| 1759 |
+
For example, two lines can be made thicker and red with a single call:
|
| 1760 |
+
|
| 1761 |
+
>>> x = arange(0, 1, 0.01)
|
| 1762 |
+
>>> lines = plot(x, sin(2*pi*x), x, sin(4*pi*x))
|
| 1763 |
+
>>> setp(lines, linewidth=2, color='r')
|
| 1764 |
+
|
| 1765 |
+
file : file-like, default: `sys.stdout`
|
| 1766 |
+
Where `setp` writes its output when asked to list allowed values.
|
| 1767 |
+
|
| 1768 |
+
>>> with open('output.log') as file:
|
| 1769 |
+
... setp(line, file=file)
|
| 1770 |
+
|
| 1771 |
+
The default, ``None``, means `sys.stdout`.
|
| 1772 |
+
|
| 1773 |
+
*args, **kwargs
|
| 1774 |
+
The properties to set. The following combinations are supported:
|
| 1775 |
+
|
| 1776 |
+
- Set the linestyle of a line to be dashed:
|
| 1777 |
+
|
| 1778 |
+
>>> line, = plot([1, 2, 3])
|
| 1779 |
+
>>> setp(line, linestyle='--')
|
| 1780 |
+
|
| 1781 |
+
- Set multiple properties at once:
|
| 1782 |
+
|
| 1783 |
+
>>> setp(line, linewidth=2, color='r')
|
| 1784 |
+
|
| 1785 |
+
- List allowed values for a line's linestyle:
|
| 1786 |
+
|
| 1787 |
+
>>> setp(line, 'linestyle')
|
| 1788 |
+
linestyle: {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
|
| 1789 |
+
|
| 1790 |
+
- List all properties that can be set, and their allowed values:
|
| 1791 |
+
|
| 1792 |
+
>>> setp(line)
|
| 1793 |
+
agg_filter: a filter function, ...
|
| 1794 |
+
[long output listing omitted]
|
| 1795 |
+
|
| 1796 |
+
`setp` also supports MATLAB style string/value pairs. For example, the
|
| 1797 |
+
following are equivalent:
|
| 1798 |
+
|
| 1799 |
+
>>> setp(lines, 'linewidth', 2, 'color', 'r') # MATLAB style
|
| 1800 |
+
>>> setp(lines, linewidth=2, color='r') # Python style
|
| 1801 |
+
|
| 1802 |
+
See Also
|
| 1803 |
+
--------
|
| 1804 |
+
getp
|
| 1805 |
+
"""
|
| 1806 |
+
|
| 1807 |
+
if isinstance(obj, Artist):
|
| 1808 |
+
objs = [obj]
|
| 1809 |
+
else:
|
| 1810 |
+
objs = list(cbook.flatten(obj))
|
| 1811 |
+
|
| 1812 |
+
if not objs:
|
| 1813 |
+
return
|
| 1814 |
+
|
| 1815 |
+
insp = ArtistInspector(objs[0])
|
| 1816 |
+
|
| 1817 |
+
if not kwargs and len(args) < 2:
|
| 1818 |
+
if args:
|
| 1819 |
+
print(insp.pprint_setters(prop=args[0]), file=file)
|
| 1820 |
+
else:
|
| 1821 |
+
print('\n'.join(insp.pprint_setters()), file=file)
|
| 1822 |
+
return
|
| 1823 |
+
|
| 1824 |
+
if len(args) % 2:
|
| 1825 |
+
raise ValueError('The set args must be string, value pairs')
|
| 1826 |
+
|
| 1827 |
+
funcvals = dict(zip(args[::2], args[1::2]))
|
| 1828 |
+
ret = [o.update(funcvals) for o in objs] + [o.set(**kwargs) for o in objs]
|
| 1829 |
+
return list(cbook.flatten(ret))
|
| 1830 |
+
|
| 1831 |
+
|
| 1832 |
+
def kwdoc(artist):
|
| 1833 |
+
r"""
|
| 1834 |
+
Inspect an `~matplotlib.artist.Artist` class (using `.ArtistInspector`) and
|
| 1835 |
+
return information about its settable properties and their current values.
|
| 1836 |
+
|
| 1837 |
+
Parameters
|
| 1838 |
+
----------
|
| 1839 |
+
artist : `~matplotlib.artist.Artist` or an iterable of `Artist`\s
|
| 1840 |
+
|
| 1841 |
+
Returns
|
| 1842 |
+
-------
|
| 1843 |
+
str
|
| 1844 |
+
The settable properties of *artist*, as plain text if
|
| 1845 |
+
:rc:`docstring.hardcopy` is False and as a rst table (intended for
|
| 1846 |
+
use in Sphinx) if it is True.
|
| 1847 |
+
"""
|
| 1848 |
+
ai = ArtistInspector(artist)
|
| 1849 |
+
return ('\n'.join(ai.pprint_setters_rest(leadingspace=4))
|
| 1850 |
+
if mpl.rcParams['docstring.hardcopy'] else
|
| 1851 |
+
'Properties:\n' + '\n'.join(ai.pprint_setters(leadingspace=4)))
|
| 1852 |
+
|
| 1853 |
+
# We defer this to the end of them module, because it needs ArtistInspector
|
| 1854 |
+
# to be defined.
|
| 1855 |
+
Artist._update_set_signature_and_docstring()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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/backend_bases.pyi
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from enum import Enum, IntEnum
|
| 2 |
+
import os
|
| 3 |
+
from matplotlib import (
|
| 4 |
+
cbook,
|
| 5 |
+
transforms,
|
| 6 |
+
widgets,
|
| 7 |
+
_api,
|
| 8 |
+
)
|
| 9 |
+
from matplotlib.artist import Artist
|
| 10 |
+
from matplotlib.axes import Axes
|
| 11 |
+
from matplotlib.backend_managers import ToolManager
|
| 12 |
+
from matplotlib.backend_tools import Cursors, ToolBase
|
| 13 |
+
from matplotlib.colorbar import Colorbar
|
| 14 |
+
from matplotlib.figure import Figure
|
| 15 |
+
from matplotlib.font_manager import FontProperties
|
| 16 |
+
from matplotlib.path import Path
|
| 17 |
+
from matplotlib.texmanager import TexManager
|
| 18 |
+
from matplotlib.text import Text
|
| 19 |
+
from matplotlib.transforms import Bbox, BboxBase, Transform, TransformedPath
|
| 20 |
+
|
| 21 |
+
from collections.abc import Callable, Iterable, Sequence
|
| 22 |
+
from typing import Any, IO, Literal, NamedTuple, TypeVar
|
| 23 |
+
from numpy.typing import ArrayLike
|
| 24 |
+
from .typing import ColorType, LineStyleType, CapStyleType, JoinStyleType
|
| 25 |
+
|
| 26 |
+
def register_backend(
|
| 27 |
+
format: str, backend: str | type[FigureCanvasBase], description: str | None = ...
|
| 28 |
+
) -> None: ...
|
| 29 |
+
def get_registered_canvas_class(format: str) -> type[FigureCanvasBase]: ...
|
| 30 |
+
|
| 31 |
+
class RendererBase:
|
| 32 |
+
def __init__(self) -> None: ...
|
| 33 |
+
def open_group(self, s: str, gid: str | None = ...) -> None: ...
|
| 34 |
+
def close_group(self, s: str) -> None: ...
|
| 35 |
+
def draw_path(
|
| 36 |
+
self,
|
| 37 |
+
gc: GraphicsContextBase,
|
| 38 |
+
path: Path,
|
| 39 |
+
transform: Transform,
|
| 40 |
+
rgbFace: ColorType | None = ...,
|
| 41 |
+
) -> None: ...
|
| 42 |
+
def draw_markers(
|
| 43 |
+
self,
|
| 44 |
+
gc: GraphicsContextBase,
|
| 45 |
+
marker_path: Path,
|
| 46 |
+
marker_trans: Transform,
|
| 47 |
+
path: Path,
|
| 48 |
+
trans: Transform,
|
| 49 |
+
rgbFace: ColorType | None = ...,
|
| 50 |
+
) -> None: ...
|
| 51 |
+
def draw_path_collection(
|
| 52 |
+
self,
|
| 53 |
+
gc: GraphicsContextBase,
|
| 54 |
+
master_transform: Transform,
|
| 55 |
+
paths: Sequence[Path],
|
| 56 |
+
all_transforms: Sequence[ArrayLike],
|
| 57 |
+
offsets: ArrayLike | Sequence[ArrayLike],
|
| 58 |
+
offset_trans: Transform,
|
| 59 |
+
facecolors: ColorType | Sequence[ColorType],
|
| 60 |
+
edgecolors: ColorType | Sequence[ColorType],
|
| 61 |
+
linewidths: float | Sequence[float],
|
| 62 |
+
linestyles: LineStyleType | Sequence[LineStyleType],
|
| 63 |
+
antialiaseds: bool | Sequence[bool],
|
| 64 |
+
urls: str | Sequence[str],
|
| 65 |
+
offset_position: Any,
|
| 66 |
+
) -> None: ...
|
| 67 |
+
def draw_quad_mesh(
|
| 68 |
+
self,
|
| 69 |
+
gc: GraphicsContextBase,
|
| 70 |
+
master_transform: Transform,
|
| 71 |
+
meshWidth,
|
| 72 |
+
meshHeight,
|
| 73 |
+
coordinates: ArrayLike,
|
| 74 |
+
offsets: ArrayLike | Sequence[ArrayLike],
|
| 75 |
+
offsetTrans: Transform,
|
| 76 |
+
facecolors: Sequence[ColorType],
|
| 77 |
+
antialiased: bool,
|
| 78 |
+
edgecolors: Sequence[ColorType] | ColorType | None,
|
| 79 |
+
) -> None: ...
|
| 80 |
+
def draw_gouraud_triangles(
|
| 81 |
+
self,
|
| 82 |
+
gc: GraphicsContextBase,
|
| 83 |
+
triangles_array: ArrayLike,
|
| 84 |
+
colors_array: ArrayLike,
|
| 85 |
+
transform: Transform,
|
| 86 |
+
) -> None: ...
|
| 87 |
+
def get_image_magnification(self) -> float: ...
|
| 88 |
+
def draw_image(
|
| 89 |
+
self,
|
| 90 |
+
gc: GraphicsContextBase,
|
| 91 |
+
x: float,
|
| 92 |
+
y: float,
|
| 93 |
+
im: ArrayLike,
|
| 94 |
+
transform: transforms.Affine2DBase | None = ...,
|
| 95 |
+
) -> None: ...
|
| 96 |
+
def option_image_nocomposite(self) -> bool: ...
|
| 97 |
+
def option_scale_image(self) -> bool: ...
|
| 98 |
+
def draw_tex(
|
| 99 |
+
self,
|
| 100 |
+
gc: GraphicsContextBase,
|
| 101 |
+
x: float,
|
| 102 |
+
y: float,
|
| 103 |
+
s: str,
|
| 104 |
+
prop: FontProperties,
|
| 105 |
+
angle: float,
|
| 106 |
+
*,
|
| 107 |
+
mtext: Text | None = ...
|
| 108 |
+
) -> None: ...
|
| 109 |
+
def draw_text(
|
| 110 |
+
self,
|
| 111 |
+
gc: GraphicsContextBase,
|
| 112 |
+
x: float,
|
| 113 |
+
y: float,
|
| 114 |
+
s: str,
|
| 115 |
+
prop: FontProperties,
|
| 116 |
+
angle: float,
|
| 117 |
+
ismath: bool | Literal["TeX"] = ...,
|
| 118 |
+
mtext: Text | None = ...,
|
| 119 |
+
) -> None: ...
|
| 120 |
+
def get_text_width_height_descent(
|
| 121 |
+
self, s: str, prop: FontProperties, ismath: bool | Literal["TeX"]
|
| 122 |
+
) -> tuple[float, float, float]: ...
|
| 123 |
+
def flipy(self) -> bool: ...
|
| 124 |
+
def get_canvas_width_height(self) -> tuple[float, float]: ...
|
| 125 |
+
def get_texmanager(self) -> TexManager: ...
|
| 126 |
+
def new_gc(self) -> GraphicsContextBase: ...
|
| 127 |
+
def points_to_pixels(self, points: ArrayLike) -> ArrayLike: ...
|
| 128 |
+
def start_rasterizing(self) -> None: ...
|
| 129 |
+
def stop_rasterizing(self) -> None: ...
|
| 130 |
+
def start_filter(self) -> None: ...
|
| 131 |
+
def stop_filter(self, filter_func) -> None: ...
|
| 132 |
+
|
| 133 |
+
class GraphicsContextBase:
|
| 134 |
+
def __init__(self) -> None: ...
|
| 135 |
+
def copy_properties(self, gc: GraphicsContextBase) -> None: ...
|
| 136 |
+
def restore(self) -> None: ...
|
| 137 |
+
def get_alpha(self) -> float: ...
|
| 138 |
+
def get_antialiased(self) -> int: ...
|
| 139 |
+
def get_capstyle(self) -> Literal["butt", "projecting", "round"]: ...
|
| 140 |
+
def get_clip_rectangle(self) -> Bbox | None: ...
|
| 141 |
+
def get_clip_path(
|
| 142 |
+
self,
|
| 143 |
+
) -> tuple[TransformedPath, Transform] | tuple[None, None]: ...
|
| 144 |
+
def get_dashes(self) -> tuple[float, ArrayLike | None]: ...
|
| 145 |
+
def get_forced_alpha(self) -> bool: ...
|
| 146 |
+
def get_joinstyle(self) -> Literal["miter", "round", "bevel"]: ...
|
| 147 |
+
def get_linewidth(self) -> float: ...
|
| 148 |
+
def get_rgb(self) -> tuple[float, float, float, float]: ...
|
| 149 |
+
def get_url(self) -> str | None: ...
|
| 150 |
+
def get_gid(self) -> int | None: ...
|
| 151 |
+
def get_snap(self) -> bool | None: ...
|
| 152 |
+
def set_alpha(self, alpha: float) -> None: ...
|
| 153 |
+
def set_antialiased(self, b: bool) -> None: ...
|
| 154 |
+
def set_capstyle(self, cs: CapStyleType) -> None: ...
|
| 155 |
+
def set_clip_rectangle(self, rectangle: Bbox | None) -> None: ...
|
| 156 |
+
def set_clip_path(self, path: TransformedPath | None) -> None: ...
|
| 157 |
+
def set_dashes(self, dash_offset: float, dash_list: ArrayLike | None) -> None: ...
|
| 158 |
+
def set_foreground(self, fg: ColorType, isRGBA: bool = ...) -> None: ...
|
| 159 |
+
def set_joinstyle(self, js: JoinStyleType) -> None: ...
|
| 160 |
+
def set_linewidth(self, w: float) -> None: ...
|
| 161 |
+
def set_url(self, url: str | None) -> None: ...
|
| 162 |
+
def set_gid(self, id: int | None) -> None: ...
|
| 163 |
+
def set_snap(self, snap: bool | None) -> None: ...
|
| 164 |
+
def set_hatch(self, hatch: str | None) -> None: ...
|
| 165 |
+
def get_hatch(self) -> str | None: ...
|
| 166 |
+
def get_hatch_path(self, density: float = ...) -> Path: ...
|
| 167 |
+
def get_hatch_color(self) -> ColorType: ...
|
| 168 |
+
def set_hatch_color(self, hatch_color: ColorType) -> None: ...
|
| 169 |
+
def get_hatch_linewidth(self) -> float: ...
|
| 170 |
+
def set_hatch_linewidth(self, hatch_linewidth: float) -> None: ...
|
| 171 |
+
def get_sketch_params(self) -> tuple[float, float, float] | None: ...
|
| 172 |
+
def set_sketch_params(
|
| 173 |
+
self,
|
| 174 |
+
scale: float | None = ...,
|
| 175 |
+
length: float | None = ...,
|
| 176 |
+
randomness: float | None = ...,
|
| 177 |
+
) -> None: ...
|
| 178 |
+
|
| 179 |
+
class TimerBase:
|
| 180 |
+
callbacks: list[tuple[Callable, tuple, dict[str, Any]]]
|
| 181 |
+
def __init__(
|
| 182 |
+
self,
|
| 183 |
+
interval: int | None = ...,
|
| 184 |
+
callbacks: list[tuple[Callable, tuple, dict[str, Any]]] | None = ...,
|
| 185 |
+
) -> None: ...
|
| 186 |
+
def __del__(self) -> None: ...
|
| 187 |
+
def start(self, interval: int | None = ...) -> None: ...
|
| 188 |
+
def stop(self) -> None: ...
|
| 189 |
+
@property
|
| 190 |
+
def interval(self) -> int: ...
|
| 191 |
+
@interval.setter
|
| 192 |
+
def interval(self, interval: int) -> None: ...
|
| 193 |
+
@property
|
| 194 |
+
def single_shot(self) -> bool: ...
|
| 195 |
+
@single_shot.setter
|
| 196 |
+
def single_shot(self, ss: bool) -> None: ...
|
| 197 |
+
def add_callback(self, func: Callable, *args, **kwargs) -> Callable: ...
|
| 198 |
+
def remove_callback(self, func: Callable, *args, **kwargs) -> None: ...
|
| 199 |
+
|
| 200 |
+
class Event:
|
| 201 |
+
name: str
|
| 202 |
+
canvas: FigureCanvasBase
|
| 203 |
+
guiEvent: Any
|
| 204 |
+
def __init__(
|
| 205 |
+
self, name: str, canvas: FigureCanvasBase, guiEvent: Any | None = ...
|
| 206 |
+
) -> None: ...
|
| 207 |
+
|
| 208 |
+
class DrawEvent(Event):
|
| 209 |
+
renderer: RendererBase
|
| 210 |
+
def __init__(
|
| 211 |
+
self, name: str, canvas: FigureCanvasBase, renderer: RendererBase
|
| 212 |
+
) -> None: ...
|
| 213 |
+
|
| 214 |
+
class ResizeEvent(Event):
|
| 215 |
+
width: int
|
| 216 |
+
height: int
|
| 217 |
+
def __init__(self, name: str, canvas: FigureCanvasBase) -> None: ...
|
| 218 |
+
|
| 219 |
+
class CloseEvent(Event): ...
|
| 220 |
+
|
| 221 |
+
class LocationEvent(Event):
|
| 222 |
+
x: int
|
| 223 |
+
y: int
|
| 224 |
+
inaxes: Axes | None
|
| 225 |
+
xdata: float | None
|
| 226 |
+
ydata: float | None
|
| 227 |
+
def __init__(
|
| 228 |
+
self,
|
| 229 |
+
name: str,
|
| 230 |
+
canvas: FigureCanvasBase,
|
| 231 |
+
x: int,
|
| 232 |
+
y: int,
|
| 233 |
+
guiEvent: Any | None = ...,
|
| 234 |
+
*,
|
| 235 |
+
modifiers: Iterable[str] | None = ...,
|
| 236 |
+
) -> None: ...
|
| 237 |
+
|
| 238 |
+
class MouseButton(IntEnum):
|
| 239 |
+
LEFT = 1
|
| 240 |
+
MIDDLE = 2
|
| 241 |
+
RIGHT = 3
|
| 242 |
+
BACK = 8
|
| 243 |
+
FORWARD = 9
|
| 244 |
+
|
| 245 |
+
class MouseEvent(LocationEvent):
|
| 246 |
+
button: MouseButton | Literal["up", "down"] | None
|
| 247 |
+
key: str | None
|
| 248 |
+
step: float
|
| 249 |
+
dblclick: bool
|
| 250 |
+
def __init__(
|
| 251 |
+
self,
|
| 252 |
+
name: str,
|
| 253 |
+
canvas: FigureCanvasBase,
|
| 254 |
+
x: int,
|
| 255 |
+
y: int,
|
| 256 |
+
button: MouseButton | Literal["up", "down"] | None = ...,
|
| 257 |
+
key: str | None = ...,
|
| 258 |
+
step: float = ...,
|
| 259 |
+
dblclick: bool = ...,
|
| 260 |
+
guiEvent: Any | None = ...,
|
| 261 |
+
*,
|
| 262 |
+
buttons: Iterable[MouseButton] | None = ...,
|
| 263 |
+
modifiers: Iterable[str] | None = ...,
|
| 264 |
+
) -> None: ...
|
| 265 |
+
|
| 266 |
+
class PickEvent(Event):
|
| 267 |
+
mouseevent: MouseEvent
|
| 268 |
+
artist: Artist
|
| 269 |
+
def __init__(
|
| 270 |
+
self,
|
| 271 |
+
name: str,
|
| 272 |
+
canvas: FigureCanvasBase,
|
| 273 |
+
mouseevent: MouseEvent,
|
| 274 |
+
artist: Artist,
|
| 275 |
+
guiEvent: Any | None = ...,
|
| 276 |
+
**kwargs
|
| 277 |
+
) -> None: ...
|
| 278 |
+
|
| 279 |
+
class KeyEvent(LocationEvent):
|
| 280 |
+
key: str | None
|
| 281 |
+
def __init__(
|
| 282 |
+
self,
|
| 283 |
+
name: str,
|
| 284 |
+
canvas: FigureCanvasBase,
|
| 285 |
+
key: str | None,
|
| 286 |
+
x: int = ...,
|
| 287 |
+
y: int = ...,
|
| 288 |
+
guiEvent: Any | None = ...,
|
| 289 |
+
) -> None: ...
|
| 290 |
+
|
| 291 |
+
class FigureCanvasBase:
|
| 292 |
+
required_interactive_framework: str | None
|
| 293 |
+
|
| 294 |
+
@_api.classproperty
|
| 295 |
+
def manager_class(cls) -> type[FigureManagerBase]: ...
|
| 296 |
+
events: list[str]
|
| 297 |
+
fixed_dpi: None | float
|
| 298 |
+
filetypes: dict[str, str]
|
| 299 |
+
|
| 300 |
+
@_api.classproperty
|
| 301 |
+
def supports_blit(cls) -> bool: ...
|
| 302 |
+
|
| 303 |
+
figure: Figure
|
| 304 |
+
manager: None | FigureManagerBase
|
| 305 |
+
widgetlock: widgets.LockDraw
|
| 306 |
+
mouse_grabber: None | Axes
|
| 307 |
+
toolbar: None | NavigationToolbar2
|
| 308 |
+
def __init__(self, figure: Figure | None = ...) -> None: ...
|
| 309 |
+
@property
|
| 310 |
+
def callbacks(self) -> cbook.CallbackRegistry: ...
|
| 311 |
+
@property
|
| 312 |
+
def button_pick_id(self) -> int: ...
|
| 313 |
+
@property
|
| 314 |
+
def scroll_pick_id(self) -> int: ...
|
| 315 |
+
@classmethod
|
| 316 |
+
def new_manager(cls, figure: Figure, num: int | str) -> FigureManagerBase: ...
|
| 317 |
+
def is_saving(self) -> bool: ...
|
| 318 |
+
def blit(self, bbox: BboxBase | None = ...) -> None: ...
|
| 319 |
+
def inaxes(self, xy: tuple[float, float]) -> Axes | None: ...
|
| 320 |
+
def grab_mouse(self, ax: Axes) -> None: ...
|
| 321 |
+
def release_mouse(self, ax: Axes) -> None: ...
|
| 322 |
+
def set_cursor(self, cursor: Cursors) -> None: ...
|
| 323 |
+
def draw(self, *args, **kwargs) -> None: ...
|
| 324 |
+
def draw_idle(self, *args, **kwargs) -> None: ...
|
| 325 |
+
@property
|
| 326 |
+
def device_pixel_ratio(self) -> float: ...
|
| 327 |
+
def get_width_height(self, *, physical: bool = ...) -> tuple[int, int]: ...
|
| 328 |
+
@classmethod
|
| 329 |
+
def get_supported_filetypes(cls) -> dict[str, str]: ...
|
| 330 |
+
@classmethod
|
| 331 |
+
def get_supported_filetypes_grouped(cls) -> dict[str, list[str]]: ...
|
| 332 |
+
def print_figure(
|
| 333 |
+
self,
|
| 334 |
+
filename: str | os.PathLike | IO,
|
| 335 |
+
dpi: float | None = ...,
|
| 336 |
+
facecolor: ColorType | Literal["auto"] | None = ...,
|
| 337 |
+
edgecolor: ColorType | Literal["auto"] | None = ...,
|
| 338 |
+
orientation: str = ...,
|
| 339 |
+
format: str | None = ...,
|
| 340 |
+
*,
|
| 341 |
+
bbox_inches: Literal["tight"] | Bbox | None = ...,
|
| 342 |
+
pad_inches: float | None = ...,
|
| 343 |
+
bbox_extra_artists: list[Artist] | None = ...,
|
| 344 |
+
backend: str | None = ...,
|
| 345 |
+
**kwargs
|
| 346 |
+
) -> Any: ...
|
| 347 |
+
@classmethod
|
| 348 |
+
def get_default_filetype(cls) -> str: ...
|
| 349 |
+
def get_default_filename(self) -> str: ...
|
| 350 |
+
_T = TypeVar("_T", bound=FigureCanvasBase)
|
| 351 |
+
def mpl_connect(self, s: str, func: Callable[[Event], Any]) -> int: ...
|
| 352 |
+
def mpl_disconnect(self, cid: int) -> None: ...
|
| 353 |
+
def new_timer(
|
| 354 |
+
self,
|
| 355 |
+
interval: int | None = ...,
|
| 356 |
+
callbacks: list[tuple[Callable, tuple, dict[str, Any]]] | None = ...,
|
| 357 |
+
) -> TimerBase: ...
|
| 358 |
+
def flush_events(self) -> None: ...
|
| 359 |
+
def start_event_loop(self, timeout: float = ...) -> None: ...
|
| 360 |
+
def stop_event_loop(self) -> None: ...
|
| 361 |
+
|
| 362 |
+
def key_press_handler(
|
| 363 |
+
event: KeyEvent,
|
| 364 |
+
canvas: FigureCanvasBase | None = ...,
|
| 365 |
+
toolbar: NavigationToolbar2 | None = ...,
|
| 366 |
+
) -> None: ...
|
| 367 |
+
def button_press_handler(
|
| 368 |
+
event: MouseEvent,
|
| 369 |
+
canvas: FigureCanvasBase | None = ...,
|
| 370 |
+
toolbar: NavigationToolbar2 | None = ...,
|
| 371 |
+
) -> None: ...
|
| 372 |
+
|
| 373 |
+
class NonGuiException(Exception): ...
|
| 374 |
+
|
| 375 |
+
class FigureManagerBase:
|
| 376 |
+
canvas: FigureCanvasBase
|
| 377 |
+
num: int | str
|
| 378 |
+
key_press_handler_id: int | None
|
| 379 |
+
button_press_handler_id: int | None
|
| 380 |
+
toolmanager: ToolManager | None
|
| 381 |
+
toolbar: NavigationToolbar2 | ToolContainerBase | None
|
| 382 |
+
def __init__(self, canvas: FigureCanvasBase, num: int | str) -> None: ...
|
| 383 |
+
@classmethod
|
| 384 |
+
def create_with_canvas(
|
| 385 |
+
cls, canvas_class: type[FigureCanvasBase], figure: Figure, num: int | str
|
| 386 |
+
) -> FigureManagerBase: ...
|
| 387 |
+
@classmethod
|
| 388 |
+
def start_main_loop(cls) -> None: ...
|
| 389 |
+
@classmethod
|
| 390 |
+
def pyplot_show(cls, *, block: bool | None = ...) -> None: ...
|
| 391 |
+
def show(self) -> None: ...
|
| 392 |
+
def destroy(self) -> None: ...
|
| 393 |
+
def full_screen_toggle(self) -> None: ...
|
| 394 |
+
def resize(self, w: int, h: int) -> None: ...
|
| 395 |
+
def get_window_title(self) -> str: ...
|
| 396 |
+
def set_window_title(self, title: str) -> None: ...
|
| 397 |
+
|
| 398 |
+
cursors = Cursors
|
| 399 |
+
|
| 400 |
+
class _Mode(str, Enum):
|
| 401 |
+
NONE = ""
|
| 402 |
+
PAN = "pan/zoom"
|
| 403 |
+
ZOOM = "zoom rect"
|
| 404 |
+
|
| 405 |
+
class NavigationToolbar2:
|
| 406 |
+
toolitems: tuple[tuple[str, ...] | tuple[None, ...], ...]
|
| 407 |
+
UNKNOWN_SAVED_STATUS: object
|
| 408 |
+
canvas: FigureCanvasBase
|
| 409 |
+
mode: _Mode
|
| 410 |
+
def __init__(self, canvas: FigureCanvasBase) -> None: ...
|
| 411 |
+
def set_message(self, s: str) -> None: ...
|
| 412 |
+
def draw_rubberband(
|
| 413 |
+
self, event: Event, x0: float, y0: float, x1: float, y1: float
|
| 414 |
+
) -> None: ...
|
| 415 |
+
def remove_rubberband(self) -> None: ...
|
| 416 |
+
def home(self, *args) -> None: ...
|
| 417 |
+
def back(self, *args) -> None: ...
|
| 418 |
+
def forward(self, *args) -> None: ...
|
| 419 |
+
def mouse_move(self, event: MouseEvent) -> None: ...
|
| 420 |
+
def pan(self, *args) -> None: ...
|
| 421 |
+
|
| 422 |
+
class _PanInfo(NamedTuple):
|
| 423 |
+
button: MouseButton
|
| 424 |
+
axes: list[Axes]
|
| 425 |
+
cid: int
|
| 426 |
+
def press_pan(self, event: Event) -> None: ...
|
| 427 |
+
def drag_pan(self, event: Event) -> None: ...
|
| 428 |
+
def release_pan(self, event: Event) -> None: ...
|
| 429 |
+
def zoom(self, *args) -> None: ...
|
| 430 |
+
|
| 431 |
+
class _ZoomInfo(NamedTuple):
|
| 432 |
+
direction: Literal["in", "out"]
|
| 433 |
+
start_xy: tuple[float, float]
|
| 434 |
+
axes: list[Axes]
|
| 435 |
+
cid: int
|
| 436 |
+
cbar: Colorbar
|
| 437 |
+
def press_zoom(self, event: Event) -> None: ...
|
| 438 |
+
def drag_zoom(self, event: Event) -> None: ...
|
| 439 |
+
def release_zoom(self, event: Event) -> None: ...
|
| 440 |
+
def push_current(self) -> None: ...
|
| 441 |
+
subplot_tool: widgets.SubplotTool
|
| 442 |
+
def configure_subplots(self, *args): ...
|
| 443 |
+
def save_figure(self, *args) -> str | None | object: ...
|
| 444 |
+
def update(self) -> None: ...
|
| 445 |
+
def set_history_buttons(self) -> None: ...
|
| 446 |
+
|
| 447 |
+
class ToolContainerBase:
|
| 448 |
+
toolmanager: ToolManager
|
| 449 |
+
def __init__(self, toolmanager: ToolManager) -> None: ...
|
| 450 |
+
def add_tool(self, tool: ToolBase, group: str, position: int = ...) -> None: ...
|
| 451 |
+
def trigger_tool(self, name: str) -> None: ...
|
| 452 |
+
def add_toolitem(
|
| 453 |
+
self,
|
| 454 |
+
name: str,
|
| 455 |
+
group: str,
|
| 456 |
+
position: int,
|
| 457 |
+
image: str,
|
| 458 |
+
description: str,
|
| 459 |
+
toggle: bool,
|
| 460 |
+
) -> None: ...
|
| 461 |
+
def toggle_toolitem(self, name: str, toggled: bool) -> None: ...
|
| 462 |
+
def remove_toolitem(self, name: str) -> None: ...
|
| 463 |
+
def set_message(self, s: str) -> None: ...
|
| 464 |
+
|
| 465 |
+
class _Backend:
|
| 466 |
+
backend_version: str
|
| 467 |
+
FigureCanvas: type[FigureCanvasBase] | None
|
| 468 |
+
FigureManager: type[FigureManagerBase]
|
| 469 |
+
mainloop: None | Callable[[], Any]
|
| 470 |
+
@classmethod
|
| 471 |
+
def new_figure_manager(cls, num: int | str, *args, **kwargs) -> FigureManagerBase: ...
|
| 472 |
+
@classmethod
|
| 473 |
+
def new_figure_manager_given_figure(cls, num: int | str, figure: Figure) -> FigureManagerBase: ...
|
| 474 |
+
@classmethod
|
| 475 |
+
def draw_if_interactive(cls) -> None: ...
|
| 476 |
+
@classmethod
|
| 477 |
+
def show(cls, *, block: bool | None = ...) -> None: ...
|
| 478 |
+
@staticmethod
|
| 479 |
+
def export(cls) -> type[_Backend]: ...
|
| 480 |
+
|
| 481 |
+
class ShowBase(_Backend):
|
| 482 |
+
def __call__(self, block: bool | None = ...) -> None: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/backend_managers.py
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from matplotlib import _api, backend_tools, cbook, widgets
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class ToolEvent:
|
| 5 |
+
"""Event for tool manipulation (add/remove)."""
|
| 6 |
+
def __init__(self, name, sender, tool, data=None):
|
| 7 |
+
self.name = name
|
| 8 |
+
self.sender = sender
|
| 9 |
+
self.tool = tool
|
| 10 |
+
self.data = data
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class ToolTriggerEvent(ToolEvent):
|
| 14 |
+
"""Event to inform that a tool has been triggered."""
|
| 15 |
+
def __init__(self, name, sender, tool, canvasevent=None, data=None):
|
| 16 |
+
super().__init__(name, sender, tool, data)
|
| 17 |
+
self.canvasevent = canvasevent
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class ToolManagerMessageEvent:
|
| 21 |
+
"""
|
| 22 |
+
Event carrying messages from toolmanager.
|
| 23 |
+
|
| 24 |
+
Messages usually get displayed to the user by the toolbar.
|
| 25 |
+
"""
|
| 26 |
+
def __init__(self, name, sender, message):
|
| 27 |
+
self.name = name
|
| 28 |
+
self.sender = sender
|
| 29 |
+
self.message = message
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class ToolManager:
|
| 33 |
+
"""
|
| 34 |
+
Manager for actions triggered by user interactions (key press, toolbar
|
| 35 |
+
clicks, ...) on a Figure.
|
| 36 |
+
|
| 37 |
+
Attributes
|
| 38 |
+
----------
|
| 39 |
+
figure : `.Figure`
|
| 40 |
+
keypresslock : `~matplotlib.widgets.LockDraw`
|
| 41 |
+
`.LockDraw` object to know if the `canvas` key_press_event is locked.
|
| 42 |
+
messagelock : `~matplotlib.widgets.LockDraw`
|
| 43 |
+
`.LockDraw` object to know if the message is available to write.
|
| 44 |
+
"""
|
| 45 |
+
|
| 46 |
+
def __init__(self, figure=None):
|
| 47 |
+
|
| 48 |
+
self._key_press_handler_id = None
|
| 49 |
+
|
| 50 |
+
self._tools = {}
|
| 51 |
+
self._keys = {}
|
| 52 |
+
self._toggled = {}
|
| 53 |
+
self._callbacks = cbook.CallbackRegistry()
|
| 54 |
+
|
| 55 |
+
# to process keypress event
|
| 56 |
+
self.keypresslock = widgets.LockDraw()
|
| 57 |
+
self.messagelock = widgets.LockDraw()
|
| 58 |
+
|
| 59 |
+
self._figure = None
|
| 60 |
+
self.set_figure(figure)
|
| 61 |
+
|
| 62 |
+
@property
|
| 63 |
+
def canvas(self):
|
| 64 |
+
"""Canvas managed by FigureManager."""
|
| 65 |
+
if not self._figure:
|
| 66 |
+
return None
|
| 67 |
+
return self._figure.canvas
|
| 68 |
+
|
| 69 |
+
@property
|
| 70 |
+
def figure(self):
|
| 71 |
+
"""Figure that holds the canvas."""
|
| 72 |
+
return self._figure
|
| 73 |
+
|
| 74 |
+
@figure.setter
|
| 75 |
+
def figure(self, figure):
|
| 76 |
+
self.set_figure(figure)
|
| 77 |
+
|
| 78 |
+
def set_figure(self, figure, update_tools=True):
|
| 79 |
+
"""
|
| 80 |
+
Bind the given figure to the tools.
|
| 81 |
+
|
| 82 |
+
Parameters
|
| 83 |
+
----------
|
| 84 |
+
figure : `.Figure`
|
| 85 |
+
update_tools : bool, default: True
|
| 86 |
+
Force tools to update figure.
|
| 87 |
+
"""
|
| 88 |
+
if self._key_press_handler_id:
|
| 89 |
+
self.canvas.mpl_disconnect(self._key_press_handler_id)
|
| 90 |
+
self._figure = figure
|
| 91 |
+
if figure:
|
| 92 |
+
self._key_press_handler_id = self.canvas.mpl_connect(
|
| 93 |
+
'key_press_event', self._key_press)
|
| 94 |
+
if update_tools:
|
| 95 |
+
for tool in self._tools.values():
|
| 96 |
+
tool.figure = figure
|
| 97 |
+
|
| 98 |
+
def toolmanager_connect(self, s, func):
|
| 99 |
+
"""
|
| 100 |
+
Connect event with string *s* to *func*.
|
| 101 |
+
|
| 102 |
+
Parameters
|
| 103 |
+
----------
|
| 104 |
+
s : str
|
| 105 |
+
The name of the event. The following events are recognized:
|
| 106 |
+
|
| 107 |
+
- 'tool_message_event'
|
| 108 |
+
- 'tool_removed_event'
|
| 109 |
+
- 'tool_added_event'
|
| 110 |
+
|
| 111 |
+
For every tool added a new event is created
|
| 112 |
+
|
| 113 |
+
- 'tool_trigger_TOOLNAME', where TOOLNAME is the id of the tool.
|
| 114 |
+
|
| 115 |
+
func : callable
|
| 116 |
+
Callback function for the toolmanager event with signature::
|
| 117 |
+
|
| 118 |
+
def func(event: ToolEvent) -> Any
|
| 119 |
+
|
| 120 |
+
Returns
|
| 121 |
+
-------
|
| 122 |
+
cid
|
| 123 |
+
The callback id for the connection. This can be used in
|
| 124 |
+
`.toolmanager_disconnect`.
|
| 125 |
+
"""
|
| 126 |
+
return self._callbacks.connect(s, func)
|
| 127 |
+
|
| 128 |
+
def toolmanager_disconnect(self, cid):
|
| 129 |
+
"""
|
| 130 |
+
Disconnect callback id *cid*.
|
| 131 |
+
|
| 132 |
+
Example usage::
|
| 133 |
+
|
| 134 |
+
cid = toolmanager.toolmanager_connect('tool_trigger_zoom', onpress)
|
| 135 |
+
#...later
|
| 136 |
+
toolmanager.toolmanager_disconnect(cid)
|
| 137 |
+
"""
|
| 138 |
+
return self._callbacks.disconnect(cid)
|
| 139 |
+
|
| 140 |
+
def message_event(self, message, sender=None):
|
| 141 |
+
"""Emit a `ToolManagerMessageEvent`."""
|
| 142 |
+
if sender is None:
|
| 143 |
+
sender = self
|
| 144 |
+
|
| 145 |
+
s = 'tool_message_event'
|
| 146 |
+
event = ToolManagerMessageEvent(s, sender, message)
|
| 147 |
+
self._callbacks.process(s, event)
|
| 148 |
+
|
| 149 |
+
@property
|
| 150 |
+
def active_toggle(self):
|
| 151 |
+
"""Currently toggled tools."""
|
| 152 |
+
return self._toggled
|
| 153 |
+
|
| 154 |
+
def get_tool_keymap(self, name):
|
| 155 |
+
"""
|
| 156 |
+
Return the keymap associated with the specified tool.
|
| 157 |
+
|
| 158 |
+
Parameters
|
| 159 |
+
----------
|
| 160 |
+
name : str
|
| 161 |
+
Name of the Tool.
|
| 162 |
+
|
| 163 |
+
Returns
|
| 164 |
+
-------
|
| 165 |
+
list of str
|
| 166 |
+
List of keys associated with the tool.
|
| 167 |
+
"""
|
| 168 |
+
|
| 169 |
+
keys = [k for k, i in self._keys.items() if i == name]
|
| 170 |
+
return keys
|
| 171 |
+
|
| 172 |
+
def _remove_keys(self, name):
|
| 173 |
+
for k in self.get_tool_keymap(name):
|
| 174 |
+
del self._keys[k]
|
| 175 |
+
|
| 176 |
+
def update_keymap(self, name, key):
|
| 177 |
+
"""
|
| 178 |
+
Set the keymap to associate with the specified tool.
|
| 179 |
+
|
| 180 |
+
Parameters
|
| 181 |
+
----------
|
| 182 |
+
name : str
|
| 183 |
+
Name of the Tool.
|
| 184 |
+
key : str or list of str
|
| 185 |
+
Keys to associate with the tool.
|
| 186 |
+
"""
|
| 187 |
+
if name not in self._tools:
|
| 188 |
+
raise KeyError(f'{name!r} not in Tools')
|
| 189 |
+
self._remove_keys(name)
|
| 190 |
+
if isinstance(key, str):
|
| 191 |
+
key = [key]
|
| 192 |
+
for k in key:
|
| 193 |
+
if k in self._keys:
|
| 194 |
+
_api.warn_external(
|
| 195 |
+
f'Key {k} changed from {self._keys[k]} to {name}')
|
| 196 |
+
self._keys[k] = name
|
| 197 |
+
|
| 198 |
+
def remove_tool(self, name):
|
| 199 |
+
"""
|
| 200 |
+
Remove tool named *name*.
|
| 201 |
+
|
| 202 |
+
Parameters
|
| 203 |
+
----------
|
| 204 |
+
name : str
|
| 205 |
+
Name of the tool.
|
| 206 |
+
"""
|
| 207 |
+
tool = self.get_tool(name)
|
| 208 |
+
if getattr(tool, 'toggled', False): # If it's a toggled toggle tool, untoggle
|
| 209 |
+
self.trigger_tool(tool, 'toolmanager')
|
| 210 |
+
self._remove_keys(name)
|
| 211 |
+
event = ToolEvent('tool_removed_event', self, tool)
|
| 212 |
+
self._callbacks.process(event.name, event)
|
| 213 |
+
del self._tools[name]
|
| 214 |
+
|
| 215 |
+
def add_tool(self, name, tool, *args, **kwargs):
|
| 216 |
+
"""
|
| 217 |
+
Add *tool* to `ToolManager`.
|
| 218 |
+
|
| 219 |
+
If successful, adds a new event ``tool_trigger_{name}`` where
|
| 220 |
+
``{name}`` is the *name* of the tool; the event is fired every time the
|
| 221 |
+
tool is triggered.
|
| 222 |
+
|
| 223 |
+
Parameters
|
| 224 |
+
----------
|
| 225 |
+
name : str
|
| 226 |
+
Name of the tool, treated as the ID, has to be unique.
|
| 227 |
+
tool : type
|
| 228 |
+
Class of the tool to be added. A subclass will be used
|
| 229 |
+
instead if one was registered for the current canvas class.
|
| 230 |
+
*args, **kwargs
|
| 231 |
+
Passed to the *tool*'s constructor.
|
| 232 |
+
|
| 233 |
+
See Also
|
| 234 |
+
--------
|
| 235 |
+
matplotlib.backend_tools.ToolBase : The base class for tools.
|
| 236 |
+
"""
|
| 237 |
+
|
| 238 |
+
tool_cls = backend_tools._find_tool_class(type(self.canvas), tool)
|
| 239 |
+
if not tool_cls:
|
| 240 |
+
raise ValueError('Impossible to find class for %s' % str(tool))
|
| 241 |
+
|
| 242 |
+
if name in self._tools:
|
| 243 |
+
_api.warn_external('A "Tool class" with the same name already '
|
| 244 |
+
'exists, not added')
|
| 245 |
+
return self._tools[name]
|
| 246 |
+
|
| 247 |
+
tool_obj = tool_cls(self, name, *args, **kwargs)
|
| 248 |
+
self._tools[name] = tool_obj
|
| 249 |
+
|
| 250 |
+
if tool_obj.default_keymap is not None:
|
| 251 |
+
self.update_keymap(name, tool_obj.default_keymap)
|
| 252 |
+
|
| 253 |
+
# For toggle tools init the radio_group in self._toggled
|
| 254 |
+
if isinstance(tool_obj, backend_tools.ToolToggleBase):
|
| 255 |
+
# None group is not mutually exclusive, a set is used to keep track
|
| 256 |
+
# of all toggled tools in this group
|
| 257 |
+
if tool_obj.radio_group is None:
|
| 258 |
+
self._toggled.setdefault(None, set())
|
| 259 |
+
else:
|
| 260 |
+
self._toggled.setdefault(tool_obj.radio_group, None)
|
| 261 |
+
|
| 262 |
+
# If initially toggled
|
| 263 |
+
if tool_obj.toggled:
|
| 264 |
+
self._handle_toggle(tool_obj, None, None)
|
| 265 |
+
tool_obj.set_figure(self.figure)
|
| 266 |
+
|
| 267 |
+
event = ToolEvent('tool_added_event', self, tool_obj)
|
| 268 |
+
self._callbacks.process(event.name, event)
|
| 269 |
+
|
| 270 |
+
return tool_obj
|
| 271 |
+
|
| 272 |
+
def _handle_toggle(self, tool, canvasevent, data):
|
| 273 |
+
"""
|
| 274 |
+
Toggle tools, need to untoggle prior to using other Toggle tool.
|
| 275 |
+
Called from trigger_tool.
|
| 276 |
+
|
| 277 |
+
Parameters
|
| 278 |
+
----------
|
| 279 |
+
tool : `.ToolBase`
|
| 280 |
+
canvasevent : Event
|
| 281 |
+
Original Canvas event or None.
|
| 282 |
+
data : object
|
| 283 |
+
Extra data to pass to the tool when triggering.
|
| 284 |
+
"""
|
| 285 |
+
|
| 286 |
+
radio_group = tool.radio_group
|
| 287 |
+
# radio_group None is not mutually exclusive
|
| 288 |
+
# just keep track of toggled tools in this group
|
| 289 |
+
if radio_group is None:
|
| 290 |
+
if tool.name in self._toggled[None]:
|
| 291 |
+
self._toggled[None].remove(tool.name)
|
| 292 |
+
else:
|
| 293 |
+
self._toggled[None].add(tool.name)
|
| 294 |
+
return
|
| 295 |
+
|
| 296 |
+
# If the tool already has a toggled state, untoggle it
|
| 297 |
+
if self._toggled[radio_group] == tool.name:
|
| 298 |
+
toggled = None
|
| 299 |
+
# If no tool was toggled in the radio_group
|
| 300 |
+
# toggle it
|
| 301 |
+
elif self._toggled[radio_group] is None:
|
| 302 |
+
toggled = tool.name
|
| 303 |
+
# Other tool in the radio_group is toggled
|
| 304 |
+
else:
|
| 305 |
+
# Untoggle previously toggled tool
|
| 306 |
+
self.trigger_tool(self._toggled[radio_group],
|
| 307 |
+
self,
|
| 308 |
+
canvasevent,
|
| 309 |
+
data)
|
| 310 |
+
toggled = tool.name
|
| 311 |
+
|
| 312 |
+
# Keep track of the toggled tool in the radio_group
|
| 313 |
+
self._toggled[radio_group] = toggled
|
| 314 |
+
|
| 315 |
+
def trigger_tool(self, name, sender=None, canvasevent=None, data=None):
|
| 316 |
+
"""
|
| 317 |
+
Trigger a tool and emit the ``tool_trigger_{name}`` event.
|
| 318 |
+
|
| 319 |
+
Parameters
|
| 320 |
+
----------
|
| 321 |
+
name : str
|
| 322 |
+
Name of the tool.
|
| 323 |
+
sender : object
|
| 324 |
+
Object that wishes to trigger the tool.
|
| 325 |
+
canvasevent : Event
|
| 326 |
+
Original Canvas event or None.
|
| 327 |
+
data : object
|
| 328 |
+
Extra data to pass to the tool when triggering.
|
| 329 |
+
"""
|
| 330 |
+
tool = self.get_tool(name)
|
| 331 |
+
if tool is None:
|
| 332 |
+
return
|
| 333 |
+
|
| 334 |
+
if sender is None:
|
| 335 |
+
sender = self
|
| 336 |
+
|
| 337 |
+
if isinstance(tool, backend_tools.ToolToggleBase):
|
| 338 |
+
self._handle_toggle(tool, canvasevent, data)
|
| 339 |
+
|
| 340 |
+
tool.trigger(sender, canvasevent, data) # Actually trigger Tool.
|
| 341 |
+
|
| 342 |
+
s = 'tool_trigger_%s' % name
|
| 343 |
+
event = ToolTriggerEvent(s, sender, tool, canvasevent, data)
|
| 344 |
+
self._callbacks.process(s, event)
|
| 345 |
+
|
| 346 |
+
def _key_press(self, event):
|
| 347 |
+
if event.key is None or self.keypresslock.locked():
|
| 348 |
+
return
|
| 349 |
+
|
| 350 |
+
name = self._keys.get(event.key, None)
|
| 351 |
+
if name is None:
|
| 352 |
+
return
|
| 353 |
+
self.trigger_tool(name, canvasevent=event)
|
| 354 |
+
|
| 355 |
+
@property
|
| 356 |
+
def tools(self):
|
| 357 |
+
"""A dict mapping tool name -> controlled tool."""
|
| 358 |
+
return self._tools
|
| 359 |
+
|
| 360 |
+
def get_tool(self, name, warn=True):
|
| 361 |
+
"""
|
| 362 |
+
Return the tool object with the given name.
|
| 363 |
+
|
| 364 |
+
For convenience, this passes tool objects through.
|
| 365 |
+
|
| 366 |
+
Parameters
|
| 367 |
+
----------
|
| 368 |
+
name : str or `.ToolBase`
|
| 369 |
+
Name of the tool, or the tool itself.
|
| 370 |
+
warn : bool, default: True
|
| 371 |
+
Whether a warning should be emitted it no tool with the given name
|
| 372 |
+
exists.
|
| 373 |
+
|
| 374 |
+
Returns
|
| 375 |
+
-------
|
| 376 |
+
`.ToolBase` or None
|
| 377 |
+
The tool or None if no tool with the given name exists.
|
| 378 |
+
"""
|
| 379 |
+
if (isinstance(name, backend_tools.ToolBase)
|
| 380 |
+
and name.name in self._tools):
|
| 381 |
+
return name
|
| 382 |
+
if name not in self._tools:
|
| 383 |
+
if warn:
|
| 384 |
+
_api.warn_external(
|
| 385 |
+
f"ToolManager does not control tool {name!r}")
|
| 386 |
+
return None
|
| 387 |
+
return self._tools[name]
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/backend_managers.pyi
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from matplotlib import backend_tools, widgets
|
| 2 |
+
from matplotlib.backend_bases import FigureCanvasBase
|
| 3 |
+
from matplotlib.figure import Figure
|
| 4 |
+
|
| 5 |
+
from collections.abc import Callable, Iterable
|
| 6 |
+
from typing import Any, TypeVar
|
| 7 |
+
|
| 8 |
+
class ToolEvent:
|
| 9 |
+
name: str
|
| 10 |
+
sender: Any
|
| 11 |
+
tool: backend_tools.ToolBase
|
| 12 |
+
data: Any
|
| 13 |
+
def __init__(self, name, sender, tool, data: Any | None = ...) -> None: ...
|
| 14 |
+
|
| 15 |
+
class ToolTriggerEvent(ToolEvent):
|
| 16 |
+
canvasevent: ToolEvent
|
| 17 |
+
def __init__(
|
| 18 |
+
self,
|
| 19 |
+
name,
|
| 20 |
+
sender,
|
| 21 |
+
tool,
|
| 22 |
+
canvasevent: ToolEvent | None = ...,
|
| 23 |
+
data: Any | None = ...,
|
| 24 |
+
) -> None: ...
|
| 25 |
+
|
| 26 |
+
class ToolManagerMessageEvent:
|
| 27 |
+
name: str
|
| 28 |
+
sender: Any
|
| 29 |
+
message: str
|
| 30 |
+
def __init__(self, name: str, sender: Any, message: str) -> None: ...
|
| 31 |
+
|
| 32 |
+
class ToolManager:
|
| 33 |
+
keypresslock: widgets.LockDraw
|
| 34 |
+
messagelock: widgets.LockDraw
|
| 35 |
+
def __init__(self, figure: Figure | None = ...) -> None: ...
|
| 36 |
+
@property
|
| 37 |
+
def canvas(self) -> FigureCanvasBase | None: ...
|
| 38 |
+
@property
|
| 39 |
+
def figure(self) -> Figure | None: ...
|
| 40 |
+
@figure.setter
|
| 41 |
+
def figure(self, figure: Figure) -> None: ...
|
| 42 |
+
def set_figure(self, figure: Figure, update_tools: bool = ...) -> None: ...
|
| 43 |
+
def toolmanager_connect(self, s: str, func: Callable[[ToolEvent], Any]) -> int: ...
|
| 44 |
+
def toolmanager_disconnect(self, cid: int) -> None: ...
|
| 45 |
+
def message_event(self, message: str, sender: Any | None = ...) -> None: ...
|
| 46 |
+
@property
|
| 47 |
+
def active_toggle(self) -> dict[str | None, list[str] | str]: ...
|
| 48 |
+
def get_tool_keymap(self, name: str) -> list[str]: ...
|
| 49 |
+
def update_keymap(self, name: str, key: str | Iterable[str]) -> None: ...
|
| 50 |
+
def remove_tool(self, name: str) -> None: ...
|
| 51 |
+
_T = TypeVar("_T", bound=backend_tools.ToolBase)
|
| 52 |
+
def add_tool(self, name: str, tool: type[_T], *args, **kwargs) -> _T: ...
|
| 53 |
+
def trigger_tool(
|
| 54 |
+
self,
|
| 55 |
+
name: str | backend_tools.ToolBase,
|
| 56 |
+
sender: Any | None = ...,
|
| 57 |
+
canvasevent: ToolEvent | None = ...,
|
| 58 |
+
data: Any | None = ...,
|
| 59 |
+
) -> None: ...
|
| 60 |
+
@property
|
| 61 |
+
def tools(self) -> dict[str, backend_tools.ToolBase]: ...
|
| 62 |
+
def get_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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
def _is_jax_array(x: Any) -> bool: ...
|
| 172 |
+
def _unpack_to_numpy(x: Any) -> Any: ...
|
| 173 |
+
def _auto_format_str(fmt: str, value: Any) -> str: ...
|
infer_4_30_0/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 |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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 |
+
|
| 222 |
+
n_rasterize = 50 # rasterize solids if number of colors >= n_rasterize
|
| 223 |
+
|
| 224 |
+
def __init__(
|
| 225 |
+
self, ax, mappable=None, *,
|
| 226 |
+
alpha=None,
|
| 227 |
+
location=None,
|
| 228 |
+
extend=None,
|
| 229 |
+
extendfrac=None,
|
| 230 |
+
extendrect=False,
|
| 231 |
+
ticks=None,
|
| 232 |
+
format=None,
|
| 233 |
+
values=None,
|
| 234 |
+
boundaries=None,
|
| 235 |
+
spacing='uniform',
|
| 236 |
+
drawedges=False,
|
| 237 |
+
label='',
|
| 238 |
+
cmap=None, norm=None, # redundant with *mappable*
|
| 239 |
+
orientation=None, ticklocation='auto', # redundant with *location*
|
| 240 |
+
):
|
| 241 |
+
"""
|
| 242 |
+
Parameters
|
| 243 |
+
----------
|
| 244 |
+
ax : `~matplotlib.axes.Axes`
|
| 245 |
+
The `~.axes.Axes` instance in which the colorbar is drawn.
|
| 246 |
+
|
| 247 |
+
mappable : `.ScalarMappable`
|
| 248 |
+
The mappable whose colormap and norm will be used.
|
| 249 |
+
|
| 250 |
+
To show the colors versus index instead of on a 0-1 scale, set the
|
| 251 |
+
mappable's norm to ``colors.NoNorm()``.
|
| 252 |
+
|
| 253 |
+
alpha : float
|
| 254 |
+
The colorbar transparency between 0 (transparent) and 1 (opaque).
|
| 255 |
+
|
| 256 |
+
location : None or {'left', 'right', 'top', 'bottom'}
|
| 257 |
+
Set the colorbar's *orientation* and *ticklocation*. Colorbars on
|
| 258 |
+
the left and right are vertical, colorbars at the top and bottom
|
| 259 |
+
are horizontal. The *ticklocation* is the same as *location*, so if
|
| 260 |
+
*location* is 'top', the ticks are on the top. *orientation* and/or
|
| 261 |
+
*ticklocation* can be provided as well and overrides the value set by
|
| 262 |
+
*location*, but there will be an error for incompatible combinations.
|
| 263 |
+
|
| 264 |
+
.. versionadded:: 3.7
|
| 265 |
+
|
| 266 |
+
%(_colormap_kw_doc)s
|
| 267 |
+
|
| 268 |
+
Other Parameters
|
| 269 |
+
----------------
|
| 270 |
+
cmap : `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
|
| 271 |
+
The colormap to use. This parameter is ignored, unless *mappable* is
|
| 272 |
+
None.
|
| 273 |
+
|
| 274 |
+
norm : `~matplotlib.colors.Normalize`
|
| 275 |
+
The normalization to use. This parameter is ignored, unless *mappable*
|
| 276 |
+
is None.
|
| 277 |
+
|
| 278 |
+
orientation : None or {'vertical', 'horizontal'}
|
| 279 |
+
If None, use the value determined by *location*. If both
|
| 280 |
+
*orientation* and *location* are None then defaults to 'vertical'.
|
| 281 |
+
|
| 282 |
+
ticklocation : {'auto', 'left', 'right', 'top', 'bottom'}
|
| 283 |
+
The location of the colorbar ticks. The *ticklocation* must match
|
| 284 |
+
*orientation*. For example, a horizontal colorbar can only have ticks
|
| 285 |
+
at the top or the bottom. If 'auto', the ticks will be the same as
|
| 286 |
+
*location*, so a colorbar to the left will have ticks to the left. If
|
| 287 |
+
*location* is None, the ticks will be at the bottom for a horizontal
|
| 288 |
+
colorbar and at the right for a vertical.
|
| 289 |
+
"""
|
| 290 |
+
if mappable is None:
|
| 291 |
+
mappable = cm.ScalarMappable(norm=norm, cmap=cmap)
|
| 292 |
+
|
| 293 |
+
self.mappable = mappable
|
| 294 |
+
cmap = mappable.cmap
|
| 295 |
+
norm = mappable.norm
|
| 296 |
+
|
| 297 |
+
filled = True
|
| 298 |
+
if isinstance(mappable, contour.ContourSet):
|
| 299 |
+
cs = mappable
|
| 300 |
+
alpha = cs.get_alpha()
|
| 301 |
+
boundaries = cs._levels
|
| 302 |
+
values = cs.cvalues
|
| 303 |
+
extend = cs.extend
|
| 304 |
+
filled = cs.filled
|
| 305 |
+
if ticks is None:
|
| 306 |
+
ticks = ticker.FixedLocator(cs.levels, nbins=10)
|
| 307 |
+
elif isinstance(mappable, martist.Artist):
|
| 308 |
+
alpha = mappable.get_alpha()
|
| 309 |
+
|
| 310 |
+
mappable.colorbar = self
|
| 311 |
+
mappable.colorbar_cid = mappable.callbacks.connect(
|
| 312 |
+
'changed', self.update_normal)
|
| 313 |
+
|
| 314 |
+
location_orientation = _get_orientation_from_location(location)
|
| 315 |
+
|
| 316 |
+
_api.check_in_list(
|
| 317 |
+
[None, 'vertical', 'horizontal'], orientation=orientation)
|
| 318 |
+
_api.check_in_list(
|
| 319 |
+
['auto', 'left', 'right', 'top', 'bottom'],
|
| 320 |
+
ticklocation=ticklocation)
|
| 321 |
+
_api.check_in_list(
|
| 322 |
+
['uniform', 'proportional'], spacing=spacing)
|
| 323 |
+
|
| 324 |
+
if location_orientation is not None and orientation is not None:
|
| 325 |
+
if location_orientation != orientation:
|
| 326 |
+
raise TypeError(
|
| 327 |
+
"location and orientation are mutually exclusive")
|
| 328 |
+
else:
|
| 329 |
+
orientation = orientation or location_orientation or "vertical"
|
| 330 |
+
|
| 331 |
+
self.ax = ax
|
| 332 |
+
self.ax._axes_locator = _ColorbarAxesLocator(self)
|
| 333 |
+
|
| 334 |
+
if extend is None:
|
| 335 |
+
if (not isinstance(mappable, contour.ContourSet)
|
| 336 |
+
and getattr(cmap, 'colorbar_extend', False) is not False):
|
| 337 |
+
extend = cmap.colorbar_extend
|
| 338 |
+
elif hasattr(norm, 'extend'):
|
| 339 |
+
extend = norm.extend
|
| 340 |
+
else:
|
| 341 |
+
extend = 'neither'
|
| 342 |
+
self.alpha = None
|
| 343 |
+
# Call set_alpha to handle array-like alphas properly
|
| 344 |
+
self.set_alpha(alpha)
|
| 345 |
+
self.cmap = cmap
|
| 346 |
+
self.norm = norm
|
| 347 |
+
self.values = values
|
| 348 |
+
self.boundaries = boundaries
|
| 349 |
+
self.extend = extend
|
| 350 |
+
self._inside = _api.check_getitem(
|
| 351 |
+
{'neither': slice(0, None), 'both': slice(1, -1),
|
| 352 |
+
'min': slice(1, None), 'max': slice(0, -1)},
|
| 353 |
+
extend=extend)
|
| 354 |
+
self.spacing = spacing
|
| 355 |
+
self.orientation = orientation
|
| 356 |
+
self.drawedges = drawedges
|
| 357 |
+
self._filled = filled
|
| 358 |
+
self.extendfrac = extendfrac
|
| 359 |
+
self.extendrect = extendrect
|
| 360 |
+
self._extend_patches = []
|
| 361 |
+
self.solids = None
|
| 362 |
+
self.solids_patches = []
|
| 363 |
+
self.lines = []
|
| 364 |
+
|
| 365 |
+
for spine in self.ax.spines.values():
|
| 366 |
+
spine.set_visible(False)
|
| 367 |
+
self.outline = self.ax.spines['outline'] = _ColorbarSpine(self.ax)
|
| 368 |
+
|
| 369 |
+
self.dividers = collections.LineCollection(
|
| 370 |
+
[],
|
| 371 |
+
colors=[mpl.rcParams['axes.edgecolor']],
|
| 372 |
+
linewidths=[0.5 * mpl.rcParams['axes.linewidth']],
|
| 373 |
+
clip_on=False)
|
| 374 |
+
self.ax.add_collection(self.dividers)
|
| 375 |
+
|
| 376 |
+
self._locator = None
|
| 377 |
+
self._minorlocator = None
|
| 378 |
+
self._formatter = None
|
| 379 |
+
self._minorformatter = None
|
| 380 |
+
|
| 381 |
+
if ticklocation == 'auto':
|
| 382 |
+
ticklocation = _get_ticklocation_from_orientation(
|
| 383 |
+
orientation) if location is None else location
|
| 384 |
+
self.ticklocation = ticklocation
|
| 385 |
+
|
| 386 |
+
self.set_label(label)
|
| 387 |
+
self._reset_locator_formatter_scale()
|
| 388 |
+
|
| 389 |
+
if np.iterable(ticks):
|
| 390 |
+
self._locator = ticker.FixedLocator(ticks, nbins=len(ticks))
|
| 391 |
+
else:
|
| 392 |
+
self._locator = ticks
|
| 393 |
+
|
| 394 |
+
if isinstance(format, str):
|
| 395 |
+
# Check format between FormatStrFormatter and StrMethodFormatter
|
| 396 |
+
try:
|
| 397 |
+
self._formatter = ticker.FormatStrFormatter(format)
|
| 398 |
+
_ = self._formatter(0)
|
| 399 |
+
except (TypeError, ValueError):
|
| 400 |
+
self._formatter = ticker.StrMethodFormatter(format)
|
| 401 |
+
else:
|
| 402 |
+
self._formatter = format # Assume it is a Formatter or None
|
| 403 |
+
self._draw_all()
|
| 404 |
+
|
| 405 |
+
if isinstance(mappable, contour.ContourSet) and not mappable.filled:
|
| 406 |
+
self.add_lines(mappable)
|
| 407 |
+
|
| 408 |
+
# Link the Axes and Colorbar for interactive use
|
| 409 |
+
self.ax._colorbar = self
|
| 410 |
+
# Don't navigate on any of these types of mappables
|
| 411 |
+
if (isinstance(self.norm, (colors.BoundaryNorm, colors.NoNorm)) or
|
| 412 |
+
isinstance(self.mappable, contour.ContourSet)):
|
| 413 |
+
self.ax.set_navigate(False)
|
| 414 |
+
|
| 415 |
+
# These are the functions that set up interactivity on this colorbar
|
| 416 |
+
self._interactive_funcs = ["_get_view", "_set_view",
|
| 417 |
+
"_set_view_from_bbox", "drag_pan"]
|
| 418 |
+
for x in self._interactive_funcs:
|
| 419 |
+
setattr(self.ax, x, getattr(self, x))
|
| 420 |
+
# Set the cla function to the cbar's method to override it
|
| 421 |
+
self.ax.cla = self._cbar_cla
|
| 422 |
+
# Callbacks for the extend calculations to handle inverting the axis
|
| 423 |
+
self._extend_cid1 = self.ax.callbacks.connect(
|
| 424 |
+
"xlim_changed", self._do_extends)
|
| 425 |
+
self._extend_cid2 = self.ax.callbacks.connect(
|
| 426 |
+
"ylim_changed", self._do_extends)
|
| 427 |
+
|
| 428 |
+
@property
|
| 429 |
+
def long_axis(self):
|
| 430 |
+
"""Axis that has decorations (ticks, etc) on it."""
|
| 431 |
+
if self.orientation == 'vertical':
|
| 432 |
+
return self.ax.yaxis
|
| 433 |
+
return self.ax.xaxis
|
| 434 |
+
|
| 435 |
+
@property
|
| 436 |
+
def locator(self):
|
| 437 |
+
"""Major tick `.Locator` for the colorbar."""
|
| 438 |
+
return self.long_axis.get_major_locator()
|
| 439 |
+
|
| 440 |
+
@locator.setter
|
| 441 |
+
def locator(self, loc):
|
| 442 |
+
self.long_axis.set_major_locator(loc)
|
| 443 |
+
self._locator = loc
|
| 444 |
+
|
| 445 |
+
@property
|
| 446 |
+
def minorlocator(self):
|
| 447 |
+
"""Minor tick `.Locator` for the colorbar."""
|
| 448 |
+
return self.long_axis.get_minor_locator()
|
| 449 |
+
|
| 450 |
+
@minorlocator.setter
|
| 451 |
+
def minorlocator(self, loc):
|
| 452 |
+
self.long_axis.set_minor_locator(loc)
|
| 453 |
+
self._minorlocator = loc
|
| 454 |
+
|
| 455 |
+
@property
|
| 456 |
+
def formatter(self):
|
| 457 |
+
"""Major tick label `.Formatter` for the colorbar."""
|
| 458 |
+
return self.long_axis.get_major_formatter()
|
| 459 |
+
|
| 460 |
+
@formatter.setter
|
| 461 |
+
def formatter(self, fmt):
|
| 462 |
+
self.long_axis.set_major_formatter(fmt)
|
| 463 |
+
self._formatter = fmt
|
| 464 |
+
|
| 465 |
+
@property
|
| 466 |
+
def minorformatter(self):
|
| 467 |
+
"""Minor tick `.Formatter` for the colorbar."""
|
| 468 |
+
return self.long_axis.get_minor_formatter()
|
| 469 |
+
|
| 470 |
+
@minorformatter.setter
|
| 471 |
+
def minorformatter(self, fmt):
|
| 472 |
+
self.long_axis.set_minor_formatter(fmt)
|
| 473 |
+
self._minorformatter = fmt
|
| 474 |
+
|
| 475 |
+
def _cbar_cla(self):
|
| 476 |
+
"""Function to clear the interactive colorbar state."""
|
| 477 |
+
for x in self._interactive_funcs:
|
| 478 |
+
delattr(self.ax, x)
|
| 479 |
+
# We now restore the old cla() back and can call it directly
|
| 480 |
+
del self.ax.cla
|
| 481 |
+
self.ax.cla()
|
| 482 |
+
|
| 483 |
+
def update_normal(self, mappable=None):
|
| 484 |
+
"""
|
| 485 |
+
Update solid patches, lines, etc.
|
| 486 |
+
|
| 487 |
+
This is meant to be called when the norm of the image or contour plot
|
| 488 |
+
to which this colorbar belongs changes.
|
| 489 |
+
|
| 490 |
+
If the norm on the mappable is different than before, this resets the
|
| 491 |
+
locator and formatter for the axis, so if these have been customized,
|
| 492 |
+
they will need to be customized again. However, if the norm only
|
| 493 |
+
changes values of *vmin*, *vmax* or *cmap* then the old formatter
|
| 494 |
+
and locator will be preserved.
|
| 495 |
+
"""
|
| 496 |
+
if mappable:
|
| 497 |
+
# The mappable keyword argument exists because
|
| 498 |
+
# ScalarMappable.changed() emits self.callbacks.process('changed', self)
|
| 499 |
+
# in contrast, ColorizingArtist (and Colorizer) does not use this keyword.
|
| 500 |
+
# [ColorizingArtist.changed() emits self.callbacks.process('changed')]
|
| 501 |
+
# Also, there is no test where self.mappable == mappable is not True
|
| 502 |
+
# and possibly no use case.
|
| 503 |
+
# Therefore, the mappable keyword can be deprecated if cm.ScalarMappable
|
| 504 |
+
# is removed.
|
| 505 |
+
self.mappable = mappable
|
| 506 |
+
_log.debug('colorbar update normal %r %r', self.mappable.norm, self.norm)
|
| 507 |
+
self.set_alpha(self.mappable.get_alpha())
|
| 508 |
+
self.cmap = self.mappable.cmap
|
| 509 |
+
if self.mappable.norm != self.norm:
|
| 510 |
+
self.norm = self.mappable.norm
|
| 511 |
+
self._reset_locator_formatter_scale()
|
| 512 |
+
|
| 513 |
+
self._draw_all()
|
| 514 |
+
if isinstance(self.mappable, contour.ContourSet):
|
| 515 |
+
CS = self.mappable
|
| 516 |
+
if not CS.filled:
|
| 517 |
+
self.add_lines(CS)
|
| 518 |
+
self.stale = True
|
| 519 |
+
|
| 520 |
+
def _draw_all(self):
|
| 521 |
+
"""
|
| 522 |
+
Calculate any free parameters based on the current cmap and norm,
|
| 523 |
+
and do all the drawing.
|
| 524 |
+
"""
|
| 525 |
+
if self.orientation == 'vertical':
|
| 526 |
+
if mpl.rcParams['ytick.minor.visible']:
|
| 527 |
+
self.minorticks_on()
|
| 528 |
+
else:
|
| 529 |
+
if mpl.rcParams['xtick.minor.visible']:
|
| 530 |
+
self.minorticks_on()
|
| 531 |
+
self.long_axis.set(label_position=self.ticklocation,
|
| 532 |
+
ticks_position=self.ticklocation)
|
| 533 |
+
self._short_axis().set_ticks([])
|
| 534 |
+
self._short_axis().set_ticks([], minor=True)
|
| 535 |
+
|
| 536 |
+
# Set self._boundaries and self._values, including extensions.
|
| 537 |
+
# self._boundaries are the edges of each square of color, and
|
| 538 |
+
# self._values are the value to map into the norm to get the
|
| 539 |
+
# color:
|
| 540 |
+
self._process_values()
|
| 541 |
+
# Set self.vmin and self.vmax to first and last boundary, excluding
|
| 542 |
+
# extensions:
|
| 543 |
+
self.vmin, self.vmax = self._boundaries[self._inside][[0, -1]]
|
| 544 |
+
# Compute the X/Y mesh.
|
| 545 |
+
X, Y = self._mesh()
|
| 546 |
+
# draw the extend triangles, and shrink the inner Axes to accommodate.
|
| 547 |
+
# also adds the outline path to self.outline spine:
|
| 548 |
+
self._do_extends()
|
| 549 |
+
lower, upper = self.vmin, self.vmax
|
| 550 |
+
if self.long_axis.get_inverted():
|
| 551 |
+
# If the axis is inverted, we need to swap the vmin/vmax
|
| 552 |
+
lower, upper = upper, lower
|
| 553 |
+
if self.orientation == 'vertical':
|
| 554 |
+
self.ax.set_xlim(0, 1)
|
| 555 |
+
self.ax.set_ylim(lower, upper)
|
| 556 |
+
else:
|
| 557 |
+
self.ax.set_ylim(0, 1)
|
| 558 |
+
self.ax.set_xlim(lower, upper)
|
| 559 |
+
|
| 560 |
+
# set up the tick locators and formatters. A bit complicated because
|
| 561 |
+
# boundary norms + uniform spacing requires a manual locator.
|
| 562 |
+
self.update_ticks()
|
| 563 |
+
|
| 564 |
+
if self._filled:
|
| 565 |
+
ind = np.arange(len(self._values))
|
| 566 |
+
if self._extend_lower():
|
| 567 |
+
ind = ind[1:]
|
| 568 |
+
if self._extend_upper():
|
| 569 |
+
ind = ind[:-1]
|
| 570 |
+
self._add_solids(X, Y, self._values[ind, np.newaxis])
|
| 571 |
+
|
| 572 |
+
def _add_solids(self, X, Y, C):
|
| 573 |
+
"""Draw the colors; optionally add separators."""
|
| 574 |
+
# Cleanup previously set artists.
|
| 575 |
+
if self.solids is not None:
|
| 576 |
+
self.solids.remove()
|
| 577 |
+
for solid in self.solids_patches:
|
| 578 |
+
solid.remove()
|
| 579 |
+
# Add new artist(s), based on mappable type. Use individual patches if
|
| 580 |
+
# hatching is needed, pcolormesh otherwise.
|
| 581 |
+
mappable = getattr(self, 'mappable', None)
|
| 582 |
+
if (isinstance(mappable, contour.ContourSet)
|
| 583 |
+
and any(hatch is not None for hatch in mappable.hatches)):
|
| 584 |
+
self._add_solids_patches(X, Y, C, mappable)
|
| 585 |
+
else:
|
| 586 |
+
self.solids = self.ax.pcolormesh(
|
| 587 |
+
X, Y, C, cmap=self.cmap, norm=self.norm, alpha=self.alpha,
|
| 588 |
+
edgecolors='none', shading='flat')
|
| 589 |
+
if not self.drawedges:
|
| 590 |
+
if len(self._y) >= self.n_rasterize:
|
| 591 |
+
self.solids.set_rasterized(True)
|
| 592 |
+
self._update_dividers()
|
| 593 |
+
|
| 594 |
+
def _update_dividers(self):
|
| 595 |
+
if not self.drawedges:
|
| 596 |
+
self.dividers.set_segments([])
|
| 597 |
+
return
|
| 598 |
+
# Place all *internal* dividers.
|
| 599 |
+
if self.orientation == 'vertical':
|
| 600 |
+
lims = self.ax.get_ylim()
|
| 601 |
+
bounds = (lims[0] < self._y) & (self._y < lims[1])
|
| 602 |
+
else:
|
| 603 |
+
lims = self.ax.get_xlim()
|
| 604 |
+
bounds = (lims[0] < self._y) & (self._y < lims[1])
|
| 605 |
+
y = self._y[bounds]
|
| 606 |
+
# And then add outer dividers if extensions are on.
|
| 607 |
+
if self._extend_lower():
|
| 608 |
+
y = np.insert(y, 0, lims[0])
|
| 609 |
+
if self._extend_upper():
|
| 610 |
+
y = np.append(y, lims[1])
|
| 611 |
+
X, Y = np.meshgrid([0, 1], y)
|
| 612 |
+
if self.orientation == 'vertical':
|
| 613 |
+
segments = np.dstack([X, Y])
|
| 614 |
+
else:
|
| 615 |
+
segments = np.dstack([Y, X])
|
| 616 |
+
self.dividers.set_segments(segments)
|
| 617 |
+
|
| 618 |
+
def _add_solids_patches(self, X, Y, C, mappable):
|
| 619 |
+
hatches = mappable.hatches * (len(C) + 1) # Have enough hatches.
|
| 620 |
+
if self._extend_lower():
|
| 621 |
+
# remove first hatch that goes into the extend patch
|
| 622 |
+
hatches = hatches[1:]
|
| 623 |
+
patches = []
|
| 624 |
+
for i in range(len(X) - 1):
|
| 625 |
+
xy = np.array([[X[i, 0], Y[i, 1]],
|
| 626 |
+
[X[i, 1], Y[i, 0]],
|
| 627 |
+
[X[i + 1, 1], Y[i + 1, 0]],
|
| 628 |
+
[X[i + 1, 0], Y[i + 1, 1]]])
|
| 629 |
+
patch = mpatches.PathPatch(mpath.Path(xy),
|
| 630 |
+
facecolor=self.cmap(self.norm(C[i][0])),
|
| 631 |
+
hatch=hatches[i], linewidth=0,
|
| 632 |
+
antialiased=False, alpha=self.alpha)
|
| 633 |
+
self.ax.add_patch(patch)
|
| 634 |
+
patches.append(patch)
|
| 635 |
+
self.solids_patches = patches
|
| 636 |
+
|
| 637 |
+
def _do_extends(self, ax=None):
|
| 638 |
+
"""
|
| 639 |
+
Add the extend tri/rectangles on the outside of the Axes.
|
| 640 |
+
|
| 641 |
+
ax is unused, but required due to the callbacks on xlim/ylim changed
|
| 642 |
+
"""
|
| 643 |
+
# Clean up any previous extend patches
|
| 644 |
+
for patch in self._extend_patches:
|
| 645 |
+
patch.remove()
|
| 646 |
+
self._extend_patches = []
|
| 647 |
+
# extend lengths are fraction of the *inner* part of colorbar,
|
| 648 |
+
# not the total colorbar:
|
| 649 |
+
_, extendlen = self._proportional_y()
|
| 650 |
+
bot = 0 - (extendlen[0] if self._extend_lower() else 0)
|
| 651 |
+
top = 1 + (extendlen[1] if self._extend_upper() else 0)
|
| 652 |
+
|
| 653 |
+
# xyout is the outline of the colorbar including the extend patches:
|
| 654 |
+
if not self.extendrect:
|
| 655 |
+
# triangle:
|
| 656 |
+
xyout = np.array([[0, 0], [0.5, bot], [1, 0],
|
| 657 |
+
[1, 1], [0.5, top], [0, 1], [0, 0]])
|
| 658 |
+
else:
|
| 659 |
+
# rectangle:
|
| 660 |
+
xyout = np.array([[0, 0], [0, bot], [1, bot], [1, 0],
|
| 661 |
+
[1, 1], [1, top], [0, top], [0, 1],
|
| 662 |
+
[0, 0]])
|
| 663 |
+
|
| 664 |
+
if self.orientation == 'horizontal':
|
| 665 |
+
xyout = xyout[:, ::-1]
|
| 666 |
+
|
| 667 |
+
# xyout is the path for the spine:
|
| 668 |
+
self.outline.set_xy(xyout)
|
| 669 |
+
if not self._filled:
|
| 670 |
+
return
|
| 671 |
+
|
| 672 |
+
# Make extend triangles or rectangles filled patches. These are
|
| 673 |
+
# defined in the outer parent axes' coordinates:
|
| 674 |
+
mappable = getattr(self, 'mappable', None)
|
| 675 |
+
if (isinstance(mappable, contour.ContourSet)
|
| 676 |
+
and any(hatch is not None for hatch in mappable.hatches)):
|
| 677 |
+
hatches = mappable.hatches * (len(self._y) + 1)
|
| 678 |
+
else:
|
| 679 |
+
hatches = [None] * (len(self._y) + 1)
|
| 680 |
+
|
| 681 |
+
if self._extend_lower():
|
| 682 |
+
if not self.extendrect:
|
| 683 |
+
# triangle
|
| 684 |
+
xy = np.array([[0, 0], [0.5, bot], [1, 0]])
|
| 685 |
+
else:
|
| 686 |
+
# rectangle
|
| 687 |
+
xy = np.array([[0, 0], [0, bot], [1., bot], [1, 0]])
|
| 688 |
+
if self.orientation == 'horizontal':
|
| 689 |
+
xy = xy[:, ::-1]
|
| 690 |
+
# add the patch
|
| 691 |
+
val = -1 if self.long_axis.get_inverted() else 0
|
| 692 |
+
color = self.cmap(self.norm(self._values[val]))
|
| 693 |
+
patch = mpatches.PathPatch(
|
| 694 |
+
mpath.Path(xy), facecolor=color, alpha=self.alpha,
|
| 695 |
+
linewidth=0, antialiased=False,
|
| 696 |
+
transform=self.ax.transAxes,
|
| 697 |
+
hatch=hatches[0], clip_on=False,
|
| 698 |
+
# Place it right behind the standard patches, which is
|
| 699 |
+
# needed if we updated the extends
|
| 700 |
+
zorder=np.nextafter(self.ax.patch.zorder, -np.inf))
|
| 701 |
+
self.ax.add_patch(patch)
|
| 702 |
+
self._extend_patches.append(patch)
|
| 703 |
+
# remove first hatch that goes into the extend patch
|
| 704 |
+
hatches = hatches[1:]
|
| 705 |
+
if self._extend_upper():
|
| 706 |
+
if not self.extendrect:
|
| 707 |
+
# triangle
|
| 708 |
+
xy = np.array([[0, 1], [0.5, top], [1, 1]])
|
| 709 |
+
else:
|
| 710 |
+
# rectangle
|
| 711 |
+
xy = np.array([[0, 1], [0, top], [1, top], [1, 1]])
|
| 712 |
+
if self.orientation == 'horizontal':
|
| 713 |
+
xy = xy[:, ::-1]
|
| 714 |
+
# add the patch
|
| 715 |
+
val = 0 if self.long_axis.get_inverted() else -1
|
| 716 |
+
color = self.cmap(self.norm(self._values[val]))
|
| 717 |
+
hatch_idx = len(self._y) - 1
|
| 718 |
+
patch = mpatches.PathPatch(
|
| 719 |
+
mpath.Path(xy), facecolor=color, alpha=self.alpha,
|
| 720 |
+
linewidth=0, antialiased=False,
|
| 721 |
+
transform=self.ax.transAxes, hatch=hatches[hatch_idx],
|
| 722 |
+
clip_on=False,
|
| 723 |
+
# Place it right behind the standard patches, which is
|
| 724 |
+
# needed if we updated the extends
|
| 725 |
+
zorder=np.nextafter(self.ax.patch.zorder, -np.inf))
|
| 726 |
+
self.ax.add_patch(patch)
|
| 727 |
+
self._extend_patches.append(patch)
|
| 728 |
+
|
| 729 |
+
self._update_dividers()
|
| 730 |
+
|
| 731 |
+
def add_lines(self, *args, **kwargs):
|
| 732 |
+
"""
|
| 733 |
+
Draw lines on the colorbar.
|
| 734 |
+
|
| 735 |
+
The lines are appended to the list :attr:`lines`.
|
| 736 |
+
|
| 737 |
+
Parameters
|
| 738 |
+
----------
|
| 739 |
+
levels : array-like
|
| 740 |
+
The positions of the lines.
|
| 741 |
+
colors : :mpltype:`color` or list of :mpltype:`color`
|
| 742 |
+
Either a single color applying to all lines or one color value for
|
| 743 |
+
each line.
|
| 744 |
+
linewidths : float or array-like
|
| 745 |
+
Either a single linewidth applying to all lines or one linewidth
|
| 746 |
+
for each line.
|
| 747 |
+
erase : bool, default: True
|
| 748 |
+
Whether to remove any previously added lines.
|
| 749 |
+
|
| 750 |
+
Notes
|
| 751 |
+
-----
|
| 752 |
+
Alternatively, this method can also be called with the signature
|
| 753 |
+
``colorbar.add_lines(contour_set, erase=True)``, in which case
|
| 754 |
+
*levels*, *colors*, and *linewidths* are taken from *contour_set*.
|
| 755 |
+
"""
|
| 756 |
+
params = _api.select_matching_signature(
|
| 757 |
+
[lambda self, CS, erase=True: locals(),
|
| 758 |
+
lambda self, levels, colors, linewidths, erase=True: locals()],
|
| 759 |
+
self, *args, **kwargs)
|
| 760 |
+
if "CS" in params:
|
| 761 |
+
self, cs, erase = params.values()
|
| 762 |
+
if not isinstance(cs, contour.ContourSet) or cs.filled:
|
| 763 |
+
raise ValueError("If a single artist is passed to add_lines, "
|
| 764 |
+
"it must be a ContourSet of lines")
|
| 765 |
+
# TODO: Make colorbar lines auto-follow changes in contour lines.
|
| 766 |
+
return self.add_lines(
|
| 767 |
+
cs.levels,
|
| 768 |
+
cs.to_rgba(cs.cvalues, cs.alpha),
|
| 769 |
+
cs.get_linewidths(),
|
| 770 |
+
erase=erase)
|
| 771 |
+
else:
|
| 772 |
+
self, levels, colors, linewidths, erase = params.values()
|
| 773 |
+
|
| 774 |
+
y = self._locate(levels)
|
| 775 |
+
rtol = (self._y[-1] - self._y[0]) * 1e-10
|
| 776 |
+
igood = (y < self._y[-1] + rtol) & (y > self._y[0] - rtol)
|
| 777 |
+
y = y[igood]
|
| 778 |
+
if np.iterable(colors):
|
| 779 |
+
colors = np.asarray(colors)[igood]
|
| 780 |
+
if np.iterable(linewidths):
|
| 781 |
+
linewidths = np.asarray(linewidths)[igood]
|
| 782 |
+
X, Y = np.meshgrid([0, 1], y)
|
| 783 |
+
if self.orientation == 'vertical':
|
| 784 |
+
xy = np.stack([X, Y], axis=-1)
|
| 785 |
+
else:
|
| 786 |
+
xy = np.stack([Y, X], axis=-1)
|
| 787 |
+
col = collections.LineCollection(xy, linewidths=linewidths,
|
| 788 |
+
colors=colors)
|
| 789 |
+
|
| 790 |
+
if erase and self.lines:
|
| 791 |
+
for lc in self.lines:
|
| 792 |
+
lc.remove()
|
| 793 |
+
self.lines = []
|
| 794 |
+
self.lines.append(col)
|
| 795 |
+
|
| 796 |
+
# make a clip path that is just a linewidth bigger than the Axes...
|
| 797 |
+
fac = np.max(linewidths) / 72
|
| 798 |
+
xy = np.array([[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]])
|
| 799 |
+
inches = self.ax.get_figure().dpi_scale_trans
|
| 800 |
+
# do in inches:
|
| 801 |
+
xy = inches.inverted().transform(self.ax.transAxes.transform(xy))
|
| 802 |
+
xy[[0, 1, 4], 1] -= fac
|
| 803 |
+
xy[[2, 3], 1] += fac
|
| 804 |
+
# back to axes units...
|
| 805 |
+
xy = self.ax.transAxes.inverted().transform(inches.transform(xy))
|
| 806 |
+
col.set_clip_path(mpath.Path(xy, closed=True),
|
| 807 |
+
self.ax.transAxes)
|
| 808 |
+
self.ax.add_collection(col)
|
| 809 |
+
self.stale = True
|
| 810 |
+
|
| 811 |
+
def update_ticks(self):
|
| 812 |
+
"""
|
| 813 |
+
Set up the ticks and ticklabels. This should not be needed by users.
|
| 814 |
+
"""
|
| 815 |
+
# Get the locator and formatter; defaults to self._locator if not None.
|
| 816 |
+
self._get_ticker_locator_formatter()
|
| 817 |
+
self.long_axis.set_major_locator(self._locator)
|
| 818 |
+
self.long_axis.set_minor_locator(self._minorlocator)
|
| 819 |
+
self.long_axis.set_major_formatter(self._formatter)
|
| 820 |
+
|
| 821 |
+
def _get_ticker_locator_formatter(self):
|
| 822 |
+
"""
|
| 823 |
+
Return the ``locator`` and ``formatter`` of the colorbar.
|
| 824 |
+
|
| 825 |
+
If they have not been defined (i.e. are *None*), the formatter and
|
| 826 |
+
locator are retrieved from the axis, or from the value of the
|
| 827 |
+
boundaries for a boundary norm.
|
| 828 |
+
|
| 829 |
+
Called by update_ticks...
|
| 830 |
+
"""
|
| 831 |
+
locator = self._locator
|
| 832 |
+
formatter = self._formatter
|
| 833 |
+
minorlocator = self._minorlocator
|
| 834 |
+
if isinstance(self.norm, colors.BoundaryNorm):
|
| 835 |
+
b = self.norm.boundaries
|
| 836 |
+
if locator is None:
|
| 837 |
+
locator = ticker.FixedLocator(b, nbins=10)
|
| 838 |
+
if minorlocator is None:
|
| 839 |
+
minorlocator = ticker.FixedLocator(b)
|
| 840 |
+
elif isinstance(self.norm, colors.NoNorm):
|
| 841 |
+
if locator is None:
|
| 842 |
+
# put ticks on integers between the boundaries of NoNorm
|
| 843 |
+
nv = len(self._values)
|
| 844 |
+
base = 1 + int(nv / 10)
|
| 845 |
+
locator = ticker.IndexLocator(base=base, offset=.5)
|
| 846 |
+
elif self.boundaries is not None:
|
| 847 |
+
b = self._boundaries[self._inside]
|
| 848 |
+
if locator is None:
|
| 849 |
+
locator = ticker.FixedLocator(b, nbins=10)
|
| 850 |
+
else: # most cases:
|
| 851 |
+
if locator is None:
|
| 852 |
+
# we haven't set the locator explicitly, so use the default
|
| 853 |
+
# for this axis:
|
| 854 |
+
locator = self.long_axis.get_major_locator()
|
| 855 |
+
if minorlocator is None:
|
| 856 |
+
minorlocator = self.long_axis.get_minor_locator()
|
| 857 |
+
|
| 858 |
+
if minorlocator is None:
|
| 859 |
+
minorlocator = ticker.NullLocator()
|
| 860 |
+
|
| 861 |
+
if formatter is None:
|
| 862 |
+
formatter = self.long_axis.get_major_formatter()
|
| 863 |
+
|
| 864 |
+
self._locator = locator
|
| 865 |
+
self._formatter = formatter
|
| 866 |
+
self._minorlocator = minorlocator
|
| 867 |
+
_log.debug('locator: %r', locator)
|
| 868 |
+
|
| 869 |
+
def set_ticks(self, ticks, *, labels=None, minor=False, **kwargs):
|
| 870 |
+
"""
|
| 871 |
+
Set tick locations.
|
| 872 |
+
|
| 873 |
+
Parameters
|
| 874 |
+
----------
|
| 875 |
+
ticks : 1D array-like
|
| 876 |
+
List of tick locations.
|
| 877 |
+
labels : list of str, optional
|
| 878 |
+
List of tick labels. If not set, the labels show the data value.
|
| 879 |
+
minor : bool, default: False
|
| 880 |
+
If ``False``, set the major ticks; if ``True``, the minor ticks.
|
| 881 |
+
**kwargs
|
| 882 |
+
`.Text` properties for the labels. These take effect only if you
|
| 883 |
+
pass *labels*. In other cases, please use `~.Axes.tick_params`.
|
| 884 |
+
"""
|
| 885 |
+
if np.iterable(ticks):
|
| 886 |
+
self.long_axis.set_ticks(ticks, labels=labels, minor=minor,
|
| 887 |
+
**kwargs)
|
| 888 |
+
self._locator = self.long_axis.get_major_locator()
|
| 889 |
+
else:
|
| 890 |
+
self._locator = ticks
|
| 891 |
+
self.long_axis.set_major_locator(self._locator)
|
| 892 |
+
self.stale = True
|
| 893 |
+
|
| 894 |
+
def get_ticks(self, minor=False):
|
| 895 |
+
"""
|
| 896 |
+
Return the ticks as a list of locations.
|
| 897 |
+
|
| 898 |
+
Parameters
|
| 899 |
+
----------
|
| 900 |
+
minor : boolean, default: False
|
| 901 |
+
if True return the minor ticks.
|
| 902 |
+
"""
|
| 903 |
+
if minor:
|
| 904 |
+
return self.long_axis.get_minorticklocs()
|
| 905 |
+
else:
|
| 906 |
+
return self.long_axis.get_majorticklocs()
|
| 907 |
+
|
| 908 |
+
def set_ticklabels(self, ticklabels, *, minor=False, **kwargs):
|
| 909 |
+
"""
|
| 910 |
+
[*Discouraged*] Set tick labels.
|
| 911 |
+
|
| 912 |
+
.. admonition:: Discouraged
|
| 913 |
+
|
| 914 |
+
The use of this method is discouraged, because of the dependency
|
| 915 |
+
on tick positions. In most cases, you'll want to use
|
| 916 |
+
``set_ticks(positions, labels=labels)`` instead.
|
| 917 |
+
|
| 918 |
+
If you are using this method, you should always fix the tick
|
| 919 |
+
positions before, e.g. by using `.Colorbar.set_ticks` or by
|
| 920 |
+
explicitly setting a `~.ticker.FixedLocator` on the long axis
|
| 921 |
+
of the colorbar. Otherwise, ticks are free to move and the
|
| 922 |
+
labels may end up in unexpected positions.
|
| 923 |
+
|
| 924 |
+
Parameters
|
| 925 |
+
----------
|
| 926 |
+
ticklabels : sequence of str or of `.Text`
|
| 927 |
+
Texts for labeling each tick location in the sequence set by
|
| 928 |
+
`.Colorbar.set_ticks`; the number of labels must match the number
|
| 929 |
+
of locations.
|
| 930 |
+
|
| 931 |
+
update_ticks : bool, default: True
|
| 932 |
+
This keyword argument is ignored and will be removed.
|
| 933 |
+
Deprecated
|
| 934 |
+
|
| 935 |
+
minor : bool
|
| 936 |
+
If True, set minor ticks instead of major ticks.
|
| 937 |
+
|
| 938 |
+
**kwargs
|
| 939 |
+
`.Text` properties for the labels.
|
| 940 |
+
"""
|
| 941 |
+
self.long_axis.set_ticklabels(ticklabels, minor=minor, **kwargs)
|
| 942 |
+
|
| 943 |
+
def minorticks_on(self):
|
| 944 |
+
"""
|
| 945 |
+
Turn on colorbar minor ticks.
|
| 946 |
+
"""
|
| 947 |
+
self.ax.minorticks_on()
|
| 948 |
+
self._short_axis().set_minor_locator(ticker.NullLocator())
|
| 949 |
+
|
| 950 |
+
def minorticks_off(self):
|
| 951 |
+
"""Turn the minor ticks of the colorbar off."""
|
| 952 |
+
self._minorlocator = ticker.NullLocator()
|
| 953 |
+
self.long_axis.set_minor_locator(self._minorlocator)
|
| 954 |
+
|
| 955 |
+
def set_label(self, label, *, loc=None, **kwargs):
|
| 956 |
+
"""
|
| 957 |
+
Add a label to the long axis of the colorbar.
|
| 958 |
+
|
| 959 |
+
Parameters
|
| 960 |
+
----------
|
| 961 |
+
label : str
|
| 962 |
+
The label text.
|
| 963 |
+
loc : str, optional
|
| 964 |
+
The location of the label.
|
| 965 |
+
|
| 966 |
+
- For horizontal orientation one of {'left', 'center', 'right'}
|
| 967 |
+
- For vertical orientation one of {'bottom', 'center', 'top'}
|
| 968 |
+
|
| 969 |
+
Defaults to :rc:`xaxis.labellocation` or :rc:`yaxis.labellocation`
|
| 970 |
+
depending on the orientation.
|
| 971 |
+
**kwargs
|
| 972 |
+
Keyword arguments are passed to `~.Axes.set_xlabel` /
|
| 973 |
+
`~.Axes.set_ylabel`.
|
| 974 |
+
Supported keywords are *labelpad* and `.Text` properties.
|
| 975 |
+
"""
|
| 976 |
+
if self.orientation == "vertical":
|
| 977 |
+
self.ax.set_ylabel(label, loc=loc, **kwargs)
|
| 978 |
+
else:
|
| 979 |
+
self.ax.set_xlabel(label, loc=loc, **kwargs)
|
| 980 |
+
self.stale = True
|
| 981 |
+
|
| 982 |
+
def set_alpha(self, alpha):
|
| 983 |
+
"""
|
| 984 |
+
Set the transparency between 0 (transparent) and 1 (opaque).
|
| 985 |
+
|
| 986 |
+
If an array is provided, *alpha* will be set to None to use the
|
| 987 |
+
transparency values associated with the colormap.
|
| 988 |
+
"""
|
| 989 |
+
self.alpha = None if isinstance(alpha, np.ndarray) else alpha
|
| 990 |
+
|
| 991 |
+
def _set_scale(self, scale, **kwargs):
|
| 992 |
+
"""
|
| 993 |
+
Set the colorbar long axis scale.
|
| 994 |
+
|
| 995 |
+
Parameters
|
| 996 |
+
----------
|
| 997 |
+
scale : {"linear", "log", "symlog", "logit", ...} or `.ScaleBase`
|
| 998 |
+
The axis scale type to apply.
|
| 999 |
+
|
| 1000 |
+
**kwargs
|
| 1001 |
+
Different keyword arguments are accepted, depending on the scale.
|
| 1002 |
+
See the respective class keyword arguments:
|
| 1003 |
+
|
| 1004 |
+
- `matplotlib.scale.LinearScale`
|
| 1005 |
+
- `matplotlib.scale.LogScale`
|
| 1006 |
+
- `matplotlib.scale.SymmetricalLogScale`
|
| 1007 |
+
- `matplotlib.scale.LogitScale`
|
| 1008 |
+
- `matplotlib.scale.FuncScale`
|
| 1009 |
+
- `matplotlib.scale.AsinhScale`
|
| 1010 |
+
|
| 1011 |
+
Notes
|
| 1012 |
+
-----
|
| 1013 |
+
By default, Matplotlib supports the above-mentioned scales.
|
| 1014 |
+
Additionally, custom scales may be registered using
|
| 1015 |
+
`matplotlib.scale.register_scale`. These scales can then also
|
| 1016 |
+
be used here.
|
| 1017 |
+
"""
|
| 1018 |
+
self.long_axis._set_axes_scale(scale, **kwargs)
|
| 1019 |
+
|
| 1020 |
+
def remove(self):
|
| 1021 |
+
"""
|
| 1022 |
+
Remove this colorbar from the figure.
|
| 1023 |
+
|
| 1024 |
+
If the colorbar was created with ``use_gridspec=True`` the previous
|
| 1025 |
+
gridspec is restored.
|
| 1026 |
+
"""
|
| 1027 |
+
if hasattr(self.ax, '_colorbar_info'):
|
| 1028 |
+
parents = self.ax._colorbar_info['parents']
|
| 1029 |
+
for a in parents:
|
| 1030 |
+
if self.ax in a._colorbars:
|
| 1031 |
+
a._colorbars.remove(self.ax)
|
| 1032 |
+
|
| 1033 |
+
self.ax.remove()
|
| 1034 |
+
|
| 1035 |
+
self.mappable.callbacks.disconnect(self.mappable.colorbar_cid)
|
| 1036 |
+
self.mappable.colorbar = None
|
| 1037 |
+
self.mappable.colorbar_cid = None
|
| 1038 |
+
# Remove the extension callbacks
|
| 1039 |
+
self.ax.callbacks.disconnect(self._extend_cid1)
|
| 1040 |
+
self.ax.callbacks.disconnect(self._extend_cid2)
|
| 1041 |
+
|
| 1042 |
+
try:
|
| 1043 |
+
ax = self.mappable.axes
|
| 1044 |
+
except AttributeError:
|
| 1045 |
+
return
|
| 1046 |
+
try:
|
| 1047 |
+
subplotspec = self.ax.get_subplotspec().get_gridspec()._subplot_spec
|
| 1048 |
+
except AttributeError: # use_gridspec was False
|
| 1049 |
+
pos = ax.get_position(original=True)
|
| 1050 |
+
ax._set_position(pos)
|
| 1051 |
+
else: # use_gridspec was True
|
| 1052 |
+
ax.set_subplotspec(subplotspec)
|
| 1053 |
+
|
| 1054 |
+
def _process_values(self):
|
| 1055 |
+
"""
|
| 1056 |
+
Set `_boundaries` and `_values` based on the self.boundaries and
|
| 1057 |
+
self.values if not None, or based on the size of the colormap and
|
| 1058 |
+
the vmin/vmax of the norm.
|
| 1059 |
+
"""
|
| 1060 |
+
if self.values is not None:
|
| 1061 |
+
# set self._boundaries from the values...
|
| 1062 |
+
self._values = np.array(self.values)
|
| 1063 |
+
if self.boundaries is None:
|
| 1064 |
+
# bracket values by 1/2 dv:
|
| 1065 |
+
b = np.zeros(len(self.values) + 1)
|
| 1066 |
+
b[1:-1] = 0.5 * (self._values[:-1] + self._values[1:])
|
| 1067 |
+
b[0] = 2.0 * b[1] - b[2]
|
| 1068 |
+
b[-1] = 2.0 * b[-2] - b[-3]
|
| 1069 |
+
self._boundaries = b
|
| 1070 |
+
return
|
| 1071 |
+
self._boundaries = np.array(self.boundaries)
|
| 1072 |
+
return
|
| 1073 |
+
|
| 1074 |
+
# otherwise values are set from the boundaries
|
| 1075 |
+
if isinstance(self.norm, colors.BoundaryNorm):
|
| 1076 |
+
b = self.norm.boundaries
|
| 1077 |
+
elif isinstance(self.norm, colors.NoNorm):
|
| 1078 |
+
# NoNorm has N blocks, so N+1 boundaries, centered on integers:
|
| 1079 |
+
b = np.arange(self.cmap.N + 1) - .5
|
| 1080 |
+
elif self.boundaries is not None:
|
| 1081 |
+
b = self.boundaries
|
| 1082 |
+
else:
|
| 1083 |
+
# otherwise make the boundaries from the size of the cmap:
|
| 1084 |
+
N = self.cmap.N + 1
|
| 1085 |
+
b, _ = self._uniform_y(N)
|
| 1086 |
+
# add extra boundaries if needed:
|
| 1087 |
+
if self._extend_lower():
|
| 1088 |
+
b = np.hstack((b[0] - 1, b))
|
| 1089 |
+
if self._extend_upper():
|
| 1090 |
+
b = np.hstack((b, b[-1] + 1))
|
| 1091 |
+
|
| 1092 |
+
# transform from 0-1 to vmin-vmax:
|
| 1093 |
+
if self.mappable.get_array() is not None:
|
| 1094 |
+
self.mappable.autoscale_None()
|
| 1095 |
+
if not self.norm.scaled():
|
| 1096 |
+
# If we still aren't scaled after autoscaling, use 0, 1 as default
|
| 1097 |
+
self.norm.vmin = 0
|
| 1098 |
+
self.norm.vmax = 1
|
| 1099 |
+
self.norm.vmin, self.norm.vmax = mtransforms.nonsingular(
|
| 1100 |
+
self.norm.vmin, self.norm.vmax, expander=0.1)
|
| 1101 |
+
if (not isinstance(self.norm, colors.BoundaryNorm) and
|
| 1102 |
+
(self.boundaries is None)):
|
| 1103 |
+
b = self.norm.inverse(b)
|
| 1104 |
+
|
| 1105 |
+
self._boundaries = np.asarray(b, dtype=float)
|
| 1106 |
+
self._values = 0.5 * (self._boundaries[:-1] + self._boundaries[1:])
|
| 1107 |
+
if isinstance(self.norm, colors.NoNorm):
|
| 1108 |
+
self._values = (self._values + 0.00001).astype(np.int16)
|
| 1109 |
+
|
| 1110 |
+
def _mesh(self):
|
| 1111 |
+
"""
|
| 1112 |
+
Return the coordinate arrays for the colorbar pcolormesh/patches.
|
| 1113 |
+
|
| 1114 |
+
These are scaled between vmin and vmax, and already handle colorbar
|
| 1115 |
+
orientation.
|
| 1116 |
+
"""
|
| 1117 |
+
y, _ = self._proportional_y()
|
| 1118 |
+
# Use the vmin and vmax of the colorbar, which may not be the same
|
| 1119 |
+
# as the norm. There are situations where the colormap has a
|
| 1120 |
+
# narrower range than the colorbar and we want to accommodate the
|
| 1121 |
+
# extra contours.
|
| 1122 |
+
if (isinstance(self.norm, (colors.BoundaryNorm, colors.NoNorm))
|
| 1123 |
+
or self.boundaries is not None):
|
| 1124 |
+
# not using a norm.
|
| 1125 |
+
y = y * (self.vmax - self.vmin) + self.vmin
|
| 1126 |
+
else:
|
| 1127 |
+
# Update the norm values in a context manager as it is only
|
| 1128 |
+
# a temporary change and we don't want to propagate any signals
|
| 1129 |
+
# attached to the norm (callbacks.blocked).
|
| 1130 |
+
with (self.norm.callbacks.blocked(),
|
| 1131 |
+
cbook._setattr_cm(self.norm, vmin=self.vmin, vmax=self.vmax)):
|
| 1132 |
+
y = self.norm.inverse(y)
|
| 1133 |
+
self._y = y
|
| 1134 |
+
X, Y = np.meshgrid([0., 1.], y)
|
| 1135 |
+
if self.orientation == 'vertical':
|
| 1136 |
+
return (X, Y)
|
| 1137 |
+
else:
|
| 1138 |
+
return (Y, X)
|
| 1139 |
+
|
| 1140 |
+
def _forward_boundaries(self, x):
|
| 1141 |
+
# map boundaries equally between 0 and 1...
|
| 1142 |
+
b = self._boundaries
|
| 1143 |
+
y = np.interp(x, b, np.linspace(0, 1, len(b)))
|
| 1144 |
+
# the following avoids ticks in the extends:
|
| 1145 |
+
eps = (b[-1] - b[0]) * 1e-6
|
| 1146 |
+
# map these _well_ out of bounds to keep any ticks out
|
| 1147 |
+
# of the extends region...
|
| 1148 |
+
y[x < b[0]-eps] = -1
|
| 1149 |
+
y[x > b[-1]+eps] = 2
|
| 1150 |
+
return y
|
| 1151 |
+
|
| 1152 |
+
def _inverse_boundaries(self, x):
|
| 1153 |
+
# invert the above...
|
| 1154 |
+
b = self._boundaries
|
| 1155 |
+
return np.interp(x, np.linspace(0, 1, len(b)), b)
|
| 1156 |
+
|
| 1157 |
+
def _reset_locator_formatter_scale(self):
|
| 1158 |
+
"""
|
| 1159 |
+
Reset the locator et al to defaults. Any user-hardcoded changes
|
| 1160 |
+
need to be re-entered if this gets called (either at init, or when
|
| 1161 |
+
the mappable normal gets changed: Colorbar.update_normal)
|
| 1162 |
+
"""
|
| 1163 |
+
self._process_values()
|
| 1164 |
+
self._locator = None
|
| 1165 |
+
self._minorlocator = None
|
| 1166 |
+
self._formatter = None
|
| 1167 |
+
self._minorformatter = None
|
| 1168 |
+
if (isinstance(self.mappable, contour.ContourSet) and
|
| 1169 |
+
isinstance(self.norm, colors.LogNorm)):
|
| 1170 |
+
# if contours have lognorm, give them a log scale...
|
| 1171 |
+
self._set_scale('log')
|
| 1172 |
+
elif (self.boundaries is not None or
|
| 1173 |
+
isinstance(self.norm, colors.BoundaryNorm)):
|
| 1174 |
+
if self.spacing == 'uniform':
|
| 1175 |
+
funcs = (self._forward_boundaries, self._inverse_boundaries)
|
| 1176 |
+
self._set_scale('function', functions=funcs)
|
| 1177 |
+
elif self.spacing == 'proportional':
|
| 1178 |
+
self._set_scale('linear')
|
| 1179 |
+
elif getattr(self.norm, '_scale', None):
|
| 1180 |
+
# use the norm's scale (if it exists and is not None):
|
| 1181 |
+
self._set_scale(self.norm._scale)
|
| 1182 |
+
elif type(self.norm) is colors.Normalize:
|
| 1183 |
+
# plain Normalize:
|
| 1184 |
+
self._set_scale('linear')
|
| 1185 |
+
else:
|
| 1186 |
+
# norm._scale is None or not an attr: derive the scale from
|
| 1187 |
+
# the Norm:
|
| 1188 |
+
funcs = (self.norm, self.norm.inverse)
|
| 1189 |
+
self._set_scale('function', functions=funcs)
|
| 1190 |
+
|
| 1191 |
+
def _locate(self, x):
|
| 1192 |
+
"""
|
| 1193 |
+
Given a set of color data values, return their
|
| 1194 |
+
corresponding colorbar data coordinates.
|
| 1195 |
+
"""
|
| 1196 |
+
if isinstance(self.norm, (colors.NoNorm, colors.BoundaryNorm)):
|
| 1197 |
+
b = self._boundaries
|
| 1198 |
+
xn = x
|
| 1199 |
+
else:
|
| 1200 |
+
# Do calculations using normalized coordinates so
|
| 1201 |
+
# as to make the interpolation more accurate.
|
| 1202 |
+
b = self.norm(self._boundaries, clip=False).filled()
|
| 1203 |
+
xn = self.norm(x, clip=False).filled()
|
| 1204 |
+
|
| 1205 |
+
bunique = b[self._inside]
|
| 1206 |
+
yunique = self._y
|
| 1207 |
+
|
| 1208 |
+
z = np.interp(xn, bunique, yunique)
|
| 1209 |
+
return z
|
| 1210 |
+
|
| 1211 |
+
# trivial helpers
|
| 1212 |
+
|
| 1213 |
+
def _uniform_y(self, N):
|
| 1214 |
+
"""
|
| 1215 |
+
Return colorbar data coordinates for *N* uniformly
|
| 1216 |
+
spaced boundaries, plus extension lengths if required.
|
| 1217 |
+
"""
|
| 1218 |
+
automin = automax = 1. / (N - 1.)
|
| 1219 |
+
extendlength = self._get_extension_lengths(self.extendfrac,
|
| 1220 |
+
automin, automax,
|
| 1221 |
+
default=0.05)
|
| 1222 |
+
y = np.linspace(0, 1, N)
|
| 1223 |
+
return y, extendlength
|
| 1224 |
+
|
| 1225 |
+
def _proportional_y(self):
|
| 1226 |
+
"""
|
| 1227 |
+
Return colorbar data coordinates for the boundaries of
|
| 1228 |
+
a proportional colorbar, plus extension lengths if required:
|
| 1229 |
+
"""
|
| 1230 |
+
if (isinstance(self.norm, colors.BoundaryNorm) or
|
| 1231 |
+
self.boundaries is not None):
|
| 1232 |
+
y = (self._boundaries - self._boundaries[self._inside][0])
|
| 1233 |
+
y = y / (self._boundaries[self._inside][-1] -
|
| 1234 |
+
self._boundaries[self._inside][0])
|
| 1235 |
+
# need yscaled the same as the axes scale to get
|
| 1236 |
+
# the extend lengths.
|
| 1237 |
+
if self.spacing == 'uniform':
|
| 1238 |
+
yscaled = self._forward_boundaries(self._boundaries)
|
| 1239 |
+
else:
|
| 1240 |
+
yscaled = y
|
| 1241 |
+
else:
|
| 1242 |
+
y = self.norm(self._boundaries.copy())
|
| 1243 |
+
y = np.ma.filled(y, np.nan)
|
| 1244 |
+
# the norm and the scale should be the same...
|
| 1245 |
+
yscaled = y
|
| 1246 |
+
y = y[self._inside]
|
| 1247 |
+
yscaled = yscaled[self._inside]
|
| 1248 |
+
# normalize from 0..1:
|
| 1249 |
+
norm = colors.Normalize(y[0], y[-1])
|
| 1250 |
+
y = np.ma.filled(norm(y), np.nan)
|
| 1251 |
+
norm = colors.Normalize(yscaled[0], yscaled[-1])
|
| 1252 |
+
yscaled = np.ma.filled(norm(yscaled), np.nan)
|
| 1253 |
+
# make the lower and upper extend lengths proportional to the lengths
|
| 1254 |
+
# of the first and last boundary spacing (if extendfrac='auto'):
|
| 1255 |
+
automin = yscaled[1] - yscaled[0]
|
| 1256 |
+
automax = yscaled[-1] - yscaled[-2]
|
| 1257 |
+
extendlength = [0, 0]
|
| 1258 |
+
if self._extend_lower() or self._extend_upper():
|
| 1259 |
+
extendlength = self._get_extension_lengths(
|
| 1260 |
+
self.extendfrac, automin, automax, default=0.05)
|
| 1261 |
+
return y, extendlength
|
| 1262 |
+
|
| 1263 |
+
def _get_extension_lengths(self, frac, automin, automax, default=0.05):
|
| 1264 |
+
"""
|
| 1265 |
+
Return the lengths of colorbar extensions.
|
| 1266 |
+
|
| 1267 |
+
This is a helper method for _uniform_y and _proportional_y.
|
| 1268 |
+
"""
|
| 1269 |
+
# Set the default value.
|
| 1270 |
+
extendlength = np.array([default, default])
|
| 1271 |
+
if isinstance(frac, str):
|
| 1272 |
+
_api.check_in_list(['auto'], extendfrac=frac.lower())
|
| 1273 |
+
# Use the provided values when 'auto' is required.
|
| 1274 |
+
extendlength[:] = [automin, automax]
|
| 1275 |
+
elif frac is not None:
|
| 1276 |
+
try:
|
| 1277 |
+
# Try to set min and max extension fractions directly.
|
| 1278 |
+
extendlength[:] = frac
|
| 1279 |
+
# If frac is a sequence containing None then NaN may
|
| 1280 |
+
# be encountered. This is an error.
|
| 1281 |
+
if np.isnan(extendlength).any():
|
| 1282 |
+
raise ValueError()
|
| 1283 |
+
except (TypeError, ValueError) as err:
|
| 1284 |
+
# Raise an error on encountering an invalid value for frac.
|
| 1285 |
+
raise ValueError('invalid value for extendfrac') from err
|
| 1286 |
+
return extendlength
|
| 1287 |
+
|
| 1288 |
+
def _extend_lower(self):
|
| 1289 |
+
"""Return whether the lower limit is open ended."""
|
| 1290 |
+
minmax = "max" if self.long_axis.get_inverted() else "min"
|
| 1291 |
+
return self.extend in ('both', minmax)
|
| 1292 |
+
|
| 1293 |
+
def _extend_upper(self):
|
| 1294 |
+
"""Return whether the upper limit is open ended."""
|
| 1295 |
+
minmax = "min" if self.long_axis.get_inverted() else "max"
|
| 1296 |
+
return self.extend in ('both', minmax)
|
| 1297 |
+
|
| 1298 |
+
def _short_axis(self):
|
| 1299 |
+
"""Return the short axis"""
|
| 1300 |
+
if self.orientation == 'vertical':
|
| 1301 |
+
return self.ax.xaxis
|
| 1302 |
+
return self.ax.yaxis
|
| 1303 |
+
|
| 1304 |
+
def _get_view(self):
|
| 1305 |
+
# docstring inherited
|
| 1306 |
+
# An interactive view for a colorbar is the norm's vmin/vmax
|
| 1307 |
+
return self.norm.vmin, self.norm.vmax
|
| 1308 |
+
|
| 1309 |
+
def _set_view(self, view):
|
| 1310 |
+
# docstring inherited
|
| 1311 |
+
# An interactive view for a colorbar is the norm's vmin/vmax
|
| 1312 |
+
self.norm.vmin, self.norm.vmax = view
|
| 1313 |
+
|
| 1314 |
+
def _set_view_from_bbox(self, bbox, direction='in',
|
| 1315 |
+
mode=None, twinx=False, twiny=False):
|
| 1316 |
+
# docstring inherited
|
| 1317 |
+
# For colorbars, we use the zoom bbox to scale the norm's vmin/vmax
|
| 1318 |
+
new_xbound, new_ybound = self.ax._prepare_view_from_bbox(
|
| 1319 |
+
bbox, direction=direction, mode=mode, twinx=twinx, twiny=twiny)
|
| 1320 |
+
if self.orientation == 'horizontal':
|
| 1321 |
+
self.norm.vmin, self.norm.vmax = new_xbound
|
| 1322 |
+
elif self.orientation == 'vertical':
|
| 1323 |
+
self.norm.vmin, self.norm.vmax = new_ybound
|
| 1324 |
+
|
| 1325 |
+
def drag_pan(self, button, key, x, y):
|
| 1326 |
+
# docstring inherited
|
| 1327 |
+
points = self.ax._get_pan_points(button, key, x, y)
|
| 1328 |
+
if points is not None:
|
| 1329 |
+
if self.orientation == 'horizontal':
|
| 1330 |
+
self.norm.vmin, self.norm.vmax = points[:, 0]
|
| 1331 |
+
elif self.orientation == 'vertical':
|
| 1332 |
+
self.norm.vmin, self.norm.vmax = points[:, 1]
|
| 1333 |
+
|
| 1334 |
+
|
| 1335 |
+
ColorbarBase = Colorbar # Backcompat API
|
| 1336 |
+
|
| 1337 |
+
|
| 1338 |
+
def _normalize_location_orientation(location, orientation):
|
| 1339 |
+
if location is None:
|
| 1340 |
+
location = _get_ticklocation_from_orientation(orientation)
|
| 1341 |
+
loc_settings = _api.check_getitem({
|
| 1342 |
+
"left": {"location": "left", "anchor": (1.0, 0.5),
|
| 1343 |
+
"panchor": (0.0, 0.5), "pad": 0.10},
|
| 1344 |
+
"right": {"location": "right", "anchor": (0.0, 0.5),
|
| 1345 |
+
"panchor": (1.0, 0.5), "pad": 0.05},
|
| 1346 |
+
"top": {"location": "top", "anchor": (0.5, 0.0),
|
| 1347 |
+
"panchor": (0.5, 1.0), "pad": 0.05},
|
| 1348 |
+
"bottom": {"location": "bottom", "anchor": (0.5, 1.0),
|
| 1349 |
+
"panchor": (0.5, 0.0), "pad": 0.15},
|
| 1350 |
+
}, location=location)
|
| 1351 |
+
loc_settings["orientation"] = _get_orientation_from_location(location)
|
| 1352 |
+
if orientation is not None and orientation != loc_settings["orientation"]:
|
| 1353 |
+
# Allow the user to pass both if they are consistent.
|
| 1354 |
+
raise TypeError("location and orientation are mutually exclusive")
|
| 1355 |
+
return loc_settings
|
| 1356 |
+
|
| 1357 |
+
|
| 1358 |
+
def _get_orientation_from_location(location):
|
| 1359 |
+
return _api.check_getitem(
|
| 1360 |
+
{None: None, "left": "vertical", "right": "vertical",
|
| 1361 |
+
"top": "horizontal", "bottom": "horizontal"}, location=location)
|
| 1362 |
+
|
| 1363 |
+
|
| 1364 |
+
def _get_ticklocation_from_orientation(orientation):
|
| 1365 |
+
return _api.check_getitem(
|
| 1366 |
+
{None: "right", "vertical": "right", "horizontal": "bottom"},
|
| 1367 |
+
orientation=orientation)
|
| 1368 |
+
|
| 1369 |
+
|
| 1370 |
+
@_docstring.interpd
|
| 1371 |
+
def make_axes(parents, location=None, orientation=None, fraction=0.15,
|
| 1372 |
+
shrink=1.0, aspect=20, **kwargs):
|
| 1373 |
+
"""
|
| 1374 |
+
Create an `~.axes.Axes` suitable for a colorbar.
|
| 1375 |
+
|
| 1376 |
+
The Axes is placed in the figure of the *parents* Axes, by resizing and
|
| 1377 |
+
repositioning *parents*.
|
| 1378 |
+
|
| 1379 |
+
Parameters
|
| 1380 |
+
----------
|
| 1381 |
+
parents : `~matplotlib.axes.Axes` or iterable or `numpy.ndarray` of `~.axes.Axes`
|
| 1382 |
+
The Axes to use as parents for placing the colorbar.
|
| 1383 |
+
%(_make_axes_kw_doc)s
|
| 1384 |
+
|
| 1385 |
+
Returns
|
| 1386 |
+
-------
|
| 1387 |
+
cax : `~matplotlib.axes.Axes`
|
| 1388 |
+
The child Axes.
|
| 1389 |
+
kwargs : dict
|
| 1390 |
+
The reduced keyword dictionary to be passed when creating the colorbar
|
| 1391 |
+
instance.
|
| 1392 |
+
"""
|
| 1393 |
+
loc_settings = _normalize_location_orientation(location, orientation)
|
| 1394 |
+
# put appropriate values into the kwargs dict for passing back to
|
| 1395 |
+
# the Colorbar class
|
| 1396 |
+
kwargs['orientation'] = loc_settings['orientation']
|
| 1397 |
+
location = kwargs['ticklocation'] = loc_settings['location']
|
| 1398 |
+
|
| 1399 |
+
anchor = kwargs.pop('anchor', loc_settings['anchor'])
|
| 1400 |
+
panchor = kwargs.pop('panchor', loc_settings['panchor'])
|
| 1401 |
+
aspect0 = aspect
|
| 1402 |
+
# turn parents into a list if it is not already. Note we cannot
|
| 1403 |
+
# use .flatten or .ravel as these copy the references rather than
|
| 1404 |
+
# reuse them, leading to a memory leak
|
| 1405 |
+
if isinstance(parents, np.ndarray):
|
| 1406 |
+
parents = list(parents.flat)
|
| 1407 |
+
elif np.iterable(parents):
|
| 1408 |
+
parents = list(parents)
|
| 1409 |
+
else:
|
| 1410 |
+
parents = [parents]
|
| 1411 |
+
|
| 1412 |
+
fig = parents[0].get_figure()
|
| 1413 |
+
|
| 1414 |
+
pad0 = 0.05 if fig.get_constrained_layout() else loc_settings['pad']
|
| 1415 |
+
pad = kwargs.pop('pad', pad0)
|
| 1416 |
+
|
| 1417 |
+
if not all(fig is ax.get_figure() for ax in parents):
|
| 1418 |
+
raise ValueError('Unable to create a colorbar Axes as not all '
|
| 1419 |
+
'parents share the same figure.')
|
| 1420 |
+
|
| 1421 |
+
# take a bounding box around all of the given Axes
|
| 1422 |
+
parents_bbox = mtransforms.Bbox.union(
|
| 1423 |
+
[ax.get_position(original=True).frozen() for ax in parents])
|
| 1424 |
+
|
| 1425 |
+
pb = parents_bbox
|
| 1426 |
+
if location in ('left', 'right'):
|
| 1427 |
+
if location == 'left':
|
| 1428 |
+
pbcb, _, pb1 = pb.splitx(fraction, fraction + pad)
|
| 1429 |
+
else:
|
| 1430 |
+
pb1, _, pbcb = pb.splitx(1 - fraction - pad, 1 - fraction)
|
| 1431 |
+
pbcb = pbcb.shrunk(1.0, shrink).anchored(anchor, pbcb)
|
| 1432 |
+
else:
|
| 1433 |
+
if location == 'bottom':
|
| 1434 |
+
pbcb, _, pb1 = pb.splity(fraction, fraction + pad)
|
| 1435 |
+
else:
|
| 1436 |
+
pb1, _, pbcb = pb.splity(1 - fraction - pad, 1 - fraction)
|
| 1437 |
+
pbcb = pbcb.shrunk(shrink, 1.0).anchored(anchor, pbcb)
|
| 1438 |
+
|
| 1439 |
+
# define the aspect ratio in terms of y's per x rather than x's per y
|
| 1440 |
+
aspect = 1.0 / aspect
|
| 1441 |
+
|
| 1442 |
+
# define a transform which takes us from old axes coordinates to
|
| 1443 |
+
# new axes coordinates
|
| 1444 |
+
shrinking_trans = mtransforms.BboxTransform(parents_bbox, pb1)
|
| 1445 |
+
|
| 1446 |
+
# transform each of the Axes in parents using the new transform
|
| 1447 |
+
for ax in parents:
|
| 1448 |
+
new_posn = shrinking_trans.transform(ax.get_position(original=True))
|
| 1449 |
+
new_posn = mtransforms.Bbox(new_posn)
|
| 1450 |
+
ax._set_position(new_posn)
|
| 1451 |
+
if panchor is not False:
|
| 1452 |
+
ax.set_anchor(panchor)
|
| 1453 |
+
|
| 1454 |
+
cax = fig.add_axes(pbcb, label="<colorbar>")
|
| 1455 |
+
for a in parents:
|
| 1456 |
+
# tell the parent it has a colorbar
|
| 1457 |
+
a._colorbars += [cax]
|
| 1458 |
+
cax._colorbar_info = dict(
|
| 1459 |
+
parents=parents,
|
| 1460 |
+
location=location,
|
| 1461 |
+
shrink=shrink,
|
| 1462 |
+
anchor=anchor,
|
| 1463 |
+
panchor=panchor,
|
| 1464 |
+
fraction=fraction,
|
| 1465 |
+
aspect=aspect0,
|
| 1466 |
+
pad=pad)
|
| 1467 |
+
# and we need to set the aspect ratio by hand...
|
| 1468 |
+
cax.set_anchor(anchor)
|
| 1469 |
+
cax.set_box_aspect(aspect)
|
| 1470 |
+
cax.set_aspect('auto')
|
| 1471 |
+
|
| 1472 |
+
return cax, kwargs
|
| 1473 |
+
|
| 1474 |
+
|
| 1475 |
+
@_docstring.interpd
|
| 1476 |
+
def make_axes_gridspec(parent, *, location=None, orientation=None,
|
| 1477 |
+
fraction=0.15, shrink=1.0, aspect=20, **kwargs):
|
| 1478 |
+
"""
|
| 1479 |
+
Create an `~.axes.Axes` suitable for a colorbar.
|
| 1480 |
+
|
| 1481 |
+
The Axes is placed in the figure of the *parent* Axes, by resizing and
|
| 1482 |
+
repositioning *parent*.
|
| 1483 |
+
|
| 1484 |
+
This function is similar to `.make_axes` and mostly compatible with it.
|
| 1485 |
+
Primary differences are
|
| 1486 |
+
|
| 1487 |
+
- `.make_axes_gridspec` requires the *parent* to have a subplotspec.
|
| 1488 |
+
- `.make_axes` positions the Axes in figure coordinates;
|
| 1489 |
+
`.make_axes_gridspec` positions it using a subplotspec.
|
| 1490 |
+
- `.make_axes` updates the position of the parent. `.make_axes_gridspec`
|
| 1491 |
+
replaces the parent gridspec with a new one.
|
| 1492 |
+
|
| 1493 |
+
Parameters
|
| 1494 |
+
----------
|
| 1495 |
+
parent : `~matplotlib.axes.Axes`
|
| 1496 |
+
The Axes to use as parent for placing the colorbar.
|
| 1497 |
+
%(_make_axes_kw_doc)s
|
| 1498 |
+
|
| 1499 |
+
Returns
|
| 1500 |
+
-------
|
| 1501 |
+
cax : `~matplotlib.axes.Axes`
|
| 1502 |
+
The child Axes.
|
| 1503 |
+
kwargs : dict
|
| 1504 |
+
The reduced keyword dictionary to be passed when creating the colorbar
|
| 1505 |
+
instance.
|
| 1506 |
+
"""
|
| 1507 |
+
|
| 1508 |
+
loc_settings = _normalize_location_orientation(location, orientation)
|
| 1509 |
+
kwargs['orientation'] = loc_settings['orientation']
|
| 1510 |
+
location = kwargs['ticklocation'] = loc_settings['location']
|
| 1511 |
+
|
| 1512 |
+
aspect0 = aspect
|
| 1513 |
+
anchor = kwargs.pop('anchor', loc_settings['anchor'])
|
| 1514 |
+
panchor = kwargs.pop('panchor', loc_settings['panchor'])
|
| 1515 |
+
pad = kwargs.pop('pad', loc_settings["pad"])
|
| 1516 |
+
wh_space = 2 * pad / (1 - pad)
|
| 1517 |
+
|
| 1518 |
+
if location in ('left', 'right'):
|
| 1519 |
+
gs = parent.get_subplotspec().subgridspec(
|
| 1520 |
+
3, 2, wspace=wh_space, hspace=0,
|
| 1521 |
+
height_ratios=[(1-anchor[1])*(1-shrink), shrink, anchor[1]*(1-shrink)])
|
| 1522 |
+
if location == 'left':
|
| 1523 |
+
gs.set_width_ratios([fraction, 1 - fraction - pad])
|
| 1524 |
+
ss_main = gs[:, 1]
|
| 1525 |
+
ss_cb = gs[1, 0]
|
| 1526 |
+
else:
|
| 1527 |
+
gs.set_width_ratios([1 - fraction - pad, fraction])
|
| 1528 |
+
ss_main = gs[:, 0]
|
| 1529 |
+
ss_cb = gs[1, 1]
|
| 1530 |
+
else:
|
| 1531 |
+
gs = parent.get_subplotspec().subgridspec(
|
| 1532 |
+
2, 3, hspace=wh_space, wspace=0,
|
| 1533 |
+
width_ratios=[anchor[0]*(1-shrink), shrink, (1-anchor[0])*(1-shrink)])
|
| 1534 |
+
if location == 'top':
|
| 1535 |
+
gs.set_height_ratios([fraction, 1 - fraction - pad])
|
| 1536 |
+
ss_main = gs[1, :]
|
| 1537 |
+
ss_cb = gs[0, 1]
|
| 1538 |
+
else:
|
| 1539 |
+
gs.set_height_ratios([1 - fraction - pad, fraction])
|
| 1540 |
+
ss_main = gs[0, :]
|
| 1541 |
+
ss_cb = gs[1, 1]
|
| 1542 |
+
aspect = 1 / aspect
|
| 1543 |
+
|
| 1544 |
+
parent.set_subplotspec(ss_main)
|
| 1545 |
+
if panchor is not False:
|
| 1546 |
+
parent.set_anchor(panchor)
|
| 1547 |
+
|
| 1548 |
+
fig = parent.get_figure()
|
| 1549 |
+
cax = fig.add_subplot(ss_cb, label="<colorbar>")
|
| 1550 |
+
cax.set_anchor(anchor)
|
| 1551 |
+
cax.set_box_aspect(aspect)
|
| 1552 |
+
cax.set_aspect('auto')
|
| 1553 |
+
cax._colorbar_info = dict(
|
| 1554 |
+
location=location,
|
| 1555 |
+
parents=[parent],
|
| 1556 |
+
shrink=shrink,
|
| 1557 |
+
anchor=anchor,
|
| 1558 |
+
panchor=panchor,
|
| 1559 |
+
fraction=fraction,
|
| 1560 |
+
aspect=aspect0,
|
| 1561 |
+
pad=pad)
|
| 1562 |
+
|
| 1563 |
+
return cax, kwargs
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/colorbar.pyi
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import matplotlib.spines as mspines
|
| 2 |
+
from matplotlib import cm, collections, colors, contour, colorizer
|
| 3 |
+
from matplotlib.axes import Axes
|
| 4 |
+
from matplotlib.axis import Axis
|
| 5 |
+
from matplotlib.backend_bases import RendererBase
|
| 6 |
+
from matplotlib.patches import Patch
|
| 7 |
+
from matplotlib.ticker import Locator, Formatter
|
| 8 |
+
from matplotlib.transforms import Bbox
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
from numpy.typing import ArrayLike
|
| 12 |
+
from collections.abc import Sequence
|
| 13 |
+
from typing import Any, Literal, overload
|
| 14 |
+
from .typing import ColorType
|
| 15 |
+
|
| 16 |
+
class _ColorbarSpine(mspines.Spines):
|
| 17 |
+
def __init__(self, axes: Axes): ...
|
| 18 |
+
def get_window_extent(self, renderer: RendererBase | None = ...) -> Bbox:...
|
| 19 |
+
def set_xy(self, xy: ArrayLike) -> None: ...
|
| 20 |
+
def draw(self, renderer: RendererBase | None) -> None:...
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class Colorbar:
|
| 24 |
+
n_rasterize: int
|
| 25 |
+
mappable: cm.ScalarMappable | colorizer.ColorizingArtist
|
| 26 |
+
ax: Axes
|
| 27 |
+
alpha: float | None
|
| 28 |
+
cmap: colors.Colormap
|
| 29 |
+
norm: colors.Normalize
|
| 30 |
+
values: Sequence[float] | None
|
| 31 |
+
boundaries: Sequence[float] | None
|
| 32 |
+
extend: Literal["neither", "both", "min", "max"]
|
| 33 |
+
spacing: Literal["uniform", "proportional"]
|
| 34 |
+
orientation: Literal["vertical", "horizontal"]
|
| 35 |
+
drawedges: bool
|
| 36 |
+
extendfrac: Literal["auto"] | float | Sequence[float] | None
|
| 37 |
+
extendrect: bool
|
| 38 |
+
solids: None | collections.QuadMesh
|
| 39 |
+
solids_patches: list[Patch]
|
| 40 |
+
lines: list[collections.LineCollection]
|
| 41 |
+
outline: _ColorbarSpine
|
| 42 |
+
dividers: collections.LineCollection
|
| 43 |
+
ticklocation: Literal["left", "right", "top", "bottom"]
|
| 44 |
+
def __init__(
|
| 45 |
+
self,
|
| 46 |
+
ax: Axes,
|
| 47 |
+
mappable: cm.ScalarMappable | colorizer.ColorizingArtist | None = ...,
|
| 48 |
+
*,
|
| 49 |
+
cmap: str | colors.Colormap | None = ...,
|
| 50 |
+
norm: colors.Normalize | None = ...,
|
| 51 |
+
alpha: float | None = ...,
|
| 52 |
+
values: Sequence[float] | None = ...,
|
| 53 |
+
boundaries: Sequence[float] | None = ...,
|
| 54 |
+
orientation: Literal["vertical", "horizontal"] | None = ...,
|
| 55 |
+
ticklocation: Literal["auto", "left", "right", "top", "bottom"] = ...,
|
| 56 |
+
extend: Literal["neither", "both", "min", "max"] | None = ...,
|
| 57 |
+
spacing: Literal["uniform", "proportional"] = ...,
|
| 58 |
+
ticks: Sequence[float] | Locator | None = ...,
|
| 59 |
+
format: str | Formatter | None = ...,
|
| 60 |
+
drawedges: bool = ...,
|
| 61 |
+
extendfrac: Literal["auto"] | float | Sequence[float] | None = ...,
|
| 62 |
+
extendrect: bool = ...,
|
| 63 |
+
label: str = ...,
|
| 64 |
+
location: Literal["left", "right", "top", "bottom"] | None = ...
|
| 65 |
+
) -> None: ...
|
| 66 |
+
@property
|
| 67 |
+
def long_axis(self) -> Axis: ...
|
| 68 |
+
@property
|
| 69 |
+
def locator(self) -> Locator: ...
|
| 70 |
+
@locator.setter
|
| 71 |
+
def locator(self, loc: Locator) -> None: ...
|
| 72 |
+
@property
|
| 73 |
+
def minorlocator(self) -> Locator: ...
|
| 74 |
+
@minorlocator.setter
|
| 75 |
+
def minorlocator(self, loc: Locator) -> None: ...
|
| 76 |
+
@property
|
| 77 |
+
def formatter(self) -> Formatter: ...
|
| 78 |
+
@formatter.setter
|
| 79 |
+
def formatter(self, fmt: Formatter) -> None: ...
|
| 80 |
+
@property
|
| 81 |
+
def minorformatter(self) -> Formatter: ...
|
| 82 |
+
@minorformatter.setter
|
| 83 |
+
def minorformatter(self, fmt: Formatter) -> None: ...
|
| 84 |
+
def update_normal(self, mappable: cm.ScalarMappable | None = ...) -> None: ...
|
| 85 |
+
@overload
|
| 86 |
+
def add_lines(self, CS: contour.ContourSet, erase: bool = ...) -> None: ...
|
| 87 |
+
@overload
|
| 88 |
+
def add_lines(
|
| 89 |
+
self,
|
| 90 |
+
levels: ArrayLike,
|
| 91 |
+
colors: ColorType | Sequence[ColorType],
|
| 92 |
+
linewidths: float | ArrayLike,
|
| 93 |
+
erase: bool = ...,
|
| 94 |
+
) -> None: ...
|
| 95 |
+
def update_ticks(self) -> None: ...
|
| 96 |
+
def set_ticks(
|
| 97 |
+
self,
|
| 98 |
+
ticks: Sequence[float] | Locator,
|
| 99 |
+
*,
|
| 100 |
+
labels: Sequence[str] | None = ...,
|
| 101 |
+
minor: bool = ...,
|
| 102 |
+
**kwargs
|
| 103 |
+
) -> None: ...
|
| 104 |
+
def get_ticks(self, minor: bool = ...) -> np.ndarray: ...
|
| 105 |
+
def set_ticklabels(
|
| 106 |
+
self,
|
| 107 |
+
ticklabels: Sequence[str],
|
| 108 |
+
*,
|
| 109 |
+
minor: bool = ...,
|
| 110 |
+
**kwargs
|
| 111 |
+
) -> None: ...
|
| 112 |
+
def minorticks_on(self) -> None: ...
|
| 113 |
+
def minorticks_off(self) -> None: ...
|
| 114 |
+
def set_label(self, label: str, *, loc: str | None = ..., **kwargs) -> None: ...
|
| 115 |
+
def set_alpha(self, alpha: float | np.ndarray) -> None: ...
|
| 116 |
+
def remove(self) -> None: ...
|
| 117 |
+
def drag_pan(self, button: Any, key: Any, x: float, y: float) -> None: ...
|
| 118 |
+
|
| 119 |
+
ColorbarBase = Colorbar
|
| 120 |
+
|
| 121 |
+
def make_axes(
|
| 122 |
+
parents: Axes | list[Axes] | np.ndarray,
|
| 123 |
+
location: Literal["left", "right", "top", "bottom"] | None = ...,
|
| 124 |
+
orientation: Literal["vertical", "horizontal"] | None = ...,
|
| 125 |
+
fraction: float = ...,
|
| 126 |
+
shrink: float = ...,
|
| 127 |
+
aspect: float = ...,
|
| 128 |
+
**kwargs
|
| 129 |
+
) -> tuple[Axes, dict[str, Any]]: ...
|
| 130 |
+
def make_axes_gridspec(
|
| 131 |
+
parent: Axes,
|
| 132 |
+
*,
|
| 133 |
+
location: Literal["left", "right", "top", "bottom"] | None = ...,
|
| 134 |
+
orientation: Literal["vertical", "horizontal"] | None = ...,
|
| 135 |
+
fraction: float = ...,
|
| 136 |
+
shrink: float = ...,
|
| 137 |
+
aspect: float = ...,
|
| 138 |
+
**kwargs
|
| 139 |
+
) -> tuple[Axes, dict[str, Any]]: ...
|
infer_4_30_0/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, BoundaryN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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)
|
infer_4_30_0/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")
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/figure.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/ft2font.pyi
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from enum import Enum, Flag
|
| 2 |
+
import sys
|
| 3 |
+
from typing import BinaryIO, Literal, TypedDict, final, overload, cast
|
| 4 |
+
from typing_extensions import Buffer # < Py 3.12
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
from numpy.typing import NDArray
|
| 8 |
+
|
| 9 |
+
__freetype_build_type__: str
|
| 10 |
+
__freetype_version__: str
|
| 11 |
+
|
| 12 |
+
class FaceFlags(Flag):
|
| 13 |
+
SCALABLE = cast(int, ...)
|
| 14 |
+
FIXED_SIZES = cast(int, ...)
|
| 15 |
+
FIXED_WIDTH = cast(int, ...)
|
| 16 |
+
SFNT = cast(int, ...)
|
| 17 |
+
HORIZONTAL = cast(int, ...)
|
| 18 |
+
VERTICAL = cast(int, ...)
|
| 19 |
+
KERNING = cast(int, ...)
|
| 20 |
+
FAST_GLYPHS = cast(int, ...)
|
| 21 |
+
MULTIPLE_MASTERS = cast(int, ...)
|
| 22 |
+
GLYPH_NAMES = cast(int, ...)
|
| 23 |
+
EXTERNAL_STREAM = cast(int, ...)
|
| 24 |
+
HINTER = cast(int, ...)
|
| 25 |
+
CID_KEYED = cast(int, ...)
|
| 26 |
+
TRICKY = cast(int, ...)
|
| 27 |
+
COLOR = cast(int, ...)
|
| 28 |
+
# VARIATION = cast(int, ...) # FT 2.9
|
| 29 |
+
# SVG = cast(int, ...) # FT 2.12
|
| 30 |
+
# SBIX = cast(int, ...) # FT 2.12
|
| 31 |
+
# SBIX_OVERLAY = cast(int, ...) # FT 2.12
|
| 32 |
+
|
| 33 |
+
class Kerning(Enum):
|
| 34 |
+
DEFAULT = cast(int, ...)
|
| 35 |
+
UNFITTED = cast(int, ...)
|
| 36 |
+
UNSCALED = cast(int, ...)
|
| 37 |
+
|
| 38 |
+
class LoadFlags(Flag):
|
| 39 |
+
DEFAULT = cast(int, ...)
|
| 40 |
+
NO_SCALE = cast(int, ...)
|
| 41 |
+
NO_HINTING = cast(int, ...)
|
| 42 |
+
RENDER = cast(int, ...)
|
| 43 |
+
NO_BITMAP = cast(int, ...)
|
| 44 |
+
VERTICAL_LAYOUT = cast(int, ...)
|
| 45 |
+
FORCE_AUTOHINT = cast(int, ...)
|
| 46 |
+
CROP_BITMAP = cast(int, ...)
|
| 47 |
+
PEDANTIC = cast(int, ...)
|
| 48 |
+
IGNORE_GLOBAL_ADVANCE_WIDTH = cast(int, ...)
|
| 49 |
+
NO_RECURSE = cast(int, ...)
|
| 50 |
+
IGNORE_TRANSFORM = cast(int, ...)
|
| 51 |
+
MONOCHROME = cast(int, ...)
|
| 52 |
+
LINEAR_DESIGN = cast(int, ...)
|
| 53 |
+
NO_AUTOHINT = cast(int, ...)
|
| 54 |
+
COLOR = cast(int, ...)
|
| 55 |
+
COMPUTE_METRICS = cast(int, ...) # FT 2.6.1
|
| 56 |
+
# BITMAP_METRICS_ONLY = cast(int, ...) # FT 2.7.1
|
| 57 |
+
# NO_SVG = cast(int, ...) # FT 2.13.1
|
| 58 |
+
# The following should be unique, but the above can be OR'd together.
|
| 59 |
+
TARGET_NORMAL = cast(int, ...)
|
| 60 |
+
TARGET_LIGHT = cast(int, ...)
|
| 61 |
+
TARGET_MONO = cast(int, ...)
|
| 62 |
+
TARGET_LCD = cast(int, ...)
|
| 63 |
+
TARGET_LCD_V = cast(int, ...)
|
| 64 |
+
|
| 65 |
+
class StyleFlags(Flag):
|
| 66 |
+
NORMAL = cast(int, ...)
|
| 67 |
+
ITALIC = cast(int, ...)
|
| 68 |
+
BOLD = cast(int, ...)
|
| 69 |
+
|
| 70 |
+
class _SfntHeadDict(TypedDict):
|
| 71 |
+
version: tuple[int, int]
|
| 72 |
+
fontRevision: tuple[int, int]
|
| 73 |
+
checkSumAdjustment: int
|
| 74 |
+
magicNumber: int
|
| 75 |
+
flags: int
|
| 76 |
+
unitsPerEm: int
|
| 77 |
+
created: tuple[int, int]
|
| 78 |
+
modified: tuple[int, int]
|
| 79 |
+
xMin: int
|
| 80 |
+
yMin: int
|
| 81 |
+
xMax: int
|
| 82 |
+
yMax: int
|
| 83 |
+
macStyle: int
|
| 84 |
+
lowestRecPPEM: int
|
| 85 |
+
fontDirectionHint: int
|
| 86 |
+
indexToLocFormat: int
|
| 87 |
+
glyphDataFormat: int
|
| 88 |
+
|
| 89 |
+
class _SfntMaxpDict(TypedDict):
|
| 90 |
+
version: tuple[int, int]
|
| 91 |
+
numGlyphs: int
|
| 92 |
+
maxPoints: int
|
| 93 |
+
maxContours: int
|
| 94 |
+
maxComponentPoints: int
|
| 95 |
+
maxComponentContours: int
|
| 96 |
+
maxZones: int
|
| 97 |
+
maxTwilightPoints: int
|
| 98 |
+
maxStorage: int
|
| 99 |
+
maxFunctionDefs: int
|
| 100 |
+
maxInstructionDefs: int
|
| 101 |
+
maxStackElements: int
|
| 102 |
+
maxSizeOfInstructions: int
|
| 103 |
+
maxComponentElements: int
|
| 104 |
+
maxComponentDepth: int
|
| 105 |
+
|
| 106 |
+
class _SfntOs2Dict(TypedDict):
|
| 107 |
+
version: int
|
| 108 |
+
xAvgCharWidth: int
|
| 109 |
+
usWeightClass: int
|
| 110 |
+
usWidthClass: int
|
| 111 |
+
fsType: int
|
| 112 |
+
ySubscriptXSize: int
|
| 113 |
+
ySubscriptYSize: int
|
| 114 |
+
ySubscriptXOffset: int
|
| 115 |
+
ySubscriptYOffset: int
|
| 116 |
+
ySuperscriptXSize: int
|
| 117 |
+
ySuperscriptYSize: int
|
| 118 |
+
ySuperscriptXOffset: int
|
| 119 |
+
ySuperscriptYOffset: int
|
| 120 |
+
yStrikeoutSize: int
|
| 121 |
+
yStrikeoutPosition: int
|
| 122 |
+
sFamilyClass: int
|
| 123 |
+
panose: bytes
|
| 124 |
+
ulCharRange: tuple[int, int, int, int]
|
| 125 |
+
achVendID: bytes
|
| 126 |
+
fsSelection: int
|
| 127 |
+
fsFirstCharIndex: int
|
| 128 |
+
fsLastCharIndex: int
|
| 129 |
+
|
| 130 |
+
class _SfntHheaDict(TypedDict):
|
| 131 |
+
version: tuple[int, int]
|
| 132 |
+
ascent: int
|
| 133 |
+
descent: int
|
| 134 |
+
lineGap: int
|
| 135 |
+
advanceWidthMax: int
|
| 136 |
+
minLeftBearing: int
|
| 137 |
+
minRightBearing: int
|
| 138 |
+
xMaxExtent: int
|
| 139 |
+
caretSlopeRise: int
|
| 140 |
+
caretSlopeRun: int
|
| 141 |
+
caretOffset: int
|
| 142 |
+
metricDataFormat: int
|
| 143 |
+
numOfLongHorMetrics: int
|
| 144 |
+
|
| 145 |
+
class _SfntVheaDict(TypedDict):
|
| 146 |
+
version: tuple[int, int]
|
| 147 |
+
vertTypoAscender: int
|
| 148 |
+
vertTypoDescender: int
|
| 149 |
+
vertTypoLineGap: int
|
| 150 |
+
advanceHeightMax: int
|
| 151 |
+
minTopSideBearing: int
|
| 152 |
+
minBottomSizeBearing: int
|
| 153 |
+
yMaxExtent: int
|
| 154 |
+
caretSlopeRise: int
|
| 155 |
+
caretSlopeRun: int
|
| 156 |
+
caretOffset: int
|
| 157 |
+
metricDataFormat: int
|
| 158 |
+
numOfLongVerMetrics: int
|
| 159 |
+
|
| 160 |
+
class _SfntPostDict(TypedDict):
|
| 161 |
+
format: tuple[int, int]
|
| 162 |
+
italicAngle: tuple[int, int]
|
| 163 |
+
underlinePosition: int
|
| 164 |
+
underlineThickness: int
|
| 165 |
+
isFixedPitch: int
|
| 166 |
+
minMemType42: int
|
| 167 |
+
maxMemType42: int
|
| 168 |
+
minMemType1: int
|
| 169 |
+
maxMemType1: int
|
| 170 |
+
|
| 171 |
+
class _SfntPcltDict(TypedDict):
|
| 172 |
+
version: tuple[int, int]
|
| 173 |
+
fontNumber: int
|
| 174 |
+
pitch: int
|
| 175 |
+
xHeight: int
|
| 176 |
+
style: int
|
| 177 |
+
typeFamily: int
|
| 178 |
+
capHeight: int
|
| 179 |
+
symbolSet: int
|
| 180 |
+
typeFace: bytes
|
| 181 |
+
characterComplement: bytes
|
| 182 |
+
strokeWeight: int
|
| 183 |
+
widthType: int
|
| 184 |
+
serifStyle: int
|
| 185 |
+
|
| 186 |
+
@final
|
| 187 |
+
class FT2Font(Buffer):
|
| 188 |
+
def __init__(
|
| 189 |
+
self,
|
| 190 |
+
filename: str | BinaryIO,
|
| 191 |
+
hinting_factor: int = ...,
|
| 192 |
+
*,
|
| 193 |
+
_fallback_list: list[FT2Font] | None = ...,
|
| 194 |
+
_kerning_factor: int = ...
|
| 195 |
+
) -> None: ...
|
| 196 |
+
if sys.version_info[:2] >= (3, 12):
|
| 197 |
+
def __buffer__(self, flags: int) -> memoryview: ...
|
| 198 |
+
def _get_fontmap(self, string: str) -> dict[str, FT2Font]: ...
|
| 199 |
+
def clear(self) -> None: ...
|
| 200 |
+
def draw_glyph_to_bitmap(
|
| 201 |
+
self, image: FT2Image, x: int, y: int, glyph: Glyph, antialiased: bool = ...
|
| 202 |
+
) -> None: ...
|
| 203 |
+
def draw_glyphs_to_bitmap(self, antialiased: bool = ...) -> None: ...
|
| 204 |
+
def get_bitmap_offset(self) -> tuple[int, int]: ...
|
| 205 |
+
def get_char_index(self, codepoint: int) -> int: ...
|
| 206 |
+
def get_charmap(self) -> dict[int, int]: ...
|
| 207 |
+
def get_descent(self) -> int: ...
|
| 208 |
+
def get_glyph_name(self, index: int) -> str: ...
|
| 209 |
+
def get_image(self) -> NDArray[np.uint8]: ...
|
| 210 |
+
def get_kerning(self, left: int, right: int, mode: Kerning) -> int: ...
|
| 211 |
+
def get_name_index(self, name: str) -> int: ...
|
| 212 |
+
def get_num_glyphs(self) -> int: ...
|
| 213 |
+
def get_path(self) -> tuple[NDArray[np.float64], NDArray[np.int8]]: ...
|
| 214 |
+
def get_ps_font_info(
|
| 215 |
+
self,
|
| 216 |
+
) -> tuple[str, str, str, str, str, int, int, int, int]: ...
|
| 217 |
+
def get_sfnt(self) -> dict[tuple[int, int, int, int], bytes]: ...
|
| 218 |
+
@overload
|
| 219 |
+
def get_sfnt_table(self, name: Literal["head"]) -> _SfntHeadDict | None: ...
|
| 220 |
+
@overload
|
| 221 |
+
def get_sfnt_table(self, name: Literal["maxp"]) -> _SfntMaxpDict | None: ...
|
| 222 |
+
@overload
|
| 223 |
+
def get_sfnt_table(self, name: Literal["OS/2"]) -> _SfntOs2Dict | None: ...
|
| 224 |
+
@overload
|
| 225 |
+
def get_sfnt_table(self, name: Literal["hhea"]) -> _SfntHheaDict | None: ...
|
| 226 |
+
@overload
|
| 227 |
+
def get_sfnt_table(self, name: Literal["vhea"]) -> _SfntVheaDict | None: ...
|
| 228 |
+
@overload
|
| 229 |
+
def get_sfnt_table(self, name: Literal["post"]) -> _SfntPostDict | None: ...
|
| 230 |
+
@overload
|
| 231 |
+
def get_sfnt_table(self, name: Literal["pclt"]) -> _SfntPcltDict | None: ...
|
| 232 |
+
def get_width_height(self) -> tuple[int, int]: ...
|
| 233 |
+
def load_char(self, charcode: int, flags: LoadFlags = ...) -> Glyph: ...
|
| 234 |
+
def load_glyph(self, glyphindex: int, flags: LoadFlags = ...) -> Glyph: ...
|
| 235 |
+
def select_charmap(self, i: int) -> None: ...
|
| 236 |
+
def set_charmap(self, i: int) -> None: ...
|
| 237 |
+
def set_size(self, ptsize: float, dpi: float) -> None: ...
|
| 238 |
+
def set_text(
|
| 239 |
+
self, string: str, angle: float = ..., flags: LoadFlags = ...
|
| 240 |
+
) -> NDArray[np.float64]: ...
|
| 241 |
+
@property
|
| 242 |
+
def ascender(self) -> int: ...
|
| 243 |
+
@property
|
| 244 |
+
def bbox(self) -> tuple[int, int, int, int]: ...
|
| 245 |
+
@property
|
| 246 |
+
def descender(self) -> int: ...
|
| 247 |
+
@property
|
| 248 |
+
def face_flags(self) -> FaceFlags: ...
|
| 249 |
+
@property
|
| 250 |
+
def family_name(self) -> str: ...
|
| 251 |
+
@property
|
| 252 |
+
def fname(self) -> str: ...
|
| 253 |
+
@property
|
| 254 |
+
def height(self) -> int: ...
|
| 255 |
+
@property
|
| 256 |
+
def max_advance_height(self) -> int: ...
|
| 257 |
+
@property
|
| 258 |
+
def max_advance_width(self) -> int: ...
|
| 259 |
+
@property
|
| 260 |
+
def num_charmaps(self) -> int: ...
|
| 261 |
+
@property
|
| 262 |
+
def num_faces(self) -> int: ...
|
| 263 |
+
@property
|
| 264 |
+
def num_fixed_sizes(self) -> int: ...
|
| 265 |
+
@property
|
| 266 |
+
def num_glyphs(self) -> int: ...
|
| 267 |
+
@property
|
| 268 |
+
def num_named_instances(self) -> int: ...
|
| 269 |
+
@property
|
| 270 |
+
def postscript_name(self) -> str: ...
|
| 271 |
+
@property
|
| 272 |
+
def scalable(self) -> bool: ...
|
| 273 |
+
@property
|
| 274 |
+
def style_flags(self) -> StyleFlags: ...
|
| 275 |
+
@property
|
| 276 |
+
def style_name(self) -> str: ...
|
| 277 |
+
@property
|
| 278 |
+
def underline_position(self) -> int: ...
|
| 279 |
+
@property
|
| 280 |
+
def underline_thickness(self) -> int: ...
|
| 281 |
+
@property
|
| 282 |
+
def units_per_EM(self) -> int: ...
|
| 283 |
+
|
| 284 |
+
@final
|
| 285 |
+
class FT2Image(Buffer):
|
| 286 |
+
def __init__(self, width: int, height: int) -> None: ...
|
| 287 |
+
def draw_rect_filled(self, x0: int, y0: int, x1: int, y1: int) -> None: ...
|
| 288 |
+
if sys.version_info[:2] >= (3, 12):
|
| 289 |
+
def __buffer__(self, flags: int) -> memoryview: ...
|
| 290 |
+
|
| 291 |
+
@final
|
| 292 |
+
class Glyph:
|
| 293 |
+
@property
|
| 294 |
+
def width(self) -> int: ...
|
| 295 |
+
@property
|
| 296 |
+
def height(self) -> int: ...
|
| 297 |
+
@property
|
| 298 |
+
def horiBearingX(self) -> int: ...
|
| 299 |
+
@property
|
| 300 |
+
def horiBearingY(self) -> int: ...
|
| 301 |
+
@property
|
| 302 |
+
def horiAdvance(self) -> int: ...
|
| 303 |
+
@property
|
| 304 |
+
def linearHoriAdvance(self) -> int: ...
|
| 305 |
+
@property
|
| 306 |
+
def vertBearingX(self) -> int: ...
|
| 307 |
+
@property
|
| 308 |
+
def vertBearingY(self) -> int: ...
|
| 309 |
+
@property
|
| 310 |
+
def vertAdvance(self) -> int: ...
|
| 311 |
+
@property
|
| 312 |
+
def bbox(self) -> tuple[int, int, int, int]: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/gridspec.py
ADDED
|
@@ -0,0 +1,788 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
| 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
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/gridspec.pyi
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, Literal, overload
|
| 2 |
+
|
| 3 |
+
from numpy.typing import ArrayLike
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
from matplotlib.axes import Axes
|
| 7 |
+
from matplotlib.backend_bases import RendererBase
|
| 8 |
+
from matplotlib.figure import Figure
|
| 9 |
+
from matplotlib.transforms import Bbox
|
| 10 |
+
|
| 11 |
+
class GridSpecBase:
|
| 12 |
+
def __init__(
|
| 13 |
+
self,
|
| 14 |
+
nrows: int,
|
| 15 |
+
ncols: int,
|
| 16 |
+
height_ratios: ArrayLike | None = ...,
|
| 17 |
+
width_ratios: ArrayLike | None = ...,
|
| 18 |
+
) -> None: ...
|
| 19 |
+
@property
|
| 20 |
+
def nrows(self) -> int: ...
|
| 21 |
+
@property
|
| 22 |
+
def ncols(self) -> int: ...
|
| 23 |
+
def get_geometry(self) -> tuple[int, int]: ...
|
| 24 |
+
def get_subplot_params(self, figure: Figure | None = ...) -> SubplotParams: ...
|
| 25 |
+
def new_subplotspec(
|
| 26 |
+
self, loc: tuple[int, int], rowspan: int = ..., colspan: int = ...
|
| 27 |
+
) -> SubplotSpec: ...
|
| 28 |
+
def set_width_ratios(self, width_ratios: ArrayLike | None) -> None: ...
|
| 29 |
+
def get_width_ratios(self) -> ArrayLike: ...
|
| 30 |
+
def set_height_ratios(self, height_ratios: ArrayLike | None) -> None: ...
|
| 31 |
+
def get_height_ratios(self) -> ArrayLike: ...
|
| 32 |
+
def get_grid_positions(
|
| 33 |
+
self, fig: Figure
|
| 34 |
+
) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: ...
|
| 35 |
+
@staticmethod
|
| 36 |
+
def _check_gridspec_exists(figure: Figure, nrows: int, ncols: int) -> GridSpec: ...
|
| 37 |
+
def __getitem__(
|
| 38 |
+
self, key: tuple[int | slice, int | slice] | slice | int
|
| 39 |
+
) -> SubplotSpec: ...
|
| 40 |
+
@overload
|
| 41 |
+
def subplots(
|
| 42 |
+
self,
|
| 43 |
+
*,
|
| 44 |
+
sharex: bool | Literal["all", "row", "col", "none"] = ...,
|
| 45 |
+
sharey: bool | Literal["all", "row", "col", "none"] = ...,
|
| 46 |
+
squeeze: Literal[False],
|
| 47 |
+
subplot_kw: dict[str, Any] | None = ...
|
| 48 |
+
) -> np.ndarray: ...
|
| 49 |
+
@overload
|
| 50 |
+
def subplots(
|
| 51 |
+
self,
|
| 52 |
+
*,
|
| 53 |
+
sharex: bool | Literal["all", "row", "col", "none"] = ...,
|
| 54 |
+
sharey: bool | Literal["all", "row", "col", "none"] = ...,
|
| 55 |
+
squeeze: Literal[True] = ...,
|
| 56 |
+
subplot_kw: dict[str, Any] | None = ...
|
| 57 |
+
) -> np.ndarray | Axes: ...
|
| 58 |
+
|
| 59 |
+
class GridSpec(GridSpecBase):
|
| 60 |
+
left: float | None
|
| 61 |
+
bottom: float | None
|
| 62 |
+
right: float | None
|
| 63 |
+
top: float | None
|
| 64 |
+
wspace: float | None
|
| 65 |
+
hspace: float | None
|
| 66 |
+
figure: Figure | None
|
| 67 |
+
def __init__(
|
| 68 |
+
self,
|
| 69 |
+
nrows: int,
|
| 70 |
+
ncols: int,
|
| 71 |
+
figure: Figure | None = ...,
|
| 72 |
+
left: float | None = ...,
|
| 73 |
+
bottom: float | None = ...,
|
| 74 |
+
right: float | None = ...,
|
| 75 |
+
top: float | None = ...,
|
| 76 |
+
wspace: float | None = ...,
|
| 77 |
+
hspace: float | None = ...,
|
| 78 |
+
width_ratios: ArrayLike | None = ...,
|
| 79 |
+
height_ratios: ArrayLike | None = ...,
|
| 80 |
+
) -> None: ...
|
| 81 |
+
def update(self, **kwargs: float | None) -> None: ...
|
| 82 |
+
def locally_modified_subplot_params(self) -> list[str]: ...
|
| 83 |
+
def tight_layout(
|
| 84 |
+
self,
|
| 85 |
+
figure: Figure,
|
| 86 |
+
renderer: RendererBase | None = ...,
|
| 87 |
+
pad: float = ...,
|
| 88 |
+
h_pad: float | None = ...,
|
| 89 |
+
w_pad: float | None = ...,
|
| 90 |
+
rect: tuple[float, float, float, float] | None = ...,
|
| 91 |
+
) -> None: ...
|
| 92 |
+
|
| 93 |
+
class GridSpecFromSubplotSpec(GridSpecBase):
|
| 94 |
+
figure: Figure | None
|
| 95 |
+
def __init__(
|
| 96 |
+
self,
|
| 97 |
+
nrows: int,
|
| 98 |
+
ncols: int,
|
| 99 |
+
subplot_spec: SubplotSpec,
|
| 100 |
+
wspace: float | None = ...,
|
| 101 |
+
hspace: float | None = ...,
|
| 102 |
+
height_ratios: ArrayLike | None = ...,
|
| 103 |
+
width_ratios: ArrayLike | None = ...,
|
| 104 |
+
) -> None: ...
|
| 105 |
+
def get_topmost_subplotspec(self) -> SubplotSpec: ...
|
| 106 |
+
|
| 107 |
+
class SubplotSpec:
|
| 108 |
+
num1: int
|
| 109 |
+
def __init__(
|
| 110 |
+
self, gridspec: GridSpecBase, num1: int, num2: int | None = ...
|
| 111 |
+
) -> None: ...
|
| 112 |
+
@staticmethod
|
| 113 |
+
def _from_subplot_args(figure, args): ...
|
| 114 |
+
@property
|
| 115 |
+
def num2(self) -> int: ...
|
| 116 |
+
@num2.setter
|
| 117 |
+
def num2(self, value: int) -> None: ...
|
| 118 |
+
def get_gridspec(self) -> GridSpec: ...
|
| 119 |
+
def get_geometry(self) -> tuple[int, int, int, int]: ...
|
| 120 |
+
@property
|
| 121 |
+
def rowspan(self) -> range: ...
|
| 122 |
+
@property
|
| 123 |
+
def colspan(self) -> range: ...
|
| 124 |
+
def is_first_row(self) -> bool: ...
|
| 125 |
+
def is_last_row(self) -> bool: ...
|
| 126 |
+
def is_first_col(self) -> bool: ...
|
| 127 |
+
def is_last_col(self) -> bool: ...
|
| 128 |
+
def get_position(self, figure: Figure) -> Bbox: ...
|
| 129 |
+
def get_topmost_subplotspec(self) -> SubplotSpec: ...
|
| 130 |
+
def __eq__(self, other: object) -> bool: ...
|
| 131 |
+
def __hash__(self) -> int: ...
|
| 132 |
+
def subgridspec(
|
| 133 |
+
self, nrows: int, ncols: int, **kwargs
|
| 134 |
+
) -> GridSpecFromSubplotSpec: ...
|
| 135 |
+
|
| 136 |
+
class SubplotParams:
|
| 137 |
+
def __init__(
|
| 138 |
+
self,
|
| 139 |
+
left: float | None = ...,
|
| 140 |
+
bottom: float | None = ...,
|
| 141 |
+
right: float | None = ...,
|
| 142 |
+
top: float | None = ...,
|
| 143 |
+
wspace: float | None = ...,
|
| 144 |
+
hspace: float | None = ...,
|
| 145 |
+
) -> None: ...
|
| 146 |
+
left: float
|
| 147 |
+
right: float
|
| 148 |
+
bottom: float
|
| 149 |
+
top: float
|
| 150 |
+
wspace: float
|
| 151 |
+
hspace: float
|
| 152 |
+
def update(
|
| 153 |
+
self,
|
| 154 |
+
left: float | None = ...,
|
| 155 |
+
bottom: float | None = ...,
|
| 156 |
+
right: float | None = ...,
|
| 157 |
+
top: float | None = ...,
|
| 158 |
+
wspace: float | None = ...,
|
| 159 |
+
hspace: float | None = ...,
|
| 160 |
+
) -> None: ...
|
infer_4_30_0/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]
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/layout_engine.pyi
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from matplotlib.figure import Figure
|
| 2 |
+
|
| 3 |
+
from typing import Any
|
| 4 |
+
|
| 5 |
+
class LayoutEngine:
|
| 6 |
+
def __init__(self, **kwargs: Any) -> None: ...
|
| 7 |
+
def set(self) -> None: ...
|
| 8 |
+
@property
|
| 9 |
+
def colorbar_gridspec(self) -> bool: ...
|
| 10 |
+
@property
|
| 11 |
+
def adjust_compatible(self) -> bool: ...
|
| 12 |
+
def get(self) -> dict[str, Any]: ...
|
| 13 |
+
def execute(self, fig: Figure) -> None: ...
|
| 14 |
+
|
| 15 |
+
class PlaceHolderLayoutEngine(LayoutEngine):
|
| 16 |
+
def __init__(
|
| 17 |
+
self, adjust_compatible: bool, colorbar_gridspec: bool, **kwargs: Any
|
| 18 |
+
) -> None: ...
|
| 19 |
+
def execute(self, fig: Figure) -> None: ...
|
| 20 |
+
|
| 21 |
+
class TightLayoutEngine(LayoutEngine):
|
| 22 |
+
def __init__(
|
| 23 |
+
self,
|
| 24 |
+
*,
|
| 25 |
+
pad: float = ...,
|
| 26 |
+
h_pad: float | None = ...,
|
| 27 |
+
w_pad: float | None = ...,
|
| 28 |
+
rect: tuple[float, float, float, float] = ...,
|
| 29 |
+
**kwargs: Any
|
| 30 |
+
) -> None: ...
|
| 31 |
+
def execute(self, fig: Figure) -> None: ...
|
| 32 |
+
def set(
|
| 33 |
+
self,
|
| 34 |
+
*,
|
| 35 |
+
pad: float | None = ...,
|
| 36 |
+
w_pad: float | None = ...,
|
| 37 |
+
h_pad: float | None = ...,
|
| 38 |
+
rect: tuple[float, float, float, float] | None = ...
|
| 39 |
+
) -> None: ...
|
| 40 |
+
|
| 41 |
+
class ConstrainedLayoutEngine(LayoutEngine):
|
| 42 |
+
def __init__(
|
| 43 |
+
self,
|
| 44 |
+
*,
|
| 45 |
+
h_pad: float | None = ...,
|
| 46 |
+
w_pad: float | None = ...,
|
| 47 |
+
hspace: float | None = ...,
|
| 48 |
+
wspace: float | None = ...,
|
| 49 |
+
rect: tuple[float, float, float, float] = ...,
|
| 50 |
+
compress: bool = ...,
|
| 51 |
+
**kwargs: Any
|
| 52 |
+
) -> None: ...
|
| 53 |
+
def execute(self, fig: Figure) -> Any: ...
|
| 54 |
+
def set(
|
| 55 |
+
self,
|
| 56 |
+
*,
|
| 57 |
+
h_pad: float | None = ...,
|
| 58 |
+
w_pad: float | None = ...,
|
| 59 |
+
hspace: float | None = ...,
|
| 60 |
+
wspace: float | None = ...,
|
| 61 |
+
rect: tuple[float, float, float, float] | None = ...
|
| 62 |
+
) -> None: ...
|
infer_4_30_0/lib/python3.10/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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, renderer):
|
| 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(renderer))
|
| 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(renderer)
|
| 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))
|
| 1369 |
+
|
| 1370 |
+
return handles, labels, kwargs
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/legend_handler.pyi
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable, Sequence
|
| 2 |
+
from matplotlib.artist import Artist
|
| 3 |
+
from matplotlib.legend import Legend
|
| 4 |
+
from matplotlib.offsetbox import OffsetBox
|
| 5 |
+
from matplotlib.transforms import Transform
|
| 6 |
+
|
| 7 |
+
from typing import TypeVar
|
| 8 |
+
|
| 9 |
+
from numpy.typing import ArrayLike
|
| 10 |
+
|
| 11 |
+
def update_from_first_child(tgt: Artist, src: Artist) -> None: ...
|
| 12 |
+
|
| 13 |
+
class HandlerBase:
|
| 14 |
+
def __init__(
|
| 15 |
+
self,
|
| 16 |
+
xpad: float = ...,
|
| 17 |
+
ypad: float = ...,
|
| 18 |
+
update_func: Callable[[Artist, Artist], None] | None = ...,
|
| 19 |
+
) -> None: ...
|
| 20 |
+
def update_prop(
|
| 21 |
+
self, legend_handle: Artist, orig_handle: Artist, legend: Legend
|
| 22 |
+
) -> None: ...
|
| 23 |
+
def adjust_drawing_area(
|
| 24 |
+
self,
|
| 25 |
+
legend: Legend,
|
| 26 |
+
orig_handle: Artist,
|
| 27 |
+
xdescent: float,
|
| 28 |
+
ydescent: float,
|
| 29 |
+
width: float,
|
| 30 |
+
height: float,
|
| 31 |
+
fontsize: float,
|
| 32 |
+
) -> tuple[float, float, float, float]: ...
|
| 33 |
+
def legend_artist(
|
| 34 |
+
self, legend: Legend, orig_handle: Artist, fontsize: float, handlebox: OffsetBox
|
| 35 |
+
) -> Artist: ...
|
| 36 |
+
def create_artists(
|
| 37 |
+
self,
|
| 38 |
+
legend: Legend,
|
| 39 |
+
orig_handle: Artist,
|
| 40 |
+
xdescent: float,
|
| 41 |
+
ydescent: float,
|
| 42 |
+
width: float,
|
| 43 |
+
height: float,
|
| 44 |
+
fontsize: float,
|
| 45 |
+
trans: Transform,
|
| 46 |
+
) -> Sequence[Artist]: ...
|
| 47 |
+
|
| 48 |
+
class HandlerNpoints(HandlerBase):
|
| 49 |
+
def __init__(
|
| 50 |
+
self, marker_pad: float = ..., numpoints: int | None = ..., **kwargs
|
| 51 |
+
) -> None: ...
|
| 52 |
+
def get_numpoints(self, legend: Legend) -> int | None: ...
|
| 53 |
+
def get_xdata(
|
| 54 |
+
self,
|
| 55 |
+
legend: Legend,
|
| 56 |
+
xdescent: float,
|
| 57 |
+
ydescent: float,
|
| 58 |
+
width: float,
|
| 59 |
+
height: float,
|
| 60 |
+
fontsize: float,
|
| 61 |
+
) -> tuple[ArrayLike, ArrayLike]: ...
|
| 62 |
+
|
| 63 |
+
class HandlerNpointsYoffsets(HandlerNpoints):
|
| 64 |
+
def __init__(
|
| 65 |
+
self,
|
| 66 |
+
numpoints: int | None = ...,
|
| 67 |
+
yoffsets: Sequence[float] | None = ...,
|
| 68 |
+
**kwargs
|
| 69 |
+
) -> None: ...
|
| 70 |
+
def get_ydata(
|
| 71 |
+
self,
|
| 72 |
+
legend: Legend,
|
| 73 |
+
xdescent: float,
|
| 74 |
+
ydescent: float,
|
| 75 |
+
width: float,
|
| 76 |
+
height: float,
|
| 77 |
+
fontsize: float,
|
| 78 |
+
) -> ArrayLike: ...
|
| 79 |
+
|
| 80 |
+
class HandlerLine2DCompound(HandlerNpoints):
|
| 81 |
+
def create_artists(
|
| 82 |
+
self,
|
| 83 |
+
legend: Legend,
|
| 84 |
+
orig_handle: Artist,
|
| 85 |
+
xdescent: float,
|
| 86 |
+
ydescent: float,
|
| 87 |
+
width: float,
|
| 88 |
+
height: float,
|
| 89 |
+
fontsize: float,
|
| 90 |
+
trans: Transform,
|
| 91 |
+
) -> Sequence[Artist]: ...
|
| 92 |
+
|
| 93 |
+
class HandlerLine2D(HandlerNpoints):
|
| 94 |
+
def create_artists(
|
| 95 |
+
self,
|
| 96 |
+
legend: Legend,
|
| 97 |
+
orig_handle: Artist,
|
| 98 |
+
xdescent: float,
|
| 99 |
+
ydescent: float,
|
| 100 |
+
width: float,
|
| 101 |
+
height: float,
|
| 102 |
+
fontsize: float,
|
| 103 |
+
trans: Transform,
|
| 104 |
+
) -> Sequence[Artist]: ...
|
| 105 |
+
|
| 106 |
+
class HandlerPatch(HandlerBase):
|
| 107 |
+
def __init__(self, patch_func: Callable | None = ..., **kwargs) -> None: ...
|
| 108 |
+
def create_artists(
|
| 109 |
+
self,
|
| 110 |
+
legend: Legend,
|
| 111 |
+
orig_handle: Artist,
|
| 112 |
+
xdescent: float,
|
| 113 |
+
ydescent: float,
|
| 114 |
+
width: float,
|
| 115 |
+
height: float,
|
| 116 |
+
fontsize: float,
|
| 117 |
+
trans: Transform,
|
| 118 |
+
) -> Sequence[Artist]: ...
|
| 119 |
+
|
| 120 |
+
class HandlerStepPatch(HandlerBase):
|
| 121 |
+
def create_artists(
|
| 122 |
+
self,
|
| 123 |
+
legend: Legend,
|
| 124 |
+
orig_handle: Artist,
|
| 125 |
+
xdescent: float,
|
| 126 |
+
ydescent: float,
|
| 127 |
+
width: float,
|
| 128 |
+
height: float,
|
| 129 |
+
fontsize: float,
|
| 130 |
+
trans: Transform,
|
| 131 |
+
) -> Sequence[Artist]: ...
|
| 132 |
+
|
| 133 |
+
class HandlerLineCollection(HandlerLine2D):
|
| 134 |
+
def get_numpoints(self, legend: Legend) -> int: ...
|
| 135 |
+
def create_artists(
|
| 136 |
+
self,
|
| 137 |
+
legend: Legend,
|
| 138 |
+
orig_handle: Artist,
|
| 139 |
+
xdescent: float,
|
| 140 |
+
ydescent: float,
|
| 141 |
+
width: float,
|
| 142 |
+
height: float,
|
| 143 |
+
fontsize: float,
|
| 144 |
+
trans: Transform,
|
| 145 |
+
) -> Sequence[Artist]: ...
|
| 146 |
+
|
| 147 |
+
_T = TypeVar("_T", bound=Artist)
|
| 148 |
+
|
| 149 |
+
class HandlerRegularPolyCollection(HandlerNpointsYoffsets):
|
| 150 |
+
def __init__(
|
| 151 |
+
self,
|
| 152 |
+
yoffsets: Sequence[float] | None = ...,
|
| 153 |
+
sizes: Sequence[float] | None = ...,
|
| 154 |
+
**kwargs
|
| 155 |
+
) -> None: ...
|
| 156 |
+
def get_numpoints(self, legend: Legend) -> int: ...
|
| 157 |
+
def get_sizes(
|
| 158 |
+
self,
|
| 159 |
+
legend: Legend,
|
| 160 |
+
orig_handle: Artist,
|
| 161 |
+
xdescent: float,
|
| 162 |
+
ydescent: float,
|
| 163 |
+
width: float,
|
| 164 |
+
height: float,
|
| 165 |
+
fontsize: float,
|
| 166 |
+
) -> Sequence[float]: ...
|
| 167 |
+
def update_prop(
|
| 168 |
+
self, legend_handle, orig_handle: Artist, legend: Legend
|
| 169 |
+
) -> None: ...
|
| 170 |
+
def create_collection(
|
| 171 |
+
self,
|
| 172 |
+
orig_handle: _T,
|
| 173 |
+
sizes: Sequence[float] | None,
|
| 174 |
+
offsets: Sequence[float] | None,
|
| 175 |
+
offset_transform: Transform,
|
| 176 |
+
) -> _T: ...
|
| 177 |
+
def create_artists(
|
| 178 |
+
self,
|
| 179 |
+
legend: Legend,
|
| 180 |
+
orig_handle: Artist,
|
| 181 |
+
xdescent: float,
|
| 182 |
+
ydescent: float,
|
| 183 |
+
width: float,
|
| 184 |
+
height: float,
|
| 185 |
+
fontsize: float,
|
| 186 |
+
trans: Transform,
|
| 187 |
+
) -> Sequence[Artist]: ...
|
| 188 |
+
|
| 189 |
+
class HandlerPathCollection(HandlerRegularPolyCollection):
|
| 190 |
+
def create_collection(
|
| 191 |
+
self,
|
| 192 |
+
orig_handle: _T,
|
| 193 |
+
sizes: Sequence[float] | None,
|
| 194 |
+
offsets: Sequence[float] | None,
|
| 195 |
+
offset_transform: Transform,
|
| 196 |
+
) -> _T: ...
|
| 197 |
+
|
| 198 |
+
class HandlerCircleCollection(HandlerRegularPolyCollection):
|
| 199 |
+
def create_collection(
|
| 200 |
+
self,
|
| 201 |
+
orig_handle: _T,
|
| 202 |
+
sizes: Sequence[float] | None,
|
| 203 |
+
offsets: Sequence[float] | None,
|
| 204 |
+
offset_transform: Transform,
|
| 205 |
+
) -> _T: ...
|
| 206 |
+
|
| 207 |
+
class HandlerErrorbar(HandlerLine2D):
|
| 208 |
+
def __init__(
|
| 209 |
+
self,
|
| 210 |
+
xerr_size: float = ...,
|
| 211 |
+
yerr_size: float | None = ...,
|
| 212 |
+
marker_pad: float = ...,
|
| 213 |
+
numpoints: int | None = ...,
|
| 214 |
+
**kwargs
|
| 215 |
+
) -> None: ...
|
| 216 |
+
def get_err_size(
|
| 217 |
+
self,
|
| 218 |
+
legend: Legend,
|
| 219 |
+
xdescent: float,
|
| 220 |
+
ydescent: float,
|
| 221 |
+
width: float,
|
| 222 |
+
height: float,
|
| 223 |
+
fontsize: float,
|
| 224 |
+
) -> tuple[float, float]: ...
|
| 225 |
+
def create_artists(
|
| 226 |
+
self,
|
| 227 |
+
legend: Legend,
|
| 228 |
+
orig_handle: Artist,
|
| 229 |
+
xdescent: float,
|
| 230 |
+
ydescent: float,
|
| 231 |
+
width: float,
|
| 232 |
+
height: float,
|
| 233 |
+
fontsize: float,
|
| 234 |
+
trans: Transform,
|
| 235 |
+
) -> Sequence[Artist]: ...
|
| 236 |
+
|
| 237 |
+
class HandlerStem(HandlerNpointsYoffsets):
|
| 238 |
+
def __init__(
|
| 239 |
+
self,
|
| 240 |
+
marker_pad: float = ...,
|
| 241 |
+
numpoints: int | None = ...,
|
| 242 |
+
bottom: float | None = ...,
|
| 243 |
+
yoffsets: Sequence[float] | None = ...,
|
| 244 |
+
**kwargs
|
| 245 |
+
) -> None: ...
|
| 246 |
+
def get_ydata(
|
| 247 |
+
self,
|
| 248 |
+
legend: Legend,
|
| 249 |
+
xdescent: float,
|
| 250 |
+
ydescent: float,
|
| 251 |
+
width: float,
|
| 252 |
+
height: float,
|
| 253 |
+
fontsize: float,
|
| 254 |
+
) -> ArrayLike: ...
|
| 255 |
+
def create_artists(
|
| 256 |
+
self,
|
| 257 |
+
legend: Legend,
|
| 258 |
+
orig_handle: Artist,
|
| 259 |
+
xdescent: float,
|
| 260 |
+
ydescent: float,
|
| 261 |
+
width: float,
|
| 262 |
+
height: float,
|
| 263 |
+
fontsize: float,
|
| 264 |
+
trans: Transform,
|
| 265 |
+
) -> Sequence[Artist]: ...
|
| 266 |
+
|
| 267 |
+
class HandlerTuple(HandlerBase):
|
| 268 |
+
def __init__(
|
| 269 |
+
self, ndivide: int | None = ..., pad: float | None = ..., **kwargs
|
| 270 |
+
) -> None: ...
|
| 271 |
+
def create_artists(
|
| 272 |
+
self,
|
| 273 |
+
legend: Legend,
|
| 274 |
+
orig_handle: Artist,
|
| 275 |
+
xdescent: float,
|
| 276 |
+
ydescent: float,
|
| 277 |
+
width: float,
|
| 278 |
+
height: float,
|
| 279 |
+
fontsize: float,
|
| 280 |
+
trans: Transform,
|
| 281 |
+
) -> Sequence[Artist]: ...
|
| 282 |
+
|
| 283 |
+
class HandlerPolyCollection(HandlerBase):
|
| 284 |
+
def create_artists(
|
| 285 |
+
self,
|
| 286 |
+
legend: Legend,
|
| 287 |
+
orig_handle: Artist,
|
| 288 |
+
xdescent: float,
|
| 289 |
+
ydescent: float,
|
| 290 |
+
width: float,
|
| 291 |
+
height: float,
|
| 292 |
+
fontsize: float,
|
| 293 |
+
trans: Transform,
|
| 294 |
+
) -> Sequence[Artist]: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/lines.py
ADDED
|
@@ -0,0 +1,1706 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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variety of line styles, markers, colors, etc.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import copy
|
| 6 |
+
|
| 7 |
+
from numbers import Integral, Number, Real
|
| 8 |
+
import logging
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
|
| 12 |
+
import matplotlib as mpl
|
| 13 |
+
from . import _api, cbook, colors as mcolors, _docstring
|
| 14 |
+
from .artist import Artist, allow_rasterization
|
| 15 |
+
from .cbook import (
|
| 16 |
+
_to_unmasked_float_array, ls_mapper, ls_mapper_r, STEP_LOOKUP_MAP)
|
| 17 |
+
from .markers import MarkerStyle
|
| 18 |
+
from .path import Path
|
| 19 |
+
from .transforms import Bbox, BboxTransformTo, TransformedPath
|
| 20 |
+
from ._enums import JoinStyle, CapStyle
|
| 21 |
+
|
| 22 |
+
# Imported here for backward compatibility, even though they don't
|
| 23 |
+
# really belong.
|
| 24 |
+
from . import _path
|
| 25 |
+
from .markers import ( # noqa
|
| 26 |
+
CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN,
|
| 27 |
+
CARETLEFTBASE, CARETRIGHTBASE, CARETUPBASE, CARETDOWNBASE,
|
| 28 |
+
TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN)
|
| 29 |
+
|
| 30 |
+
_log = logging.getLogger(__name__)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _get_dash_pattern(style):
|
| 34 |
+
"""Convert linestyle to dash pattern."""
|
| 35 |
+
# go from short hand -> full strings
|
| 36 |
+
if isinstance(style, str):
|
| 37 |
+
style = ls_mapper.get(style, style)
|
| 38 |
+
# un-dashed styles
|
| 39 |
+
if style in ['solid', 'None']:
|
| 40 |
+
offset = 0
|
| 41 |
+
dashes = None
|
| 42 |
+
# dashed styles
|
| 43 |
+
elif style in ['dashed', 'dashdot', 'dotted']:
|
| 44 |
+
offset = 0
|
| 45 |
+
dashes = tuple(mpl.rcParams[f'lines.{style}_pattern'])
|
| 46 |
+
#
|
| 47 |
+
elif isinstance(style, tuple):
|
| 48 |
+
offset, dashes = style
|
| 49 |
+
if offset is None:
|
| 50 |
+
raise ValueError(f'Unrecognized linestyle: {style!r}')
|
| 51 |
+
else:
|
| 52 |
+
raise ValueError(f'Unrecognized linestyle: {style!r}')
|
| 53 |
+
|
| 54 |
+
# normalize offset to be positive and shorter than the dash cycle
|
| 55 |
+
if dashes is not None:
|
| 56 |
+
dsum = sum(dashes)
|
| 57 |
+
if dsum:
|
| 58 |
+
offset %= dsum
|
| 59 |
+
|
| 60 |
+
return offset, dashes
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def _get_inverse_dash_pattern(offset, dashes):
|
| 64 |
+
"""Return the inverse of the given dash pattern, for filling the gaps."""
|
| 65 |
+
# Define the inverse pattern by moving the last gap to the start of the
|
| 66 |
+
# sequence.
|
| 67 |
+
gaps = dashes[-1:] + dashes[:-1]
|
| 68 |
+
# Set the offset so that this new first segment is skipped
|
| 69 |
+
# (see backend_bases.GraphicsContextBase.set_dashes for offset definition).
|
| 70 |
+
offset_gaps = offset + dashes[-1]
|
| 71 |
+
|
| 72 |
+
return offset_gaps, gaps
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def _scale_dashes(offset, dashes, lw):
|
| 76 |
+
if not mpl.rcParams['lines.scale_dashes']:
|
| 77 |
+
return offset, dashes
|
| 78 |
+
scaled_offset = offset * lw
|
| 79 |
+
scaled_dashes = ([x * lw if x is not None else None for x in dashes]
|
| 80 |
+
if dashes is not None else None)
|
| 81 |
+
return scaled_offset, scaled_dashes
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def segment_hits(cx, cy, x, y, radius):
|
| 85 |
+
"""
|
| 86 |
+
Return the indices of the segments in the polyline with coordinates (*cx*,
|
| 87 |
+
*cy*) that are within a distance *radius* of the point (*x*, *y*).
|
| 88 |
+
"""
|
| 89 |
+
# Process single points specially
|
| 90 |
+
if len(x) <= 1:
|
| 91 |
+
res, = np.nonzero((cx - x) ** 2 + (cy - y) ** 2 <= radius ** 2)
|
| 92 |
+
return res
|
| 93 |
+
|
| 94 |
+
# We need to lop the last element off a lot.
|
| 95 |
+
xr, yr = x[:-1], y[:-1]
|
| 96 |
+
|
| 97 |
+
# Only look at line segments whose nearest point to C on the line
|
| 98 |
+
# lies within the segment.
|
| 99 |
+
dx, dy = x[1:] - xr, y[1:] - yr
|
| 100 |
+
Lnorm_sq = dx ** 2 + dy ** 2 # Possibly want to eliminate Lnorm==0
|
| 101 |
+
u = ((cx - xr) * dx + (cy - yr) * dy) / Lnorm_sq
|
| 102 |
+
candidates = (u >= 0) & (u <= 1)
|
| 103 |
+
|
| 104 |
+
# Note that there is a little area near one side of each point
|
| 105 |
+
# which will be near neither segment, and another which will
|
| 106 |
+
# be near both, depending on the angle of the lines. The
|
| 107 |
+
# following radius test eliminates these ambiguities.
|
| 108 |
+
point_hits = (cx - x) ** 2 + (cy - y) ** 2 <= radius ** 2
|
| 109 |
+
candidates = candidates & ~(point_hits[:-1] | point_hits[1:])
|
| 110 |
+
|
| 111 |
+
# For those candidates which remain, determine how far they lie away
|
| 112 |
+
# from the line.
|
| 113 |
+
px, py = xr + u * dx, yr + u * dy
|
| 114 |
+
line_hits = (cx - px) ** 2 + (cy - py) ** 2 <= radius ** 2
|
| 115 |
+
line_hits = line_hits & candidates
|
| 116 |
+
points, = point_hits.ravel().nonzero()
|
| 117 |
+
lines, = line_hits.ravel().nonzero()
|
| 118 |
+
return np.concatenate((points, lines))
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def _mark_every_path(markevery, tpath, affine, ax):
|
| 122 |
+
"""
|
| 123 |
+
Helper function that sorts out how to deal the input
|
| 124 |
+
`markevery` and returns the points where markers should be drawn.
|
| 125 |
+
|
| 126 |
+
Takes in the `markevery` value and the line path and returns the
|
| 127 |
+
sub-sampled path.
|
| 128 |
+
"""
|
| 129 |
+
# pull out the two bits of data we want from the path
|
| 130 |
+
codes, verts = tpath.codes, tpath.vertices
|
| 131 |
+
|
| 132 |
+
def _slice_or_none(in_v, slc):
|
| 133 |
+
"""Helper function to cope with `codes` being an ndarray or `None`."""
|
| 134 |
+
if in_v is None:
|
| 135 |
+
return None
|
| 136 |
+
return in_v[slc]
|
| 137 |
+
|
| 138 |
+
# if just an int, assume starting at 0 and make a tuple
|
| 139 |
+
if isinstance(markevery, Integral):
|
| 140 |
+
markevery = (0, markevery)
|
| 141 |
+
# if just a float, assume starting at 0.0 and make a tuple
|
| 142 |
+
elif isinstance(markevery, Real):
|
| 143 |
+
markevery = (0.0, markevery)
|
| 144 |
+
|
| 145 |
+
if isinstance(markevery, tuple):
|
| 146 |
+
if len(markevery) != 2:
|
| 147 |
+
raise ValueError('`markevery` is a tuple but its len is not 2; '
|
| 148 |
+
f'markevery={markevery}')
|
| 149 |
+
start, step = markevery
|
| 150 |
+
# if step is an int, old behavior
|
| 151 |
+
if isinstance(step, Integral):
|
| 152 |
+
# tuple of 2 int is for backwards compatibility,
|
| 153 |
+
if not isinstance(start, Integral):
|
| 154 |
+
raise ValueError(
|
| 155 |
+
'`markevery` is a tuple with len 2 and second element is '
|
| 156 |
+
'an int, but the first element is not an int; '
|
| 157 |
+
f'markevery={markevery}')
|
| 158 |
+
# just return, we are done here
|
| 159 |
+
|
| 160 |
+
return Path(verts[slice(start, None, step)],
|
| 161 |
+
_slice_or_none(codes, slice(start, None, step)))
|
| 162 |
+
|
| 163 |
+
elif isinstance(step, Real):
|
| 164 |
+
if not isinstance(start, Real):
|
| 165 |
+
raise ValueError(
|
| 166 |
+
'`markevery` is a tuple with len 2 and second element is '
|
| 167 |
+
'a float, but the first element is not a float or an int; '
|
| 168 |
+
f'markevery={markevery}')
|
| 169 |
+
if ax is None:
|
| 170 |
+
raise ValueError(
|
| 171 |
+
"markevery is specified relative to the Axes size, but "
|
| 172 |
+
"the line does not have a Axes as parent")
|
| 173 |
+
|
| 174 |
+
# calc cumulative distance along path (in display coords):
|
| 175 |
+
fin = np.isfinite(verts).all(axis=1)
|
| 176 |
+
fverts = verts[fin]
|
| 177 |
+
disp_coords = affine.transform(fverts)
|
| 178 |
+
|
| 179 |
+
delta = np.empty((len(disp_coords), 2))
|
| 180 |
+
delta[0, :] = 0
|
| 181 |
+
delta[1:, :] = disp_coords[1:, :] - disp_coords[:-1, :]
|
| 182 |
+
delta = np.hypot(*delta.T).cumsum()
|
| 183 |
+
# calc distance between markers along path based on the Axes
|
| 184 |
+
# bounding box diagonal being a distance of unity:
|
| 185 |
+
(x0, y0), (x1, y1) = ax.transAxes.transform([[0, 0], [1, 1]])
|
| 186 |
+
scale = np.hypot(x1 - x0, y1 - y0)
|
| 187 |
+
marker_delta = np.arange(start * scale, delta[-1], step * scale)
|
| 188 |
+
# find closest actual data point that is closest to
|
| 189 |
+
# the theoretical distance along the path:
|
| 190 |
+
inds = np.abs(delta[np.newaxis, :] - marker_delta[:, np.newaxis])
|
| 191 |
+
inds = inds.argmin(axis=1)
|
| 192 |
+
inds = np.unique(inds)
|
| 193 |
+
# return, we are done here
|
| 194 |
+
return Path(fverts[inds], _slice_or_none(codes, inds))
|
| 195 |
+
else:
|
| 196 |
+
raise ValueError(
|
| 197 |
+
f"markevery={markevery!r} is a tuple with len 2, but its "
|
| 198 |
+
f"second element is not an int or a float")
|
| 199 |
+
|
| 200 |
+
elif isinstance(markevery, slice):
|
| 201 |
+
# mazol tov, it's already a slice, just return
|
| 202 |
+
return Path(verts[markevery], _slice_or_none(codes, markevery))
|
| 203 |
+
|
| 204 |
+
elif np.iterable(markevery):
|
| 205 |
+
# fancy indexing
|
| 206 |
+
try:
|
| 207 |
+
return Path(verts[markevery], _slice_or_none(codes, markevery))
|
| 208 |
+
except (ValueError, IndexError) as err:
|
| 209 |
+
raise ValueError(
|
| 210 |
+
f"markevery={markevery!r} is iterable but not a valid numpy "
|
| 211 |
+
f"fancy index") from err
|
| 212 |
+
else:
|
| 213 |
+
raise ValueError(f"markevery={markevery!r} is not a recognized value")
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
@_docstring.interpd
|
| 217 |
+
@_api.define_aliases({
|
| 218 |
+
"antialiased": ["aa"],
|
| 219 |
+
"color": ["c"],
|
| 220 |
+
"drawstyle": ["ds"],
|
| 221 |
+
"linestyle": ["ls"],
|
| 222 |
+
"linewidth": ["lw"],
|
| 223 |
+
"markeredgecolor": ["mec"],
|
| 224 |
+
"markeredgewidth": ["mew"],
|
| 225 |
+
"markerfacecolor": ["mfc"],
|
| 226 |
+
"markerfacecoloralt": ["mfcalt"],
|
| 227 |
+
"markersize": ["ms"],
|
| 228 |
+
})
|
| 229 |
+
class Line2D(Artist):
|
| 230 |
+
"""
|
| 231 |
+
A line - the line can have both a solid linestyle connecting all
|
| 232 |
+
the vertices, and a marker at each vertex. Additionally, the
|
| 233 |
+
drawing of the solid line is influenced by the drawstyle, e.g., one
|
| 234 |
+
can create "stepped" lines in various styles.
|
| 235 |
+
"""
|
| 236 |
+
|
| 237 |
+
lineStyles = _lineStyles = { # hidden names deprecated
|
| 238 |
+
'-': '_draw_solid',
|
| 239 |
+
'--': '_draw_dashed',
|
| 240 |
+
'-.': '_draw_dash_dot',
|
| 241 |
+
':': '_draw_dotted',
|
| 242 |
+
'None': '_draw_nothing',
|
| 243 |
+
' ': '_draw_nothing',
|
| 244 |
+
'': '_draw_nothing',
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
_drawStyles_l = {
|
| 248 |
+
'default': '_draw_lines',
|
| 249 |
+
'steps-mid': '_draw_steps_mid',
|
| 250 |
+
'steps-pre': '_draw_steps_pre',
|
| 251 |
+
'steps-post': '_draw_steps_post',
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
_drawStyles_s = {
|
| 255 |
+
'steps': '_draw_steps_pre',
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
# drawStyles should now be deprecated.
|
| 259 |
+
drawStyles = {**_drawStyles_l, **_drawStyles_s}
|
| 260 |
+
# Need a list ordered with long names first:
|
| 261 |
+
drawStyleKeys = [*_drawStyles_l, *_drawStyles_s]
|
| 262 |
+
|
| 263 |
+
# Referenced here to maintain API. These are defined in
|
| 264 |
+
# MarkerStyle
|
| 265 |
+
markers = MarkerStyle.markers
|
| 266 |
+
filled_markers = MarkerStyle.filled_markers
|
| 267 |
+
fillStyles = MarkerStyle.fillstyles
|
| 268 |
+
|
| 269 |
+
zorder = 2
|
| 270 |
+
|
| 271 |
+
_subslice_optim_min_size = 1000
|
| 272 |
+
|
| 273 |
+
def __str__(self):
|
| 274 |
+
if self._label != "":
|
| 275 |
+
return f"Line2D({self._label})"
|
| 276 |
+
elif self._x is None:
|
| 277 |
+
return "Line2D()"
|
| 278 |
+
elif len(self._x) > 3:
|
| 279 |
+
return "Line2D(({:g},{:g}),({:g},{:g}),...,({:g},{:g}))".format(
|
| 280 |
+
self._x[0], self._y[0],
|
| 281 |
+
self._x[1], self._y[1],
|
| 282 |
+
self._x[-1], self._y[-1])
|
| 283 |
+
else:
|
| 284 |
+
return "Line2D(%s)" % ",".join(
|
| 285 |
+
map("({:g},{:g})".format, self._x, self._y))
|
| 286 |
+
|
| 287 |
+
def __init__(self, xdata, ydata, *,
|
| 288 |
+
linewidth=None, # all Nones default to rc
|
| 289 |
+
linestyle=None,
|
| 290 |
+
color=None,
|
| 291 |
+
gapcolor=None,
|
| 292 |
+
marker=None,
|
| 293 |
+
markersize=None,
|
| 294 |
+
markeredgewidth=None,
|
| 295 |
+
markeredgecolor=None,
|
| 296 |
+
markerfacecolor=None,
|
| 297 |
+
markerfacecoloralt='none',
|
| 298 |
+
fillstyle=None,
|
| 299 |
+
antialiased=None,
|
| 300 |
+
dash_capstyle=None,
|
| 301 |
+
solid_capstyle=None,
|
| 302 |
+
dash_joinstyle=None,
|
| 303 |
+
solid_joinstyle=None,
|
| 304 |
+
pickradius=5,
|
| 305 |
+
drawstyle=None,
|
| 306 |
+
markevery=None,
|
| 307 |
+
**kwargs
|
| 308 |
+
):
|
| 309 |
+
"""
|
| 310 |
+
Create a `.Line2D` instance with *x* and *y* data in sequences of
|
| 311 |
+
*xdata*, *ydata*.
|
| 312 |
+
|
| 313 |
+
Additional keyword arguments are `.Line2D` properties:
|
| 314 |
+
|
| 315 |
+
%(Line2D:kwdoc)s
|
| 316 |
+
|
| 317 |
+
See :meth:`set_linestyle` for a description of the line styles,
|
| 318 |
+
:meth:`set_marker` for a description of the markers, and
|
| 319 |
+
:meth:`set_drawstyle` for a description of the draw styles.
|
| 320 |
+
|
| 321 |
+
"""
|
| 322 |
+
super().__init__()
|
| 323 |
+
|
| 324 |
+
# Convert sequences to NumPy arrays.
|
| 325 |
+
if not np.iterable(xdata):
|
| 326 |
+
raise RuntimeError('xdata must be a sequence')
|
| 327 |
+
if not np.iterable(ydata):
|
| 328 |
+
raise RuntimeError('ydata must be a sequence')
|
| 329 |
+
|
| 330 |
+
if linewidth is None:
|
| 331 |
+
linewidth = mpl.rcParams['lines.linewidth']
|
| 332 |
+
|
| 333 |
+
if linestyle is None:
|
| 334 |
+
linestyle = mpl.rcParams['lines.linestyle']
|
| 335 |
+
if marker is None:
|
| 336 |
+
marker = mpl.rcParams['lines.marker']
|
| 337 |
+
if color is None:
|
| 338 |
+
color = mpl.rcParams['lines.color']
|
| 339 |
+
|
| 340 |
+
if markersize is None:
|
| 341 |
+
markersize = mpl.rcParams['lines.markersize']
|
| 342 |
+
if antialiased is None:
|
| 343 |
+
antialiased = mpl.rcParams['lines.antialiased']
|
| 344 |
+
if dash_capstyle is None:
|
| 345 |
+
dash_capstyle = mpl.rcParams['lines.dash_capstyle']
|
| 346 |
+
if dash_joinstyle is None:
|
| 347 |
+
dash_joinstyle = mpl.rcParams['lines.dash_joinstyle']
|
| 348 |
+
if solid_capstyle is None:
|
| 349 |
+
solid_capstyle = mpl.rcParams['lines.solid_capstyle']
|
| 350 |
+
if solid_joinstyle is None:
|
| 351 |
+
solid_joinstyle = mpl.rcParams['lines.solid_joinstyle']
|
| 352 |
+
|
| 353 |
+
if drawstyle is None:
|
| 354 |
+
drawstyle = 'default'
|
| 355 |
+
|
| 356 |
+
self._dashcapstyle = None
|
| 357 |
+
self._dashjoinstyle = None
|
| 358 |
+
self._solidjoinstyle = None
|
| 359 |
+
self._solidcapstyle = None
|
| 360 |
+
self.set_dash_capstyle(dash_capstyle)
|
| 361 |
+
self.set_dash_joinstyle(dash_joinstyle)
|
| 362 |
+
self.set_solid_capstyle(solid_capstyle)
|
| 363 |
+
self.set_solid_joinstyle(solid_joinstyle)
|
| 364 |
+
|
| 365 |
+
self._linestyles = None
|
| 366 |
+
self._drawstyle = None
|
| 367 |
+
self._linewidth = linewidth
|
| 368 |
+
self._unscaled_dash_pattern = (0, None) # offset, dash
|
| 369 |
+
self._dash_pattern = (0, None) # offset, dash (scaled by linewidth)
|
| 370 |
+
|
| 371 |
+
self.set_linewidth(linewidth)
|
| 372 |
+
self.set_linestyle(linestyle)
|
| 373 |
+
self.set_drawstyle(drawstyle)
|
| 374 |
+
|
| 375 |
+
self._color = None
|
| 376 |
+
self.set_color(color)
|
| 377 |
+
if marker is None:
|
| 378 |
+
marker = 'none' # Default.
|
| 379 |
+
if not isinstance(marker, MarkerStyle):
|
| 380 |
+
self._marker = MarkerStyle(marker, fillstyle)
|
| 381 |
+
else:
|
| 382 |
+
self._marker = marker
|
| 383 |
+
|
| 384 |
+
self._gapcolor = None
|
| 385 |
+
self.set_gapcolor(gapcolor)
|
| 386 |
+
|
| 387 |
+
self._markevery = None
|
| 388 |
+
self._markersize = None
|
| 389 |
+
self._antialiased = None
|
| 390 |
+
|
| 391 |
+
self.set_markevery(markevery)
|
| 392 |
+
self.set_antialiased(antialiased)
|
| 393 |
+
self.set_markersize(markersize)
|
| 394 |
+
|
| 395 |
+
self._markeredgecolor = None
|
| 396 |
+
self._markeredgewidth = None
|
| 397 |
+
self._markerfacecolor = None
|
| 398 |
+
self._markerfacecoloralt = None
|
| 399 |
+
|
| 400 |
+
self.set_markerfacecolor(markerfacecolor) # Normalizes None to rc.
|
| 401 |
+
self.set_markerfacecoloralt(markerfacecoloralt)
|
| 402 |
+
self.set_markeredgecolor(markeredgecolor) # Normalizes None to rc.
|
| 403 |
+
self.set_markeredgewidth(markeredgewidth)
|
| 404 |
+
|
| 405 |
+
# update kwargs before updating data to give the caller a
|
| 406 |
+
# chance to init axes (and hence unit support)
|
| 407 |
+
self._internal_update(kwargs)
|
| 408 |
+
self.pickradius = pickradius
|
| 409 |
+
self.ind_offset = 0
|
| 410 |
+
if (isinstance(self._picker, Number) and
|
| 411 |
+
not isinstance(self._picker, bool)):
|
| 412 |
+
self._pickradius = self._picker
|
| 413 |
+
|
| 414 |
+
self._xorig = np.asarray([])
|
| 415 |
+
self._yorig = np.asarray([])
|
| 416 |
+
self._invalidx = True
|
| 417 |
+
self._invalidy = True
|
| 418 |
+
self._x = None
|
| 419 |
+
self._y = None
|
| 420 |
+
self._xy = None
|
| 421 |
+
self._path = None
|
| 422 |
+
self._transformed_path = None
|
| 423 |
+
self._subslice = False
|
| 424 |
+
self._x_filled = None # used in subslicing; only x is needed
|
| 425 |
+
|
| 426 |
+
self.set_data(xdata, ydata)
|
| 427 |
+
|
| 428 |
+
def contains(self, mouseevent):
|
| 429 |
+
"""
|
| 430 |
+
Test whether *mouseevent* occurred on the line.
|
| 431 |
+
|
| 432 |
+
An event is deemed to have occurred "on" the line if it is less
|
| 433 |
+
than ``self.pickradius`` (default: 5 points) away from it. Use
|
| 434 |
+
`~.Line2D.get_pickradius` or `~.Line2D.set_pickradius` to get or set
|
| 435 |
+
the pick radius.
|
| 436 |
+
|
| 437 |
+
Parameters
|
| 438 |
+
----------
|
| 439 |
+
mouseevent : `~matplotlib.backend_bases.MouseEvent`
|
| 440 |
+
|
| 441 |
+
Returns
|
| 442 |
+
-------
|
| 443 |
+
contains : bool
|
| 444 |
+
Whether any values are within the radius.
|
| 445 |
+
details : dict
|
| 446 |
+
A dictionary ``{'ind': pointlist}``, where *pointlist* is a
|
| 447 |
+
list of points of the line that are within the pickradius around
|
| 448 |
+
the event position.
|
| 449 |
+
|
| 450 |
+
TODO: sort returned indices by distance
|
| 451 |
+
"""
|
| 452 |
+
if self._different_canvas(mouseevent):
|
| 453 |
+
return False, {}
|
| 454 |
+
|
| 455 |
+
# Make sure we have data to plot
|
| 456 |
+
if self._invalidy or self._invalidx:
|
| 457 |
+
self.recache()
|
| 458 |
+
if len(self._xy) == 0:
|
| 459 |
+
return False, {}
|
| 460 |
+
|
| 461 |
+
# Convert points to pixels
|
| 462 |
+
transformed_path = self._get_transformed_path()
|
| 463 |
+
path, affine = transformed_path.get_transformed_path_and_affine()
|
| 464 |
+
path = affine.transform_path(path)
|
| 465 |
+
xy = path.vertices
|
| 466 |
+
xt = xy[:, 0]
|
| 467 |
+
yt = xy[:, 1]
|
| 468 |
+
|
| 469 |
+
# Convert pick radius from points to pixels
|
| 470 |
+
fig = self.get_figure(root=True)
|
| 471 |
+
if fig is None:
|
| 472 |
+
_log.warning('no figure set when check if mouse is on line')
|
| 473 |
+
pixels = self._pickradius
|
| 474 |
+
else:
|
| 475 |
+
pixels = fig.dpi / 72. * self._pickradius
|
| 476 |
+
|
| 477 |
+
# The math involved in checking for containment (here and inside of
|
| 478 |
+
# segment_hits) assumes that it is OK to overflow, so temporarily set
|
| 479 |
+
# the error flags accordingly.
|
| 480 |
+
with np.errstate(all='ignore'):
|
| 481 |
+
# Check for collision
|
| 482 |
+
if self._linestyle in ['None', None]:
|
| 483 |
+
# If no line, return the nearby point(s)
|
| 484 |
+
ind, = np.nonzero(
|
| 485 |
+
(xt - mouseevent.x) ** 2 + (yt - mouseevent.y) ** 2
|
| 486 |
+
<= pixels ** 2)
|
| 487 |
+
else:
|
| 488 |
+
# If line, return the nearby segment(s)
|
| 489 |
+
ind = segment_hits(mouseevent.x, mouseevent.y, xt, yt, pixels)
|
| 490 |
+
if self._drawstyle.startswith("steps"):
|
| 491 |
+
ind //= 2
|
| 492 |
+
|
| 493 |
+
ind += self.ind_offset
|
| 494 |
+
|
| 495 |
+
# Return the point(s) within radius
|
| 496 |
+
return len(ind) > 0, dict(ind=ind)
|
| 497 |
+
|
| 498 |
+
def get_pickradius(self):
|
| 499 |
+
"""
|
| 500 |
+
Return the pick radius used for containment tests.
|
| 501 |
+
|
| 502 |
+
See `.contains` for more details.
|
| 503 |
+
"""
|
| 504 |
+
return self._pickradius
|
| 505 |
+
|
| 506 |
+
def set_pickradius(self, pickradius):
|
| 507 |
+
"""
|
| 508 |
+
Set the pick radius used for containment tests.
|
| 509 |
+
|
| 510 |
+
See `.contains` for more details.
|
| 511 |
+
|
| 512 |
+
Parameters
|
| 513 |
+
----------
|
| 514 |
+
pickradius : float
|
| 515 |
+
Pick radius, in points.
|
| 516 |
+
"""
|
| 517 |
+
if not isinstance(pickradius, Real) or pickradius < 0:
|
| 518 |
+
raise ValueError("pick radius should be a distance")
|
| 519 |
+
self._pickradius = pickradius
|
| 520 |
+
|
| 521 |
+
pickradius = property(get_pickradius, set_pickradius)
|
| 522 |
+
|
| 523 |
+
def get_fillstyle(self):
|
| 524 |
+
"""
|
| 525 |
+
Return the marker fill style.
|
| 526 |
+
|
| 527 |
+
See also `~.Line2D.set_fillstyle`.
|
| 528 |
+
"""
|
| 529 |
+
return self._marker.get_fillstyle()
|
| 530 |
+
|
| 531 |
+
def set_fillstyle(self, fs):
|
| 532 |
+
"""
|
| 533 |
+
Set the marker fill style.
|
| 534 |
+
|
| 535 |
+
Parameters
|
| 536 |
+
----------
|
| 537 |
+
fs : {'full', 'left', 'right', 'bottom', 'top', 'none'}
|
| 538 |
+
Possible values:
|
| 539 |
+
|
| 540 |
+
- 'full': Fill the whole marker with the *markerfacecolor*.
|
| 541 |
+
- 'left', 'right', 'bottom', 'top': Fill the marker half at
|
| 542 |
+
the given side with the *markerfacecolor*. The other
|
| 543 |
+
half of the marker is filled with *markerfacecoloralt*.
|
| 544 |
+
- 'none': No filling.
|
| 545 |
+
|
| 546 |
+
For examples see :ref:`marker_fill_styles`.
|
| 547 |
+
"""
|
| 548 |
+
self.set_marker(MarkerStyle(self._marker.get_marker(), fs))
|
| 549 |
+
self.stale = True
|
| 550 |
+
|
| 551 |
+
def set_markevery(self, every):
|
| 552 |
+
"""
|
| 553 |
+
Set the markevery property to subsample the plot when using markers.
|
| 554 |
+
|
| 555 |
+
e.g., if ``every=5``, every 5-th marker will be plotted.
|
| 556 |
+
|
| 557 |
+
Parameters
|
| 558 |
+
----------
|
| 559 |
+
every : None or int or (int, int) or slice or list[int] or float or \
|
| 560 |
+
(float, float) or list[bool]
|
| 561 |
+
Which markers to plot.
|
| 562 |
+
|
| 563 |
+
- ``every=None``: every point will be plotted.
|
| 564 |
+
- ``every=N``: every N-th marker will be plotted starting with
|
| 565 |
+
marker 0.
|
| 566 |
+
- ``every=(start, N)``: every N-th marker, starting at index
|
| 567 |
+
*start*, will be plotted.
|
| 568 |
+
- ``every=slice(start, end, N)``: every N-th marker, starting at
|
| 569 |
+
index *start*, up to but not including index *end*, will be
|
| 570 |
+
plotted.
|
| 571 |
+
- ``every=[i, j, m, ...]``: only markers at the given indices
|
| 572 |
+
will be plotted.
|
| 573 |
+
- ``every=[True, False, True, ...]``: only positions that are True
|
| 574 |
+
will be plotted. The list must have the same length as the data
|
| 575 |
+
points.
|
| 576 |
+
- ``every=0.1``, (i.e. a float): markers will be spaced at
|
| 577 |
+
approximately equal visual distances along the line; the distance
|
| 578 |
+
along the line between markers is determined by multiplying the
|
| 579 |
+
display-coordinate distance of the Axes bounding-box diagonal
|
| 580 |
+
by the value of *every*.
|
| 581 |
+
- ``every=(0.5, 0.1)`` (i.e. a length-2 tuple of float): similar
|
| 582 |
+
to ``every=0.1`` but the first marker will be offset along the
|
| 583 |
+
line by 0.5 multiplied by the
|
| 584 |
+
display-coordinate-diagonal-distance along the line.
|
| 585 |
+
|
| 586 |
+
For examples see
|
| 587 |
+
:doc:`/gallery/lines_bars_and_markers/markevery_demo`.
|
| 588 |
+
|
| 589 |
+
Notes
|
| 590 |
+
-----
|
| 591 |
+
Setting *markevery* will still only draw markers at actual data points.
|
| 592 |
+
While the float argument form aims for uniform visual spacing, it has
|
| 593 |
+
to coerce from the ideal spacing to the nearest available data point.
|
| 594 |
+
Depending on the number and distribution of data points, the result
|
| 595 |
+
may still not look evenly spaced.
|
| 596 |
+
|
| 597 |
+
When using a start offset to specify the first marker, the offset will
|
| 598 |
+
be from the first data point which may be different from the first
|
| 599 |
+
the visible data point if the plot is zoomed in.
|
| 600 |
+
|
| 601 |
+
If zooming in on a plot when using float arguments then the actual
|
| 602 |
+
data points that have markers will change because the distance between
|
| 603 |
+
markers is always determined from the display-coordinates
|
| 604 |
+
axes-bounding-box-diagonal regardless of the actual axes data limits.
|
| 605 |
+
|
| 606 |
+
"""
|
| 607 |
+
self._markevery = every
|
| 608 |
+
self.stale = True
|
| 609 |
+
|
| 610 |
+
def get_markevery(self):
|
| 611 |
+
"""
|
| 612 |
+
Return the markevery setting for marker subsampling.
|
| 613 |
+
|
| 614 |
+
See also `~.Line2D.set_markevery`.
|
| 615 |
+
"""
|
| 616 |
+
return self._markevery
|
| 617 |
+
|
| 618 |
+
def set_picker(self, p):
|
| 619 |
+
"""
|
| 620 |
+
Set the event picker details for the line.
|
| 621 |
+
|
| 622 |
+
Parameters
|
| 623 |
+
----------
|
| 624 |
+
p : float or callable[[Artist, Event], tuple[bool, dict]]
|
| 625 |
+
If a float, it is used as the pick radius in points.
|
| 626 |
+
"""
|
| 627 |
+
if not callable(p):
|
| 628 |
+
self.set_pickradius(p)
|
| 629 |
+
self._picker = p
|
| 630 |
+
|
| 631 |
+
def get_bbox(self):
|
| 632 |
+
"""Get the bounding box of this line."""
|
| 633 |
+
bbox = Bbox([[0, 0], [0, 0]])
|
| 634 |
+
bbox.update_from_data_xy(self.get_xydata())
|
| 635 |
+
return bbox
|
| 636 |
+
|
| 637 |
+
def get_window_extent(self, renderer=None):
|
| 638 |
+
bbox = Bbox([[0, 0], [0, 0]])
|
| 639 |
+
trans_data_to_xy = self.get_transform().transform
|
| 640 |
+
bbox.update_from_data_xy(trans_data_to_xy(self.get_xydata()),
|
| 641 |
+
ignore=True)
|
| 642 |
+
# correct for marker size, if any
|
| 643 |
+
if self._marker:
|
| 644 |
+
ms = (self._markersize / 72.0 * self.get_figure(root=True).dpi) * 0.5
|
| 645 |
+
bbox = bbox.padded(ms)
|
| 646 |
+
return bbox
|
| 647 |
+
|
| 648 |
+
def set_data(self, *args):
|
| 649 |
+
"""
|
| 650 |
+
Set the x and y data.
|
| 651 |
+
|
| 652 |
+
Parameters
|
| 653 |
+
----------
|
| 654 |
+
*args : (2, N) array or two 1D arrays
|
| 655 |
+
|
| 656 |
+
See Also
|
| 657 |
+
--------
|
| 658 |
+
set_xdata
|
| 659 |
+
set_ydata
|
| 660 |
+
"""
|
| 661 |
+
if len(args) == 1:
|
| 662 |
+
(x, y), = args
|
| 663 |
+
else:
|
| 664 |
+
x, y = args
|
| 665 |
+
|
| 666 |
+
self.set_xdata(x)
|
| 667 |
+
self.set_ydata(y)
|
| 668 |
+
|
| 669 |
+
def recache_always(self):
|
| 670 |
+
self.recache(always=True)
|
| 671 |
+
|
| 672 |
+
def recache(self, always=False):
|
| 673 |
+
if always or self._invalidx:
|
| 674 |
+
xconv = self.convert_xunits(self._xorig)
|
| 675 |
+
x = _to_unmasked_float_array(xconv).ravel()
|
| 676 |
+
else:
|
| 677 |
+
x = self._x
|
| 678 |
+
if always or self._invalidy:
|
| 679 |
+
yconv = self.convert_yunits(self._yorig)
|
| 680 |
+
y = _to_unmasked_float_array(yconv).ravel()
|
| 681 |
+
else:
|
| 682 |
+
y = self._y
|
| 683 |
+
|
| 684 |
+
self._xy = np.column_stack(np.broadcast_arrays(x, y)).astype(float)
|
| 685 |
+
self._x, self._y = self._xy.T # views
|
| 686 |
+
|
| 687 |
+
self._subslice = False
|
| 688 |
+
if (self.axes
|
| 689 |
+
and len(x) > self._subslice_optim_min_size
|
| 690 |
+
and _path.is_sorted_and_has_non_nan(x)
|
| 691 |
+
and self.axes.name == 'rectilinear'
|
| 692 |
+
and self.axes.get_xscale() == 'linear'
|
| 693 |
+
and self._markevery is None
|
| 694 |
+
and self.get_clip_on()
|
| 695 |
+
and self.get_transform() == self.axes.transData):
|
| 696 |
+
self._subslice = True
|
| 697 |
+
nanmask = np.isnan(x)
|
| 698 |
+
if nanmask.any():
|
| 699 |
+
self._x_filled = self._x.copy()
|
| 700 |
+
indices = np.arange(len(x))
|
| 701 |
+
self._x_filled[nanmask] = np.interp(
|
| 702 |
+
indices[nanmask], indices[~nanmask], self._x[~nanmask])
|
| 703 |
+
else:
|
| 704 |
+
self._x_filled = self._x
|
| 705 |
+
|
| 706 |
+
if self._path is not None:
|
| 707 |
+
interpolation_steps = self._path._interpolation_steps
|
| 708 |
+
else:
|
| 709 |
+
interpolation_steps = 1
|
| 710 |
+
xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy.T)
|
| 711 |
+
self._path = Path(np.asarray(xy).T,
|
| 712 |
+
_interpolation_steps=interpolation_steps)
|
| 713 |
+
self._transformed_path = None
|
| 714 |
+
self._invalidx = False
|
| 715 |
+
self._invalidy = False
|
| 716 |
+
|
| 717 |
+
def _transform_path(self, subslice=None):
|
| 718 |
+
"""
|
| 719 |
+
Put a TransformedPath instance at self._transformed_path;
|
| 720 |
+
all invalidation of the transform is then handled by the
|
| 721 |
+
TransformedPath instance.
|
| 722 |
+
"""
|
| 723 |
+
# Masked arrays are now handled by the Path class itself
|
| 724 |
+
if subslice is not None:
|
| 725 |
+
xy = STEP_LOOKUP_MAP[self._drawstyle](*self._xy[subslice, :].T)
|
| 726 |
+
_path = Path(np.asarray(xy).T,
|
| 727 |
+
_interpolation_steps=self._path._interpolation_steps)
|
| 728 |
+
else:
|
| 729 |
+
_path = self._path
|
| 730 |
+
self._transformed_path = TransformedPath(_path, self.get_transform())
|
| 731 |
+
|
| 732 |
+
def _get_transformed_path(self):
|
| 733 |
+
"""Return this line's `~matplotlib.transforms.TransformedPath`."""
|
| 734 |
+
if self._transformed_path is None:
|
| 735 |
+
self._transform_path()
|
| 736 |
+
return self._transformed_path
|
| 737 |
+
|
| 738 |
+
def set_transform(self, t):
|
| 739 |
+
# docstring inherited
|
| 740 |
+
self._invalidx = True
|
| 741 |
+
self._invalidy = True
|
| 742 |
+
super().set_transform(t)
|
| 743 |
+
|
| 744 |
+
@allow_rasterization
|
| 745 |
+
def draw(self, renderer):
|
| 746 |
+
# docstring inherited
|
| 747 |
+
|
| 748 |
+
if not self.get_visible():
|
| 749 |
+
return
|
| 750 |
+
|
| 751 |
+
if self._invalidy or self._invalidx:
|
| 752 |
+
self.recache()
|
| 753 |
+
self.ind_offset = 0 # Needed for contains() method.
|
| 754 |
+
if self._subslice and self.axes:
|
| 755 |
+
x0, x1 = self.axes.get_xbound()
|
| 756 |
+
i0 = self._x_filled.searchsorted(x0, 'left')
|
| 757 |
+
i1 = self._x_filled.searchsorted(x1, 'right')
|
| 758 |
+
subslice = slice(max(i0 - 1, 0), i1 + 1)
|
| 759 |
+
self.ind_offset = subslice.start
|
| 760 |
+
self._transform_path(subslice)
|
| 761 |
+
else:
|
| 762 |
+
subslice = None
|
| 763 |
+
|
| 764 |
+
if self.get_path_effects():
|
| 765 |
+
from matplotlib.patheffects import PathEffectRenderer
|
| 766 |
+
renderer = PathEffectRenderer(self.get_path_effects(), renderer)
|
| 767 |
+
|
| 768 |
+
renderer.open_group('line2d', self.get_gid())
|
| 769 |
+
if self._lineStyles[self._linestyle] != '_draw_nothing':
|
| 770 |
+
tpath, affine = (self._get_transformed_path()
|
| 771 |
+
.get_transformed_path_and_affine())
|
| 772 |
+
if len(tpath.vertices):
|
| 773 |
+
gc = renderer.new_gc()
|
| 774 |
+
self._set_gc_clip(gc)
|
| 775 |
+
gc.set_url(self.get_url())
|
| 776 |
+
|
| 777 |
+
gc.set_antialiased(self._antialiased)
|
| 778 |
+
gc.set_linewidth(self._linewidth)
|
| 779 |
+
|
| 780 |
+
if self.is_dashed():
|
| 781 |
+
cap = self._dashcapstyle
|
| 782 |
+
join = self._dashjoinstyle
|
| 783 |
+
else:
|
| 784 |
+
cap = self._solidcapstyle
|
| 785 |
+
join = self._solidjoinstyle
|
| 786 |
+
gc.set_joinstyle(join)
|
| 787 |
+
gc.set_capstyle(cap)
|
| 788 |
+
gc.set_snap(self.get_snap())
|
| 789 |
+
if self.get_sketch_params() is not None:
|
| 790 |
+
gc.set_sketch_params(*self.get_sketch_params())
|
| 791 |
+
|
| 792 |
+
# We first draw a path within the gaps if needed.
|
| 793 |
+
if self.is_dashed() and self._gapcolor is not None:
|
| 794 |
+
lc_rgba = mcolors.to_rgba(self._gapcolor, self._alpha)
|
| 795 |
+
gc.set_foreground(lc_rgba, isRGBA=True)
|
| 796 |
+
|
| 797 |
+
offset_gaps, gaps = _get_inverse_dash_pattern(
|
| 798 |
+
*self._dash_pattern)
|
| 799 |
+
|
| 800 |
+
gc.set_dashes(offset_gaps, gaps)
|
| 801 |
+
renderer.draw_path(gc, tpath, affine.frozen())
|
| 802 |
+
|
| 803 |
+
lc_rgba = mcolors.to_rgba(self._color, self._alpha)
|
| 804 |
+
gc.set_foreground(lc_rgba, isRGBA=True)
|
| 805 |
+
|
| 806 |
+
gc.set_dashes(*self._dash_pattern)
|
| 807 |
+
renderer.draw_path(gc, tpath, affine.frozen())
|
| 808 |
+
gc.restore()
|
| 809 |
+
|
| 810 |
+
if self._marker and self._markersize > 0:
|
| 811 |
+
gc = renderer.new_gc()
|
| 812 |
+
self._set_gc_clip(gc)
|
| 813 |
+
gc.set_url(self.get_url())
|
| 814 |
+
gc.set_linewidth(self._markeredgewidth)
|
| 815 |
+
gc.set_antialiased(self._antialiased)
|
| 816 |
+
|
| 817 |
+
ec_rgba = mcolors.to_rgba(
|
| 818 |
+
self.get_markeredgecolor(), self._alpha)
|
| 819 |
+
fc_rgba = mcolors.to_rgba(
|
| 820 |
+
self._get_markerfacecolor(), self._alpha)
|
| 821 |
+
fcalt_rgba = mcolors.to_rgba(
|
| 822 |
+
self._get_markerfacecolor(alt=True), self._alpha)
|
| 823 |
+
# If the edgecolor is "auto", it is set according to the *line*
|
| 824 |
+
# color but inherits the alpha value of the *face* color, if any.
|
| 825 |
+
if (cbook._str_equal(self._markeredgecolor, "auto")
|
| 826 |
+
and not cbook._str_lower_equal(
|
| 827 |
+
self.get_markerfacecolor(), "none")):
|
| 828 |
+
ec_rgba = ec_rgba[:3] + (fc_rgba[3],)
|
| 829 |
+
gc.set_foreground(ec_rgba, isRGBA=True)
|
| 830 |
+
if self.get_sketch_params() is not None:
|
| 831 |
+
scale, length, randomness = self.get_sketch_params()
|
| 832 |
+
gc.set_sketch_params(scale/2, length/2, 2*randomness)
|
| 833 |
+
|
| 834 |
+
marker = self._marker
|
| 835 |
+
|
| 836 |
+
# Markers *must* be drawn ignoring the drawstyle (but don't pay the
|
| 837 |
+
# recaching if drawstyle is already "default").
|
| 838 |
+
if self.get_drawstyle() != "default":
|
| 839 |
+
with cbook._setattr_cm(
|
| 840 |
+
self, _drawstyle="default", _transformed_path=None):
|
| 841 |
+
self.recache()
|
| 842 |
+
self._transform_path(subslice)
|
| 843 |
+
tpath, affine = (self._get_transformed_path()
|
| 844 |
+
.get_transformed_points_and_affine())
|
| 845 |
+
else:
|
| 846 |
+
tpath, affine = (self._get_transformed_path()
|
| 847 |
+
.get_transformed_points_and_affine())
|
| 848 |
+
|
| 849 |
+
if len(tpath.vertices):
|
| 850 |
+
# subsample the markers if markevery is not None
|
| 851 |
+
markevery = self.get_markevery()
|
| 852 |
+
if markevery is not None:
|
| 853 |
+
subsampled = _mark_every_path(
|
| 854 |
+
markevery, tpath, affine, self.axes)
|
| 855 |
+
else:
|
| 856 |
+
subsampled = tpath
|
| 857 |
+
|
| 858 |
+
snap = marker.get_snap_threshold()
|
| 859 |
+
if isinstance(snap, Real):
|
| 860 |
+
snap = renderer.points_to_pixels(self._markersize) >= snap
|
| 861 |
+
gc.set_snap(snap)
|
| 862 |
+
gc.set_joinstyle(marker.get_joinstyle())
|
| 863 |
+
gc.set_capstyle(marker.get_capstyle())
|
| 864 |
+
marker_path = marker.get_path()
|
| 865 |
+
marker_trans = marker.get_transform()
|
| 866 |
+
w = renderer.points_to_pixels(self._markersize)
|
| 867 |
+
|
| 868 |
+
if cbook._str_equal(marker.get_marker(), ","):
|
| 869 |
+
gc.set_linewidth(0)
|
| 870 |
+
else:
|
| 871 |
+
# Don't scale for pixels, and don't stroke them
|
| 872 |
+
marker_trans = marker_trans.scale(w)
|
| 873 |
+
renderer.draw_markers(gc, marker_path, marker_trans,
|
| 874 |
+
subsampled, affine.frozen(),
|
| 875 |
+
fc_rgba)
|
| 876 |
+
|
| 877 |
+
alt_marker_path = marker.get_alt_path()
|
| 878 |
+
if alt_marker_path:
|
| 879 |
+
alt_marker_trans = marker.get_alt_transform()
|
| 880 |
+
alt_marker_trans = alt_marker_trans.scale(w)
|
| 881 |
+
renderer.draw_markers(
|
| 882 |
+
gc, alt_marker_path, alt_marker_trans, subsampled,
|
| 883 |
+
affine.frozen(), fcalt_rgba)
|
| 884 |
+
|
| 885 |
+
gc.restore()
|
| 886 |
+
|
| 887 |
+
renderer.close_group('line2d')
|
| 888 |
+
self.stale = False
|
| 889 |
+
|
| 890 |
+
def get_antialiased(self):
|
| 891 |
+
"""Return whether antialiased rendering is used."""
|
| 892 |
+
return self._antialiased
|
| 893 |
+
|
| 894 |
+
def get_color(self):
|
| 895 |
+
"""
|
| 896 |
+
Return the line color.
|
| 897 |
+
|
| 898 |
+
See also `~.Line2D.set_color`.
|
| 899 |
+
"""
|
| 900 |
+
return self._color
|
| 901 |
+
|
| 902 |
+
def get_drawstyle(self):
|
| 903 |
+
"""
|
| 904 |
+
Return the drawstyle.
|
| 905 |
+
|
| 906 |
+
See also `~.Line2D.set_drawstyle`.
|
| 907 |
+
"""
|
| 908 |
+
return self._drawstyle
|
| 909 |
+
|
| 910 |
+
def get_gapcolor(self):
|
| 911 |
+
"""
|
| 912 |
+
Return the line gapcolor.
|
| 913 |
+
|
| 914 |
+
See also `~.Line2D.set_gapcolor`.
|
| 915 |
+
"""
|
| 916 |
+
return self._gapcolor
|
| 917 |
+
|
| 918 |
+
def get_linestyle(self):
|
| 919 |
+
"""
|
| 920 |
+
Return the linestyle.
|
| 921 |
+
|
| 922 |
+
See also `~.Line2D.set_linestyle`.
|
| 923 |
+
"""
|
| 924 |
+
return self._linestyle
|
| 925 |
+
|
| 926 |
+
def get_linewidth(self):
|
| 927 |
+
"""
|
| 928 |
+
Return the linewidth in points.
|
| 929 |
+
|
| 930 |
+
See also `~.Line2D.set_linewidth`.
|
| 931 |
+
"""
|
| 932 |
+
return self._linewidth
|
| 933 |
+
|
| 934 |
+
def get_marker(self):
|
| 935 |
+
"""
|
| 936 |
+
Return the line marker.
|
| 937 |
+
|
| 938 |
+
See also `~.Line2D.set_marker`.
|
| 939 |
+
"""
|
| 940 |
+
return self._marker.get_marker()
|
| 941 |
+
|
| 942 |
+
def get_markeredgecolor(self):
|
| 943 |
+
"""
|
| 944 |
+
Return the marker edge color.
|
| 945 |
+
|
| 946 |
+
See also `~.Line2D.set_markeredgecolor`.
|
| 947 |
+
"""
|
| 948 |
+
mec = self._markeredgecolor
|
| 949 |
+
if cbook._str_equal(mec, 'auto'):
|
| 950 |
+
if mpl.rcParams['_internal.classic_mode']:
|
| 951 |
+
if self._marker.get_marker() in ('.', ','):
|
| 952 |
+
return self._color
|
| 953 |
+
if (self._marker.is_filled()
|
| 954 |
+
and self._marker.get_fillstyle() != 'none'):
|
| 955 |
+
return 'k' # Bad hard-wired default...
|
| 956 |
+
return self._color
|
| 957 |
+
else:
|
| 958 |
+
return mec
|
| 959 |
+
|
| 960 |
+
def get_markeredgewidth(self):
|
| 961 |
+
"""
|
| 962 |
+
Return the marker edge width in points.
|
| 963 |
+
|
| 964 |
+
See also `~.Line2D.set_markeredgewidth`.
|
| 965 |
+
"""
|
| 966 |
+
return self._markeredgewidth
|
| 967 |
+
|
| 968 |
+
def _get_markerfacecolor(self, alt=False):
|
| 969 |
+
if self._marker.get_fillstyle() == 'none':
|
| 970 |
+
return 'none'
|
| 971 |
+
fc = self._markerfacecoloralt if alt else self._markerfacecolor
|
| 972 |
+
if cbook._str_lower_equal(fc, 'auto'):
|
| 973 |
+
return self._color
|
| 974 |
+
else:
|
| 975 |
+
return fc
|
| 976 |
+
|
| 977 |
+
def get_markerfacecolor(self):
|
| 978 |
+
"""
|
| 979 |
+
Return the marker face color.
|
| 980 |
+
|
| 981 |
+
See also `~.Line2D.set_markerfacecolor`.
|
| 982 |
+
"""
|
| 983 |
+
return self._get_markerfacecolor(alt=False)
|
| 984 |
+
|
| 985 |
+
def get_markerfacecoloralt(self):
|
| 986 |
+
"""
|
| 987 |
+
Return the alternate marker face color.
|
| 988 |
+
|
| 989 |
+
See also `~.Line2D.set_markerfacecoloralt`.
|
| 990 |
+
"""
|
| 991 |
+
return self._get_markerfacecolor(alt=True)
|
| 992 |
+
|
| 993 |
+
def get_markersize(self):
|
| 994 |
+
"""
|
| 995 |
+
Return the marker size in points.
|
| 996 |
+
|
| 997 |
+
See also `~.Line2D.set_markersize`.
|
| 998 |
+
"""
|
| 999 |
+
return self._markersize
|
| 1000 |
+
|
| 1001 |
+
def get_data(self, orig=True):
|
| 1002 |
+
"""
|
| 1003 |
+
Return the line data as an ``(xdata, ydata)`` pair.
|
| 1004 |
+
|
| 1005 |
+
If *orig* is *True*, return the original data.
|
| 1006 |
+
"""
|
| 1007 |
+
return self.get_xdata(orig=orig), self.get_ydata(orig=orig)
|
| 1008 |
+
|
| 1009 |
+
def get_xdata(self, orig=True):
|
| 1010 |
+
"""
|
| 1011 |
+
Return the xdata.
|
| 1012 |
+
|
| 1013 |
+
If *orig* is *True*, return the original data, else the
|
| 1014 |
+
processed data.
|
| 1015 |
+
"""
|
| 1016 |
+
if orig:
|
| 1017 |
+
return self._xorig
|
| 1018 |
+
if self._invalidx:
|
| 1019 |
+
self.recache()
|
| 1020 |
+
return self._x
|
| 1021 |
+
|
| 1022 |
+
def get_ydata(self, orig=True):
|
| 1023 |
+
"""
|
| 1024 |
+
Return the ydata.
|
| 1025 |
+
|
| 1026 |
+
If *orig* is *True*, return the original data, else the
|
| 1027 |
+
processed data.
|
| 1028 |
+
"""
|
| 1029 |
+
if orig:
|
| 1030 |
+
return self._yorig
|
| 1031 |
+
if self._invalidy:
|
| 1032 |
+
self.recache()
|
| 1033 |
+
return self._y
|
| 1034 |
+
|
| 1035 |
+
def get_path(self):
|
| 1036 |
+
"""Return the `~matplotlib.path.Path` associated with this line."""
|
| 1037 |
+
if self._invalidy or self._invalidx:
|
| 1038 |
+
self.recache()
|
| 1039 |
+
return self._path
|
| 1040 |
+
|
| 1041 |
+
def get_xydata(self):
|
| 1042 |
+
"""Return the *xy* data as a (N, 2) array."""
|
| 1043 |
+
if self._invalidy or self._invalidx:
|
| 1044 |
+
self.recache()
|
| 1045 |
+
return self._xy
|
| 1046 |
+
|
| 1047 |
+
def set_antialiased(self, b):
|
| 1048 |
+
"""
|
| 1049 |
+
Set whether to use antialiased rendering.
|
| 1050 |
+
|
| 1051 |
+
Parameters
|
| 1052 |
+
----------
|
| 1053 |
+
b : bool
|
| 1054 |
+
"""
|
| 1055 |
+
if self._antialiased != b:
|
| 1056 |
+
self.stale = True
|
| 1057 |
+
self._antialiased = b
|
| 1058 |
+
|
| 1059 |
+
def set_color(self, color):
|
| 1060 |
+
"""
|
| 1061 |
+
Set the color of the line.
|
| 1062 |
+
|
| 1063 |
+
Parameters
|
| 1064 |
+
----------
|
| 1065 |
+
color : :mpltype:`color`
|
| 1066 |
+
"""
|
| 1067 |
+
mcolors._check_color_like(color=color)
|
| 1068 |
+
self._color = color
|
| 1069 |
+
self.stale = True
|
| 1070 |
+
|
| 1071 |
+
def set_drawstyle(self, drawstyle):
|
| 1072 |
+
"""
|
| 1073 |
+
Set the drawstyle of the plot.
|
| 1074 |
+
|
| 1075 |
+
The drawstyle determines how the points are connected.
|
| 1076 |
+
|
| 1077 |
+
Parameters
|
| 1078 |
+
----------
|
| 1079 |
+
drawstyle : {'default', 'steps', 'steps-pre', 'steps-mid', \
|
| 1080 |
+
'steps-post'}, default: 'default'
|
| 1081 |
+
For 'default', the points are connected with straight lines.
|
| 1082 |
+
|
| 1083 |
+
The steps variants connect the points with step-like lines,
|
| 1084 |
+
i.e. horizontal lines with vertical steps. They differ in the
|
| 1085 |
+
location of the step:
|
| 1086 |
+
|
| 1087 |
+
- 'steps-pre': The step is at the beginning of the line segment,
|
| 1088 |
+
i.e. the line will be at the y-value of point to the right.
|
| 1089 |
+
- 'steps-mid': The step is halfway between the points.
|
| 1090 |
+
- 'steps-post: The step is at the end of the line segment,
|
| 1091 |
+
i.e. the line will be at the y-value of the point to the left.
|
| 1092 |
+
- 'steps' is equal to 'steps-pre' and is maintained for
|
| 1093 |
+
backward-compatibility.
|
| 1094 |
+
|
| 1095 |
+
For examples see :doc:`/gallery/lines_bars_and_markers/step_demo`.
|
| 1096 |
+
"""
|
| 1097 |
+
if drawstyle is None:
|
| 1098 |
+
drawstyle = 'default'
|
| 1099 |
+
_api.check_in_list(self.drawStyles, drawstyle=drawstyle)
|
| 1100 |
+
if self._drawstyle != drawstyle:
|
| 1101 |
+
self.stale = True
|
| 1102 |
+
# invalidate to trigger a recache of the path
|
| 1103 |
+
self._invalidx = True
|
| 1104 |
+
self._drawstyle = drawstyle
|
| 1105 |
+
|
| 1106 |
+
def set_gapcolor(self, gapcolor):
|
| 1107 |
+
"""
|
| 1108 |
+
Set a color to fill the gaps in the dashed line style.
|
| 1109 |
+
|
| 1110 |
+
.. note::
|
| 1111 |
+
|
| 1112 |
+
Striped lines are created by drawing two interleaved dashed lines.
|
| 1113 |
+
There can be overlaps between those two, which may result in
|
| 1114 |
+
artifacts when using transparency.
|
| 1115 |
+
|
| 1116 |
+
This functionality is experimental and may change.
|
| 1117 |
+
|
| 1118 |
+
Parameters
|
| 1119 |
+
----------
|
| 1120 |
+
gapcolor : :mpltype:`color` or None
|
| 1121 |
+
The color with which to fill the gaps. If None, the gaps are
|
| 1122 |
+
unfilled.
|
| 1123 |
+
"""
|
| 1124 |
+
if gapcolor is not None:
|
| 1125 |
+
mcolors._check_color_like(color=gapcolor)
|
| 1126 |
+
self._gapcolor = gapcolor
|
| 1127 |
+
self.stale = True
|
| 1128 |
+
|
| 1129 |
+
def set_linewidth(self, w):
|
| 1130 |
+
"""
|
| 1131 |
+
Set the line width in points.
|
| 1132 |
+
|
| 1133 |
+
Parameters
|
| 1134 |
+
----------
|
| 1135 |
+
w : float
|
| 1136 |
+
Line width, in points.
|
| 1137 |
+
"""
|
| 1138 |
+
w = float(w)
|
| 1139 |
+
if self._linewidth != w:
|
| 1140 |
+
self.stale = True
|
| 1141 |
+
self._linewidth = w
|
| 1142 |
+
self._dash_pattern = _scale_dashes(*self._unscaled_dash_pattern, w)
|
| 1143 |
+
|
| 1144 |
+
def set_linestyle(self, ls):
|
| 1145 |
+
"""
|
| 1146 |
+
Set the linestyle of the line.
|
| 1147 |
+
|
| 1148 |
+
Parameters
|
| 1149 |
+
----------
|
| 1150 |
+
ls : {'-', '--', '-.', ':', '', (offset, on-off-seq), ...}
|
| 1151 |
+
Possible values:
|
| 1152 |
+
|
| 1153 |
+
- A string:
|
| 1154 |
+
|
| 1155 |
+
========================================== =================
|
| 1156 |
+
linestyle description
|
| 1157 |
+
========================================== =================
|
| 1158 |
+
``'-'`` or ``'solid'`` solid line
|
| 1159 |
+
``'--'`` or ``'dashed'`` dashed line
|
| 1160 |
+
``'-.'`` or ``'dashdot'`` dash-dotted line
|
| 1161 |
+
``':'`` or ``'dotted'`` dotted line
|
| 1162 |
+
``'none'``, ``'None'``, ``' '``, or ``''`` draw nothing
|
| 1163 |
+
========================================== =================
|
| 1164 |
+
|
| 1165 |
+
- Alternatively a dash tuple of the following form can be
|
| 1166 |
+
provided::
|
| 1167 |
+
|
| 1168 |
+
(offset, onoffseq)
|
| 1169 |
+
|
| 1170 |
+
where ``onoffseq`` is an even length tuple of on and off ink
|
| 1171 |
+
in points. See also :meth:`set_dashes`.
|
| 1172 |
+
|
| 1173 |
+
For examples see :doc:`/gallery/lines_bars_and_markers/linestyles`.
|
| 1174 |
+
"""
|
| 1175 |
+
if isinstance(ls, str):
|
| 1176 |
+
if ls in [' ', '', 'none']:
|
| 1177 |
+
ls = 'None'
|
| 1178 |
+
_api.check_in_list([*self._lineStyles, *ls_mapper_r], ls=ls)
|
| 1179 |
+
if ls not in self._lineStyles:
|
| 1180 |
+
ls = ls_mapper_r[ls]
|
| 1181 |
+
self._linestyle = ls
|
| 1182 |
+
else:
|
| 1183 |
+
self._linestyle = '--'
|
| 1184 |
+
self._unscaled_dash_pattern = _get_dash_pattern(ls)
|
| 1185 |
+
self._dash_pattern = _scale_dashes(
|
| 1186 |
+
*self._unscaled_dash_pattern, self._linewidth)
|
| 1187 |
+
self.stale = True
|
| 1188 |
+
|
| 1189 |
+
@_docstring.interpd
|
| 1190 |
+
def set_marker(self, marker):
|
| 1191 |
+
"""
|
| 1192 |
+
Set the line marker.
|
| 1193 |
+
|
| 1194 |
+
Parameters
|
| 1195 |
+
----------
|
| 1196 |
+
marker : marker style string, `~.path.Path` or `~.markers.MarkerStyle`
|
| 1197 |
+
See `~matplotlib.markers` for full description of possible
|
| 1198 |
+
arguments.
|
| 1199 |
+
"""
|
| 1200 |
+
self._marker = MarkerStyle(marker, self._marker.get_fillstyle())
|
| 1201 |
+
self.stale = True
|
| 1202 |
+
|
| 1203 |
+
def _set_markercolor(self, name, has_rcdefault, val):
|
| 1204 |
+
if val is None:
|
| 1205 |
+
val = mpl.rcParams[f"lines.{name}"] if has_rcdefault else "auto"
|
| 1206 |
+
attr = f"_{name}"
|
| 1207 |
+
current = getattr(self, attr)
|
| 1208 |
+
if current is None:
|
| 1209 |
+
self.stale = True
|
| 1210 |
+
else:
|
| 1211 |
+
neq = current != val
|
| 1212 |
+
# Much faster than `np.any(current != val)` if no arrays are used.
|
| 1213 |
+
if neq.any() if isinstance(neq, np.ndarray) else neq:
|
| 1214 |
+
self.stale = True
|
| 1215 |
+
setattr(self, attr, val)
|
| 1216 |
+
|
| 1217 |
+
def set_markeredgecolor(self, ec):
|
| 1218 |
+
"""
|
| 1219 |
+
Set the marker edge color.
|
| 1220 |
+
|
| 1221 |
+
Parameters
|
| 1222 |
+
----------
|
| 1223 |
+
ec : :mpltype:`color`
|
| 1224 |
+
"""
|
| 1225 |
+
self._set_markercolor("markeredgecolor", True, ec)
|
| 1226 |
+
|
| 1227 |
+
def set_markerfacecolor(self, fc):
|
| 1228 |
+
"""
|
| 1229 |
+
Set the marker face color.
|
| 1230 |
+
|
| 1231 |
+
Parameters
|
| 1232 |
+
----------
|
| 1233 |
+
fc : :mpltype:`color`
|
| 1234 |
+
"""
|
| 1235 |
+
self._set_markercolor("markerfacecolor", True, fc)
|
| 1236 |
+
|
| 1237 |
+
def set_markerfacecoloralt(self, fc):
|
| 1238 |
+
"""
|
| 1239 |
+
Set the alternate marker face color.
|
| 1240 |
+
|
| 1241 |
+
Parameters
|
| 1242 |
+
----------
|
| 1243 |
+
fc : :mpltype:`color`
|
| 1244 |
+
"""
|
| 1245 |
+
self._set_markercolor("markerfacecoloralt", False, fc)
|
| 1246 |
+
|
| 1247 |
+
def set_markeredgewidth(self, ew):
|
| 1248 |
+
"""
|
| 1249 |
+
Set the marker edge width in points.
|
| 1250 |
+
|
| 1251 |
+
Parameters
|
| 1252 |
+
----------
|
| 1253 |
+
ew : float
|
| 1254 |
+
Marker edge width, in points.
|
| 1255 |
+
"""
|
| 1256 |
+
if ew is None:
|
| 1257 |
+
ew = mpl.rcParams['lines.markeredgewidth']
|
| 1258 |
+
if self._markeredgewidth != ew:
|
| 1259 |
+
self.stale = True
|
| 1260 |
+
self._markeredgewidth = ew
|
| 1261 |
+
|
| 1262 |
+
def set_markersize(self, sz):
|
| 1263 |
+
"""
|
| 1264 |
+
Set the marker size in points.
|
| 1265 |
+
|
| 1266 |
+
Parameters
|
| 1267 |
+
----------
|
| 1268 |
+
sz : float
|
| 1269 |
+
Marker size, in points.
|
| 1270 |
+
"""
|
| 1271 |
+
sz = float(sz)
|
| 1272 |
+
if self._markersize != sz:
|
| 1273 |
+
self.stale = True
|
| 1274 |
+
self._markersize = sz
|
| 1275 |
+
|
| 1276 |
+
def set_xdata(self, x):
|
| 1277 |
+
"""
|
| 1278 |
+
Set the data array for x.
|
| 1279 |
+
|
| 1280 |
+
Parameters
|
| 1281 |
+
----------
|
| 1282 |
+
x : 1D array
|
| 1283 |
+
|
| 1284 |
+
See Also
|
| 1285 |
+
--------
|
| 1286 |
+
set_data
|
| 1287 |
+
set_ydata
|
| 1288 |
+
"""
|
| 1289 |
+
if not np.iterable(x):
|
| 1290 |
+
raise RuntimeError('x must be a sequence')
|
| 1291 |
+
self._xorig = copy.copy(x)
|
| 1292 |
+
self._invalidx = True
|
| 1293 |
+
self.stale = True
|
| 1294 |
+
|
| 1295 |
+
def set_ydata(self, y):
|
| 1296 |
+
"""
|
| 1297 |
+
Set the data array for y.
|
| 1298 |
+
|
| 1299 |
+
Parameters
|
| 1300 |
+
----------
|
| 1301 |
+
y : 1D array
|
| 1302 |
+
|
| 1303 |
+
See Also
|
| 1304 |
+
--------
|
| 1305 |
+
set_data
|
| 1306 |
+
set_xdata
|
| 1307 |
+
"""
|
| 1308 |
+
if not np.iterable(y):
|
| 1309 |
+
raise RuntimeError('y must be a sequence')
|
| 1310 |
+
self._yorig = copy.copy(y)
|
| 1311 |
+
self._invalidy = True
|
| 1312 |
+
self.stale = True
|
| 1313 |
+
|
| 1314 |
+
def set_dashes(self, seq):
|
| 1315 |
+
"""
|
| 1316 |
+
Set the dash sequence.
|
| 1317 |
+
|
| 1318 |
+
The dash sequence is a sequence of floats of even length describing
|
| 1319 |
+
the length of dashes and spaces in points.
|
| 1320 |
+
|
| 1321 |
+
For example, (5, 2, 1, 2) describes a sequence of 5 point and 1 point
|
| 1322 |
+
dashes separated by 2 point spaces.
|
| 1323 |
+
|
| 1324 |
+
See also `~.Line2D.set_gapcolor`, which allows those spaces to be
|
| 1325 |
+
filled with a color.
|
| 1326 |
+
|
| 1327 |
+
Parameters
|
| 1328 |
+
----------
|
| 1329 |
+
seq : sequence of floats (on/off ink in points) or (None, None)
|
| 1330 |
+
If *seq* is empty or ``(None, None)``, the linestyle will be set
|
| 1331 |
+
to solid.
|
| 1332 |
+
"""
|
| 1333 |
+
if seq == (None, None) or len(seq) == 0:
|
| 1334 |
+
self.set_linestyle('-')
|
| 1335 |
+
else:
|
| 1336 |
+
self.set_linestyle((0, seq))
|
| 1337 |
+
|
| 1338 |
+
def update_from(self, other):
|
| 1339 |
+
"""Copy properties from *other* to self."""
|
| 1340 |
+
super().update_from(other)
|
| 1341 |
+
self._linestyle = other._linestyle
|
| 1342 |
+
self._linewidth = other._linewidth
|
| 1343 |
+
self._color = other._color
|
| 1344 |
+
self._gapcolor = other._gapcolor
|
| 1345 |
+
self._markersize = other._markersize
|
| 1346 |
+
self._markerfacecolor = other._markerfacecolor
|
| 1347 |
+
self._markerfacecoloralt = other._markerfacecoloralt
|
| 1348 |
+
self._markeredgecolor = other._markeredgecolor
|
| 1349 |
+
self._markeredgewidth = other._markeredgewidth
|
| 1350 |
+
self._unscaled_dash_pattern = other._unscaled_dash_pattern
|
| 1351 |
+
self._dash_pattern = other._dash_pattern
|
| 1352 |
+
self._dashcapstyle = other._dashcapstyle
|
| 1353 |
+
self._dashjoinstyle = other._dashjoinstyle
|
| 1354 |
+
self._solidcapstyle = other._solidcapstyle
|
| 1355 |
+
self._solidjoinstyle = other._solidjoinstyle
|
| 1356 |
+
|
| 1357 |
+
self._linestyle = other._linestyle
|
| 1358 |
+
self._marker = MarkerStyle(marker=other._marker)
|
| 1359 |
+
self._drawstyle = other._drawstyle
|
| 1360 |
+
|
| 1361 |
+
@_docstring.interpd
|
| 1362 |
+
def set_dash_joinstyle(self, s):
|
| 1363 |
+
"""
|
| 1364 |
+
How to join segments of the line if it `~Line2D.is_dashed`.
|
| 1365 |
+
|
| 1366 |
+
The default joinstyle is :rc:`lines.dash_joinstyle`.
|
| 1367 |
+
|
| 1368 |
+
Parameters
|
| 1369 |
+
----------
|
| 1370 |
+
s : `.JoinStyle` or %(JoinStyle)s
|
| 1371 |
+
"""
|
| 1372 |
+
js = JoinStyle(s)
|
| 1373 |
+
if self._dashjoinstyle != js:
|
| 1374 |
+
self.stale = True
|
| 1375 |
+
self._dashjoinstyle = js
|
| 1376 |
+
|
| 1377 |
+
@_docstring.interpd
|
| 1378 |
+
def set_solid_joinstyle(self, s):
|
| 1379 |
+
"""
|
| 1380 |
+
How to join segments if the line is solid (not `~Line2D.is_dashed`).
|
| 1381 |
+
|
| 1382 |
+
The default joinstyle is :rc:`lines.solid_joinstyle`.
|
| 1383 |
+
|
| 1384 |
+
Parameters
|
| 1385 |
+
----------
|
| 1386 |
+
s : `.JoinStyle` or %(JoinStyle)s
|
| 1387 |
+
"""
|
| 1388 |
+
js = JoinStyle(s)
|
| 1389 |
+
if self._solidjoinstyle != js:
|
| 1390 |
+
self.stale = True
|
| 1391 |
+
self._solidjoinstyle = js
|
| 1392 |
+
|
| 1393 |
+
def get_dash_joinstyle(self):
|
| 1394 |
+
"""
|
| 1395 |
+
Return the `.JoinStyle` for dashed lines.
|
| 1396 |
+
|
| 1397 |
+
See also `~.Line2D.set_dash_joinstyle`.
|
| 1398 |
+
"""
|
| 1399 |
+
return self._dashjoinstyle.name
|
| 1400 |
+
|
| 1401 |
+
def get_solid_joinstyle(self):
|
| 1402 |
+
"""
|
| 1403 |
+
Return the `.JoinStyle` for solid lines.
|
| 1404 |
+
|
| 1405 |
+
See also `~.Line2D.set_solid_joinstyle`.
|
| 1406 |
+
"""
|
| 1407 |
+
return self._solidjoinstyle.name
|
| 1408 |
+
|
| 1409 |
+
@_docstring.interpd
|
| 1410 |
+
def set_dash_capstyle(self, s):
|
| 1411 |
+
"""
|
| 1412 |
+
How to draw the end caps if the line is `~Line2D.is_dashed`.
|
| 1413 |
+
|
| 1414 |
+
The default capstyle is :rc:`lines.dash_capstyle`.
|
| 1415 |
+
|
| 1416 |
+
Parameters
|
| 1417 |
+
----------
|
| 1418 |
+
s : `.CapStyle` or %(CapStyle)s
|
| 1419 |
+
"""
|
| 1420 |
+
cs = CapStyle(s)
|
| 1421 |
+
if self._dashcapstyle != cs:
|
| 1422 |
+
self.stale = True
|
| 1423 |
+
self._dashcapstyle = cs
|
| 1424 |
+
|
| 1425 |
+
@_docstring.interpd
|
| 1426 |
+
def set_solid_capstyle(self, s):
|
| 1427 |
+
"""
|
| 1428 |
+
How to draw the end caps if the line is solid (not `~Line2D.is_dashed`)
|
| 1429 |
+
|
| 1430 |
+
The default capstyle is :rc:`lines.solid_capstyle`.
|
| 1431 |
+
|
| 1432 |
+
Parameters
|
| 1433 |
+
----------
|
| 1434 |
+
s : `.CapStyle` or %(CapStyle)s
|
| 1435 |
+
"""
|
| 1436 |
+
cs = CapStyle(s)
|
| 1437 |
+
if self._solidcapstyle != cs:
|
| 1438 |
+
self.stale = True
|
| 1439 |
+
self._solidcapstyle = cs
|
| 1440 |
+
|
| 1441 |
+
def get_dash_capstyle(self):
|
| 1442 |
+
"""
|
| 1443 |
+
Return the `.CapStyle` for dashed lines.
|
| 1444 |
+
|
| 1445 |
+
See also `~.Line2D.set_dash_capstyle`.
|
| 1446 |
+
"""
|
| 1447 |
+
return self._dashcapstyle.name
|
| 1448 |
+
|
| 1449 |
+
def get_solid_capstyle(self):
|
| 1450 |
+
"""
|
| 1451 |
+
Return the `.CapStyle` for solid lines.
|
| 1452 |
+
|
| 1453 |
+
See also `~.Line2D.set_solid_capstyle`.
|
| 1454 |
+
"""
|
| 1455 |
+
return self._solidcapstyle.name
|
| 1456 |
+
|
| 1457 |
+
def is_dashed(self):
|
| 1458 |
+
"""
|
| 1459 |
+
Return whether line has a dashed linestyle.
|
| 1460 |
+
|
| 1461 |
+
A custom linestyle is assumed to be dashed, we do not inspect the
|
| 1462 |
+
``onoffseq`` directly.
|
| 1463 |
+
|
| 1464 |
+
See also `~.Line2D.set_linestyle`.
|
| 1465 |
+
"""
|
| 1466 |
+
return self._linestyle in ('--', '-.', ':')
|
| 1467 |
+
|
| 1468 |
+
|
| 1469 |
+
class AxLine(Line2D):
|
| 1470 |
+
"""
|
| 1471 |
+
A helper class that implements `~.Axes.axline`, by recomputing the artist
|
| 1472 |
+
transform at draw time.
|
| 1473 |
+
"""
|
| 1474 |
+
|
| 1475 |
+
def __init__(self, xy1, xy2, slope, **kwargs):
|
| 1476 |
+
"""
|
| 1477 |
+
Parameters
|
| 1478 |
+
----------
|
| 1479 |
+
xy1 : (float, float)
|
| 1480 |
+
The first set of (x, y) coordinates for the line to pass through.
|
| 1481 |
+
xy2 : (float, float) or None
|
| 1482 |
+
The second set of (x, y) coordinates for the line to pass through.
|
| 1483 |
+
Both *xy2* and *slope* must be passed, but one of them must be None.
|
| 1484 |
+
slope : float or None
|
| 1485 |
+
The slope of the line. Both *xy2* and *slope* must be passed, but one of
|
| 1486 |
+
them must be None.
|
| 1487 |
+
"""
|
| 1488 |
+
super().__init__([0, 1], [0, 1], **kwargs)
|
| 1489 |
+
|
| 1490 |
+
if (xy2 is None and slope is None or
|
| 1491 |
+
xy2 is not None and slope is not None):
|
| 1492 |
+
raise TypeError(
|
| 1493 |
+
"Exactly one of 'xy2' and 'slope' must be given")
|
| 1494 |
+
|
| 1495 |
+
self._slope = slope
|
| 1496 |
+
self._xy1 = xy1
|
| 1497 |
+
self._xy2 = xy2
|
| 1498 |
+
|
| 1499 |
+
def get_transform(self):
|
| 1500 |
+
ax = self.axes
|
| 1501 |
+
points_transform = self._transform - ax.transData + ax.transScale
|
| 1502 |
+
|
| 1503 |
+
if self._xy2 is not None:
|
| 1504 |
+
# two points were given
|
| 1505 |
+
(x1, y1), (x2, y2) = \
|
| 1506 |
+
points_transform.transform([self._xy1, self._xy2])
|
| 1507 |
+
dx = x2 - x1
|
| 1508 |
+
dy = y2 - y1
|
| 1509 |
+
if dx == 0:
|
| 1510 |
+
if dy == 0:
|
| 1511 |
+
raise ValueError(
|
| 1512 |
+
f"Cannot draw a line through two identical points "
|
| 1513 |
+
f"(x={(x1, x2)}, y={(y1, y2)})")
|
| 1514 |
+
slope = np.inf
|
| 1515 |
+
else:
|
| 1516 |
+
slope = dy / dx
|
| 1517 |
+
else:
|
| 1518 |
+
# one point and a slope were given
|
| 1519 |
+
x1, y1 = points_transform.transform(self._xy1)
|
| 1520 |
+
slope = self._slope
|
| 1521 |
+
(vxlo, vylo), (vxhi, vyhi) = ax.transScale.transform(ax.viewLim)
|
| 1522 |
+
# General case: find intersections with view limits in either
|
| 1523 |
+
# direction, and draw between the middle two points.
|
| 1524 |
+
if slope == 0:
|
| 1525 |
+
start = vxlo, y1
|
| 1526 |
+
stop = vxhi, y1
|
| 1527 |
+
elif np.isinf(slope):
|
| 1528 |
+
start = x1, vylo
|
| 1529 |
+
stop = x1, vyhi
|
| 1530 |
+
else:
|
| 1531 |
+
_, start, stop, _ = sorted([
|
| 1532 |
+
(vxlo, y1 + (vxlo - x1) * slope),
|
| 1533 |
+
(vxhi, y1 + (vxhi - x1) * slope),
|
| 1534 |
+
(x1 + (vylo - y1) / slope, vylo),
|
| 1535 |
+
(x1 + (vyhi - y1) / slope, vyhi),
|
| 1536 |
+
])
|
| 1537 |
+
return (BboxTransformTo(Bbox([start, stop]))
|
| 1538 |
+
+ ax.transLimits + ax.transAxes)
|
| 1539 |
+
|
| 1540 |
+
def draw(self, renderer):
|
| 1541 |
+
self._transformed_path = None # Force regen.
|
| 1542 |
+
super().draw(renderer)
|
| 1543 |
+
|
| 1544 |
+
def get_xy1(self):
|
| 1545 |
+
"""Return the *xy1* value of the line."""
|
| 1546 |
+
return self._xy1
|
| 1547 |
+
|
| 1548 |
+
def get_xy2(self):
|
| 1549 |
+
"""Return the *xy2* value of the line."""
|
| 1550 |
+
return self._xy2
|
| 1551 |
+
|
| 1552 |
+
def get_slope(self):
|
| 1553 |
+
"""Return the *slope* value of the line."""
|
| 1554 |
+
return self._slope
|
| 1555 |
+
|
| 1556 |
+
def set_xy1(self, *args, **kwargs):
|
| 1557 |
+
"""
|
| 1558 |
+
Set the *xy1* value of the line.
|
| 1559 |
+
|
| 1560 |
+
Parameters
|
| 1561 |
+
----------
|
| 1562 |
+
xy1 : tuple[float, float]
|
| 1563 |
+
Points for the line to pass through.
|
| 1564 |
+
"""
|
| 1565 |
+
params = _api.select_matching_signature([
|
| 1566 |
+
lambda self, x, y: locals(), lambda self, xy1: locals(),
|
| 1567 |
+
], self, *args, **kwargs)
|
| 1568 |
+
if "x" in params:
|
| 1569 |
+
_api.warn_deprecated("3.10", message=(
|
| 1570 |
+
"Passing x and y separately to AxLine.set_xy1 is deprecated since "
|
| 1571 |
+
"%(since)s; pass them as a single tuple instead."))
|
| 1572 |
+
xy1 = params["x"], params["y"]
|
| 1573 |
+
else:
|
| 1574 |
+
xy1 = params["xy1"]
|
| 1575 |
+
self._xy1 = xy1
|
| 1576 |
+
|
| 1577 |
+
def set_xy2(self, *args, **kwargs):
|
| 1578 |
+
"""
|
| 1579 |
+
Set the *xy2* value of the line.
|
| 1580 |
+
|
| 1581 |
+
.. note::
|
| 1582 |
+
|
| 1583 |
+
You can only set *xy2* if the line was created using the *xy2*
|
| 1584 |
+
parameter. If the line was created using *slope*, please use
|
| 1585 |
+
`~.AxLine.set_slope`.
|
| 1586 |
+
|
| 1587 |
+
Parameters
|
| 1588 |
+
----------
|
| 1589 |
+
xy2 : tuple[float, float]
|
| 1590 |
+
Points for the line to pass through.
|
| 1591 |
+
"""
|
| 1592 |
+
if self._slope is None:
|
| 1593 |
+
params = _api.select_matching_signature([
|
| 1594 |
+
lambda self, x, y: locals(), lambda self, xy2: locals(),
|
| 1595 |
+
], self, *args, **kwargs)
|
| 1596 |
+
if "x" in params:
|
| 1597 |
+
_api.warn_deprecated("3.10", message=(
|
| 1598 |
+
"Passing x and y separately to AxLine.set_xy2 is deprecated since "
|
| 1599 |
+
"%(since)s; pass them as a single tuple instead."))
|
| 1600 |
+
xy2 = params["x"], params["y"]
|
| 1601 |
+
else:
|
| 1602 |
+
xy2 = params["xy2"]
|
| 1603 |
+
self._xy2 = xy2
|
| 1604 |
+
else:
|
| 1605 |
+
raise ValueError("Cannot set an 'xy2' value while 'slope' is set;"
|
| 1606 |
+
" they differ but their functionalities overlap")
|
| 1607 |
+
|
| 1608 |
+
def set_slope(self, slope):
|
| 1609 |
+
"""
|
| 1610 |
+
Set the *slope* value of the line.
|
| 1611 |
+
|
| 1612 |
+
.. note::
|
| 1613 |
+
|
| 1614 |
+
You can only set *slope* if the line was created using the *slope*
|
| 1615 |
+
parameter. If the line was created using *xy2*, please use
|
| 1616 |
+
`~.AxLine.set_xy2`.
|
| 1617 |
+
|
| 1618 |
+
Parameters
|
| 1619 |
+
----------
|
| 1620 |
+
slope : float
|
| 1621 |
+
The slope of the line.
|
| 1622 |
+
"""
|
| 1623 |
+
if self._xy2 is None:
|
| 1624 |
+
self._slope = slope
|
| 1625 |
+
else:
|
| 1626 |
+
raise ValueError("Cannot set a 'slope' value while 'xy2' is set;"
|
| 1627 |
+
" they differ but their functionalities overlap")
|
| 1628 |
+
|
| 1629 |
+
|
| 1630 |
+
class VertexSelector:
|
| 1631 |
+
"""
|
| 1632 |
+
Manage the callbacks to maintain a list of selected vertices for `.Line2D`.
|
| 1633 |
+
Derived classes should override the `process_selected` method to do
|
| 1634 |
+
something with the picks.
|
| 1635 |
+
|
| 1636 |
+
Here is an example which highlights the selected verts with red circles::
|
| 1637 |
+
|
| 1638 |
+
import numpy as np
|
| 1639 |
+
import matplotlib.pyplot as plt
|
| 1640 |
+
import matplotlib.lines as lines
|
| 1641 |
+
|
| 1642 |
+
class HighlightSelected(lines.VertexSelector):
|
| 1643 |
+
def __init__(self, line, fmt='ro', **kwargs):
|
| 1644 |
+
super().__init__(line)
|
| 1645 |
+
self.markers, = self.axes.plot([], [], fmt, **kwargs)
|
| 1646 |
+
|
| 1647 |
+
def process_selected(self, ind, xs, ys):
|
| 1648 |
+
self.markers.set_data(xs, ys)
|
| 1649 |
+
self.canvas.draw()
|
| 1650 |
+
|
| 1651 |
+
fig, ax = plt.subplots()
|
| 1652 |
+
x, y = np.random.rand(2, 30)
|
| 1653 |
+
line, = ax.plot(x, y, 'bs-', picker=5)
|
| 1654 |
+
|
| 1655 |
+
selector = HighlightSelected(line)
|
| 1656 |
+
plt.show()
|
| 1657 |
+
"""
|
| 1658 |
+
|
| 1659 |
+
def __init__(self, line):
|
| 1660 |
+
"""
|
| 1661 |
+
Parameters
|
| 1662 |
+
----------
|
| 1663 |
+
line : `~matplotlib.lines.Line2D`
|
| 1664 |
+
The line must already have been added to an `~.axes.Axes` and must
|
| 1665 |
+
have its picker property set.
|
| 1666 |
+
"""
|
| 1667 |
+
if line.axes is None:
|
| 1668 |
+
raise RuntimeError('You must first add the line to the Axes')
|
| 1669 |
+
if line.get_picker() is None:
|
| 1670 |
+
raise RuntimeError('You must first set the picker property '
|
| 1671 |
+
'of the line')
|
| 1672 |
+
self.axes = line.axes
|
| 1673 |
+
self.line = line
|
| 1674 |
+
self.cid = self.canvas.callbacks._connect_picklable(
|
| 1675 |
+
'pick_event', self.onpick)
|
| 1676 |
+
self.ind = set()
|
| 1677 |
+
|
| 1678 |
+
canvas = property(lambda self: self.axes.get_figure(root=True).canvas)
|
| 1679 |
+
|
| 1680 |
+
def process_selected(self, ind, xs, ys):
|
| 1681 |
+
"""
|
| 1682 |
+
Default "do nothing" implementation of the `process_selected` method.
|
| 1683 |
+
|
| 1684 |
+
Parameters
|
| 1685 |
+
----------
|
| 1686 |
+
ind : list of int
|
| 1687 |
+
The indices of the selected vertices.
|
| 1688 |
+
xs, ys : array-like
|
| 1689 |
+
The coordinates of the selected vertices.
|
| 1690 |
+
"""
|
| 1691 |
+
pass
|
| 1692 |
+
|
| 1693 |
+
def onpick(self, event):
|
| 1694 |
+
"""When the line is picked, update the set of selected indices."""
|
| 1695 |
+
if event.artist is not self.line:
|
| 1696 |
+
return
|
| 1697 |
+
self.ind ^= set(event.ind)
|
| 1698 |
+
ind = sorted(self.ind)
|
| 1699 |
+
xdata, ydata = self.line.get_data()
|
| 1700 |
+
self.process_selected(ind, xdata[ind], ydata[ind])
|
| 1701 |
+
|
| 1702 |
+
|
| 1703 |
+
lineStyles = Line2D._lineStyles
|
| 1704 |
+
lineMarkers = MarkerStyle.markers
|
| 1705 |
+
drawStyles = Line2D.drawStyles
|
| 1706 |
+
fillStyles = MarkerStyle.fillstyles
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/markers.py
ADDED
|
@@ -0,0 +1,908 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
r"""
|
| 2 |
+
Functions to handle markers; used by the marker functionality of
|
| 3 |
+
`~matplotlib.axes.Axes.plot`, `~matplotlib.axes.Axes.scatter`, and
|
| 4 |
+
`~matplotlib.axes.Axes.errorbar`.
|
| 5 |
+
|
| 6 |
+
All possible markers are defined here:
|
| 7 |
+
|
| 8 |
+
============================== ====== =========================================
|
| 9 |
+
marker symbol description
|
| 10 |
+
============================== ====== =========================================
|
| 11 |
+
``"."`` |m00| point
|
| 12 |
+
``","`` |m01| pixel
|
| 13 |
+
``"o"`` |m02| circle
|
| 14 |
+
``"v"`` |m03| triangle_down
|
| 15 |
+
``"^"`` |m04| triangle_up
|
| 16 |
+
``"<"`` |m05| triangle_left
|
| 17 |
+
``">"`` |m06| triangle_right
|
| 18 |
+
``"1"`` |m07| tri_down
|
| 19 |
+
``"2"`` |m08| tri_up
|
| 20 |
+
``"3"`` |m09| tri_left
|
| 21 |
+
``"4"`` |m10| tri_right
|
| 22 |
+
``"8"`` |m11| octagon
|
| 23 |
+
``"s"`` |m12| square
|
| 24 |
+
``"p"`` |m13| pentagon
|
| 25 |
+
``"P"`` |m23| plus (filled)
|
| 26 |
+
``"*"`` |m14| star
|
| 27 |
+
``"h"`` |m15| hexagon1
|
| 28 |
+
``"H"`` |m16| hexagon2
|
| 29 |
+
``"+"`` |m17| plus
|
| 30 |
+
``"x"`` |m18| x
|
| 31 |
+
``"X"`` |m24| x (filled)
|
| 32 |
+
``"D"`` |m19| diamond
|
| 33 |
+
``"d"`` |m20| thin_diamond
|
| 34 |
+
``"|"`` |m21| vline
|
| 35 |
+
``"_"`` |m22| hline
|
| 36 |
+
``0`` (``TICKLEFT``) |m25| tickleft
|
| 37 |
+
``1`` (``TICKRIGHT``) |m26| tickright
|
| 38 |
+
``2`` (``TICKUP``) |m27| tickup
|
| 39 |
+
``3`` (``TICKDOWN``) |m28| tickdown
|
| 40 |
+
``4`` (``CARETLEFT``) |m29| caretleft
|
| 41 |
+
``5`` (``CARETRIGHT``) |m30| caretright
|
| 42 |
+
``6`` (``CARETUP``) |m31| caretup
|
| 43 |
+
``7`` (``CARETDOWN``) |m32| caretdown
|
| 44 |
+
``8`` (``CARETLEFTBASE``) |m33| caretleft (centered at base)
|
| 45 |
+
``9`` (``CARETRIGHTBASE``) |m34| caretright (centered at base)
|
| 46 |
+
``10`` (``CARETUPBASE``) |m35| caretup (centered at base)
|
| 47 |
+
``11`` (``CARETDOWNBASE``) |m36| caretdown (centered at base)
|
| 48 |
+
``"none"`` or ``"None"`` nothing
|
| 49 |
+
``" "`` or ``""`` nothing
|
| 50 |
+
``"$...$"`` |m37| Render the string using mathtext.
|
| 51 |
+
E.g ``"$f$"`` for marker showing the
|
| 52 |
+
letter ``f``.
|
| 53 |
+
``verts`` A list of (x, y) pairs used for Path
|
| 54 |
+
vertices. The center of the marker is
|
| 55 |
+
located at (0, 0) and the size is
|
| 56 |
+
normalized, such that the created path
|
| 57 |
+
is encapsulated inside the unit cell.
|
| 58 |
+
``path`` A `~matplotlib.path.Path` instance.
|
| 59 |
+
``(numsides, 0, angle)`` A regular polygon with ``numsides``
|
| 60 |
+
sides, rotated by ``angle``.
|
| 61 |
+
``(numsides, 1, angle)`` A star-like symbol with ``numsides``
|
| 62 |
+
sides, rotated by ``angle``.
|
| 63 |
+
``(numsides, 2, angle)`` An asterisk with ``numsides`` sides,
|
| 64 |
+
rotated by ``angle``.
|
| 65 |
+
============================== ====== =========================================
|
| 66 |
+
|
| 67 |
+
Note that special symbols can be defined via the
|
| 68 |
+
:ref:`STIX math font <mathtext>`,
|
| 69 |
+
e.g. ``"$\u266B$"``. For an overview over the STIX font symbols refer to the
|
| 70 |
+
`STIX font table <http://www.stixfonts.org/allGlyphs.html>`_.
|
| 71 |
+
Also see the :doc:`/gallery/text_labels_and_annotations/stix_fonts_demo`.
|
| 72 |
+
|
| 73 |
+
Integer numbers from ``0`` to ``11`` create lines and triangles. Those are
|
| 74 |
+
equally accessible via capitalized variables, like ``CARETDOWNBASE``.
|
| 75 |
+
Hence the following are equivalent::
|
| 76 |
+
|
| 77 |
+
plt.plot([1, 2, 3], marker=11)
|
| 78 |
+
plt.plot([1, 2, 3], marker=matplotlib.markers.CARETDOWNBASE)
|
| 79 |
+
|
| 80 |
+
Markers join and cap styles can be customized by creating a new instance of
|
| 81 |
+
MarkerStyle.
|
| 82 |
+
A MarkerStyle can also have a custom `~matplotlib.transforms.Transform`
|
| 83 |
+
allowing it to be arbitrarily rotated or offset.
|
| 84 |
+
|
| 85 |
+
Examples showing the use of markers:
|
| 86 |
+
|
| 87 |
+
* :doc:`/gallery/lines_bars_and_markers/marker_reference`
|
| 88 |
+
* :doc:`/gallery/lines_bars_and_markers/scatter_star_poly`
|
| 89 |
+
* :doc:`/gallery/lines_bars_and_markers/multivariate_marker_plot`
|
| 90 |
+
|
| 91 |
+
.. |m00| image:: /_static/markers/m00.png
|
| 92 |
+
.. |m01| image:: /_static/markers/m01.png
|
| 93 |
+
.. |m02| image:: /_static/markers/m02.png
|
| 94 |
+
.. |m03| image:: /_static/markers/m03.png
|
| 95 |
+
.. |m04| image:: /_static/markers/m04.png
|
| 96 |
+
.. |m05| image:: /_static/markers/m05.png
|
| 97 |
+
.. |m06| image:: /_static/markers/m06.png
|
| 98 |
+
.. |m07| image:: /_static/markers/m07.png
|
| 99 |
+
.. |m08| image:: /_static/markers/m08.png
|
| 100 |
+
.. |m09| image:: /_static/markers/m09.png
|
| 101 |
+
.. |m10| image:: /_static/markers/m10.png
|
| 102 |
+
.. |m11| image:: /_static/markers/m11.png
|
| 103 |
+
.. |m12| image:: /_static/markers/m12.png
|
| 104 |
+
.. |m13| image:: /_static/markers/m13.png
|
| 105 |
+
.. |m14| image:: /_static/markers/m14.png
|
| 106 |
+
.. |m15| image:: /_static/markers/m15.png
|
| 107 |
+
.. |m16| image:: /_static/markers/m16.png
|
| 108 |
+
.. |m17| image:: /_static/markers/m17.png
|
| 109 |
+
.. |m18| image:: /_static/markers/m18.png
|
| 110 |
+
.. |m19| image:: /_static/markers/m19.png
|
| 111 |
+
.. |m20| image:: /_static/markers/m20.png
|
| 112 |
+
.. |m21| image:: /_static/markers/m21.png
|
| 113 |
+
.. |m22| image:: /_static/markers/m22.png
|
| 114 |
+
.. |m23| image:: /_static/markers/m23.png
|
| 115 |
+
.. |m24| image:: /_static/markers/m24.png
|
| 116 |
+
.. |m25| image:: /_static/markers/m25.png
|
| 117 |
+
.. |m26| image:: /_static/markers/m26.png
|
| 118 |
+
.. |m27| image:: /_static/markers/m27.png
|
| 119 |
+
.. |m28| image:: /_static/markers/m28.png
|
| 120 |
+
.. |m29| image:: /_static/markers/m29.png
|
| 121 |
+
.. |m30| image:: /_static/markers/m30.png
|
| 122 |
+
.. |m31| image:: /_static/markers/m31.png
|
| 123 |
+
.. |m32| image:: /_static/markers/m32.png
|
| 124 |
+
.. |m33| image:: /_static/markers/m33.png
|
| 125 |
+
.. |m34| image:: /_static/markers/m34.png
|
| 126 |
+
.. |m35| image:: /_static/markers/m35.png
|
| 127 |
+
.. |m36| image:: /_static/markers/m36.png
|
| 128 |
+
.. |m37| image:: /_static/markers/m37.png
|
| 129 |
+
"""
|
| 130 |
+
import copy
|
| 131 |
+
|
| 132 |
+
from collections.abc import Sized
|
| 133 |
+
|
| 134 |
+
import numpy as np
|
| 135 |
+
|
| 136 |
+
import matplotlib as mpl
|
| 137 |
+
from . import _api, cbook
|
| 138 |
+
from .path import Path
|
| 139 |
+
from .transforms import IdentityTransform, Affine2D
|
| 140 |
+
from ._enums import JoinStyle, CapStyle
|
| 141 |
+
|
| 142 |
+
# special-purpose marker identifiers:
|
| 143 |
+
(TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN,
|
| 144 |
+
CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN,
|
| 145 |
+
CARETLEFTBASE, CARETRIGHTBASE, CARETUPBASE, CARETDOWNBASE) = range(12)
|
| 146 |
+
|
| 147 |
+
_empty_path = Path(np.empty((0, 2)))
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
class MarkerStyle:
|
| 151 |
+
"""
|
| 152 |
+
A class representing marker types.
|
| 153 |
+
|
| 154 |
+
Instances are immutable. If you need to change anything, create a new
|
| 155 |
+
instance.
|
| 156 |
+
|
| 157 |
+
Attributes
|
| 158 |
+
----------
|
| 159 |
+
markers : dict
|
| 160 |
+
All known markers.
|
| 161 |
+
filled_markers : tuple
|
| 162 |
+
All known filled markers. This is a subset of *markers*.
|
| 163 |
+
fillstyles : tuple
|
| 164 |
+
The supported fillstyles.
|
| 165 |
+
"""
|
| 166 |
+
|
| 167 |
+
markers = {
|
| 168 |
+
'.': 'point',
|
| 169 |
+
',': 'pixel',
|
| 170 |
+
'o': 'circle',
|
| 171 |
+
'v': 'triangle_down',
|
| 172 |
+
'^': 'triangle_up',
|
| 173 |
+
'<': 'triangle_left',
|
| 174 |
+
'>': 'triangle_right',
|
| 175 |
+
'1': 'tri_down',
|
| 176 |
+
'2': 'tri_up',
|
| 177 |
+
'3': 'tri_left',
|
| 178 |
+
'4': 'tri_right',
|
| 179 |
+
'8': 'octagon',
|
| 180 |
+
's': 'square',
|
| 181 |
+
'p': 'pentagon',
|
| 182 |
+
'*': 'star',
|
| 183 |
+
'h': 'hexagon1',
|
| 184 |
+
'H': 'hexagon2',
|
| 185 |
+
'+': 'plus',
|
| 186 |
+
'x': 'x',
|
| 187 |
+
'D': 'diamond',
|
| 188 |
+
'd': 'thin_diamond',
|
| 189 |
+
'|': 'vline',
|
| 190 |
+
'_': 'hline',
|
| 191 |
+
'P': 'plus_filled',
|
| 192 |
+
'X': 'x_filled',
|
| 193 |
+
TICKLEFT: 'tickleft',
|
| 194 |
+
TICKRIGHT: 'tickright',
|
| 195 |
+
TICKUP: 'tickup',
|
| 196 |
+
TICKDOWN: 'tickdown',
|
| 197 |
+
CARETLEFT: 'caretleft',
|
| 198 |
+
CARETRIGHT: 'caretright',
|
| 199 |
+
CARETUP: 'caretup',
|
| 200 |
+
CARETDOWN: 'caretdown',
|
| 201 |
+
CARETLEFTBASE: 'caretleftbase',
|
| 202 |
+
CARETRIGHTBASE: 'caretrightbase',
|
| 203 |
+
CARETUPBASE: 'caretupbase',
|
| 204 |
+
CARETDOWNBASE: 'caretdownbase',
|
| 205 |
+
"None": 'nothing',
|
| 206 |
+
"none": 'nothing',
|
| 207 |
+
' ': 'nothing',
|
| 208 |
+
'': 'nothing'
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
# Just used for informational purposes. is_filled()
|
| 212 |
+
# is calculated in the _set_* functions.
|
| 213 |
+
filled_markers = (
|
| 214 |
+
'.', 'o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd',
|
| 215 |
+
'P', 'X')
|
| 216 |
+
|
| 217 |
+
fillstyles = ('full', 'left', 'right', 'bottom', 'top', 'none')
|
| 218 |
+
_half_fillstyles = ('left', 'right', 'bottom', 'top')
|
| 219 |
+
|
| 220 |
+
def __init__(self, marker,
|
| 221 |
+
fillstyle=None, transform=None, capstyle=None, joinstyle=None):
|
| 222 |
+
"""
|
| 223 |
+
Parameters
|
| 224 |
+
----------
|
| 225 |
+
marker : str, array-like, Path, MarkerStyle
|
| 226 |
+
- Another instance of `MarkerStyle` copies the details of that *marker*.
|
| 227 |
+
- For other possible marker values, see the module docstring
|
| 228 |
+
`matplotlib.markers`.
|
| 229 |
+
|
| 230 |
+
fillstyle : str, default: :rc:`markers.fillstyle`
|
| 231 |
+
One of 'full', 'left', 'right', 'bottom', 'top', 'none'.
|
| 232 |
+
|
| 233 |
+
transform : `~matplotlib.transforms.Transform`, optional
|
| 234 |
+
Transform that will be combined with the native transform of the
|
| 235 |
+
marker.
|
| 236 |
+
|
| 237 |
+
capstyle : `.CapStyle` or %(CapStyle)s, optional
|
| 238 |
+
Cap style that will override the default cap style of the marker.
|
| 239 |
+
|
| 240 |
+
joinstyle : `.JoinStyle` or %(JoinStyle)s, optional
|
| 241 |
+
Join style that will override the default join style of the marker.
|
| 242 |
+
"""
|
| 243 |
+
self._marker_function = None
|
| 244 |
+
self._user_transform = transform
|
| 245 |
+
self._user_capstyle = CapStyle(capstyle) if capstyle is not None else None
|
| 246 |
+
self._user_joinstyle = JoinStyle(joinstyle) if joinstyle is not None else None
|
| 247 |
+
self._set_fillstyle(fillstyle)
|
| 248 |
+
self._set_marker(marker)
|
| 249 |
+
|
| 250 |
+
def _recache(self):
|
| 251 |
+
if self._marker_function is None:
|
| 252 |
+
return
|
| 253 |
+
self._path = _empty_path
|
| 254 |
+
self._transform = IdentityTransform()
|
| 255 |
+
self._alt_path = None
|
| 256 |
+
self._alt_transform = None
|
| 257 |
+
self._snap_threshold = None
|
| 258 |
+
self._joinstyle = JoinStyle.round
|
| 259 |
+
self._capstyle = self._user_capstyle or CapStyle.butt
|
| 260 |
+
# Initial guess: Assume the marker is filled unless the fillstyle is
|
| 261 |
+
# set to 'none'. The marker function will override this for unfilled
|
| 262 |
+
# markers.
|
| 263 |
+
self._filled = self._fillstyle != 'none'
|
| 264 |
+
self._marker_function()
|
| 265 |
+
|
| 266 |
+
def __bool__(self):
|
| 267 |
+
return bool(len(self._path.vertices))
|
| 268 |
+
|
| 269 |
+
def is_filled(self):
|
| 270 |
+
return self._filled
|
| 271 |
+
|
| 272 |
+
def get_fillstyle(self):
|
| 273 |
+
return self._fillstyle
|
| 274 |
+
|
| 275 |
+
def _set_fillstyle(self, fillstyle):
|
| 276 |
+
"""
|
| 277 |
+
Set the fillstyle.
|
| 278 |
+
|
| 279 |
+
Parameters
|
| 280 |
+
----------
|
| 281 |
+
fillstyle : {'full', 'left', 'right', 'bottom', 'top', 'none'}
|
| 282 |
+
The part of the marker surface that is colored with
|
| 283 |
+
markerfacecolor.
|
| 284 |
+
"""
|
| 285 |
+
if fillstyle is None:
|
| 286 |
+
fillstyle = mpl.rcParams['markers.fillstyle']
|
| 287 |
+
_api.check_in_list(self.fillstyles, fillstyle=fillstyle)
|
| 288 |
+
self._fillstyle = fillstyle
|
| 289 |
+
|
| 290 |
+
def get_joinstyle(self):
|
| 291 |
+
return self._joinstyle.name
|
| 292 |
+
|
| 293 |
+
def get_capstyle(self):
|
| 294 |
+
return self._capstyle.name
|
| 295 |
+
|
| 296 |
+
def get_marker(self):
|
| 297 |
+
return self._marker
|
| 298 |
+
|
| 299 |
+
def _set_marker(self, marker):
|
| 300 |
+
"""
|
| 301 |
+
Set the marker.
|
| 302 |
+
|
| 303 |
+
Parameters
|
| 304 |
+
----------
|
| 305 |
+
marker : str, array-like, Path, MarkerStyle
|
| 306 |
+
- Another instance of `MarkerStyle` copies the details of that *marker*.
|
| 307 |
+
- For other possible marker values see the module docstring
|
| 308 |
+
`matplotlib.markers`.
|
| 309 |
+
"""
|
| 310 |
+
if isinstance(marker, str) and cbook.is_math_text(marker):
|
| 311 |
+
self._marker_function = self._set_mathtext_path
|
| 312 |
+
elif isinstance(marker, (int, str)) and marker in self.markers:
|
| 313 |
+
self._marker_function = getattr(self, '_set_' + self.markers[marker])
|
| 314 |
+
elif (isinstance(marker, np.ndarray) and marker.ndim == 2 and
|
| 315 |
+
marker.shape[1] == 2):
|
| 316 |
+
self._marker_function = self._set_vertices
|
| 317 |
+
elif isinstance(marker, Path):
|
| 318 |
+
self._marker_function = self._set_path_marker
|
| 319 |
+
elif (isinstance(marker, Sized) and len(marker) in (2, 3) and
|
| 320 |
+
marker[1] in (0, 1, 2)):
|
| 321 |
+
self._marker_function = self._set_tuple_marker
|
| 322 |
+
elif isinstance(marker, MarkerStyle):
|
| 323 |
+
self.__dict__ = copy.deepcopy(marker.__dict__)
|
| 324 |
+
else:
|
| 325 |
+
try:
|
| 326 |
+
Path(marker)
|
| 327 |
+
self._marker_function = self._set_vertices
|
| 328 |
+
except ValueError as err:
|
| 329 |
+
raise ValueError(
|
| 330 |
+
f'Unrecognized marker style {marker!r}') from err
|
| 331 |
+
|
| 332 |
+
if not isinstance(marker, MarkerStyle):
|
| 333 |
+
self._marker = marker
|
| 334 |
+
self._recache()
|
| 335 |
+
|
| 336 |
+
def get_path(self):
|
| 337 |
+
"""
|
| 338 |
+
Return a `.Path` for the primary part of the marker.
|
| 339 |
+
|
| 340 |
+
For unfilled markers this is the whole marker, for filled markers,
|
| 341 |
+
this is the area to be drawn with *markerfacecolor*.
|
| 342 |
+
"""
|
| 343 |
+
return self._path
|
| 344 |
+
|
| 345 |
+
def get_transform(self):
|
| 346 |
+
"""
|
| 347 |
+
Return the transform to be applied to the `.Path` from
|
| 348 |
+
`MarkerStyle.get_path()`.
|
| 349 |
+
"""
|
| 350 |
+
if self._user_transform is None:
|
| 351 |
+
return self._transform.frozen()
|
| 352 |
+
else:
|
| 353 |
+
return (self._transform + self._user_transform).frozen()
|
| 354 |
+
|
| 355 |
+
def get_alt_path(self):
|
| 356 |
+
"""
|
| 357 |
+
Return a `.Path` for the alternate part of the marker.
|
| 358 |
+
|
| 359 |
+
For unfilled markers, this is *None*; for filled markers, this is the
|
| 360 |
+
area to be drawn with *markerfacecoloralt*.
|
| 361 |
+
"""
|
| 362 |
+
return self._alt_path
|
| 363 |
+
|
| 364 |
+
def get_alt_transform(self):
|
| 365 |
+
"""
|
| 366 |
+
Return the transform to be applied to the `.Path` from
|
| 367 |
+
`MarkerStyle.get_alt_path()`.
|
| 368 |
+
"""
|
| 369 |
+
if self._user_transform is None:
|
| 370 |
+
return self._alt_transform.frozen()
|
| 371 |
+
else:
|
| 372 |
+
return (self._alt_transform + self._user_transform).frozen()
|
| 373 |
+
|
| 374 |
+
def get_snap_threshold(self):
|
| 375 |
+
return self._snap_threshold
|
| 376 |
+
|
| 377 |
+
def get_user_transform(self):
|
| 378 |
+
"""Return user supplied part of marker transform."""
|
| 379 |
+
if self._user_transform is not None:
|
| 380 |
+
return self._user_transform.frozen()
|
| 381 |
+
|
| 382 |
+
def transformed(self, transform):
|
| 383 |
+
"""
|
| 384 |
+
Return a new version of this marker with the transform applied.
|
| 385 |
+
|
| 386 |
+
Parameters
|
| 387 |
+
----------
|
| 388 |
+
transform : `~matplotlib.transforms.Affine2D`
|
| 389 |
+
Transform will be combined with current user supplied transform.
|
| 390 |
+
"""
|
| 391 |
+
new_marker = MarkerStyle(self)
|
| 392 |
+
if new_marker._user_transform is not None:
|
| 393 |
+
new_marker._user_transform += transform
|
| 394 |
+
else:
|
| 395 |
+
new_marker._user_transform = transform
|
| 396 |
+
return new_marker
|
| 397 |
+
|
| 398 |
+
def rotated(self, *, deg=None, rad=None):
|
| 399 |
+
"""
|
| 400 |
+
Return a new version of this marker rotated by specified angle.
|
| 401 |
+
|
| 402 |
+
Parameters
|
| 403 |
+
----------
|
| 404 |
+
deg : float, optional
|
| 405 |
+
Rotation angle in degrees.
|
| 406 |
+
|
| 407 |
+
rad : float, optional
|
| 408 |
+
Rotation angle in radians.
|
| 409 |
+
|
| 410 |
+
.. note:: You must specify exactly one of deg or rad.
|
| 411 |
+
"""
|
| 412 |
+
if deg is None and rad is None:
|
| 413 |
+
raise ValueError('One of deg or rad is required')
|
| 414 |
+
if deg is not None and rad is not None:
|
| 415 |
+
raise ValueError('Only one of deg and rad can be supplied')
|
| 416 |
+
new_marker = MarkerStyle(self)
|
| 417 |
+
if new_marker._user_transform is None:
|
| 418 |
+
new_marker._user_transform = Affine2D()
|
| 419 |
+
|
| 420 |
+
if deg is not None:
|
| 421 |
+
new_marker._user_transform.rotate_deg(deg)
|
| 422 |
+
if rad is not None:
|
| 423 |
+
new_marker._user_transform.rotate(rad)
|
| 424 |
+
|
| 425 |
+
return new_marker
|
| 426 |
+
|
| 427 |
+
def scaled(self, sx, sy=None):
|
| 428 |
+
"""
|
| 429 |
+
Return new marker scaled by specified scale factors.
|
| 430 |
+
|
| 431 |
+
If *sy* is not given, the same scale is applied in both the *x*- and
|
| 432 |
+
*y*-directions.
|
| 433 |
+
|
| 434 |
+
Parameters
|
| 435 |
+
----------
|
| 436 |
+
sx : float
|
| 437 |
+
*X*-direction scaling factor.
|
| 438 |
+
sy : float, optional
|
| 439 |
+
*Y*-direction scaling factor.
|
| 440 |
+
"""
|
| 441 |
+
if sy is None:
|
| 442 |
+
sy = sx
|
| 443 |
+
|
| 444 |
+
new_marker = MarkerStyle(self)
|
| 445 |
+
_transform = new_marker._user_transform or Affine2D()
|
| 446 |
+
new_marker._user_transform = _transform.scale(sx, sy)
|
| 447 |
+
return new_marker
|
| 448 |
+
|
| 449 |
+
def _set_nothing(self):
|
| 450 |
+
self._filled = False
|
| 451 |
+
|
| 452 |
+
def _set_custom_marker(self, path):
|
| 453 |
+
rescale = np.max(np.abs(path.vertices)) # max of x's and y's.
|
| 454 |
+
self._transform = Affine2D().scale(0.5 / rescale)
|
| 455 |
+
self._path = path
|
| 456 |
+
|
| 457 |
+
def _set_path_marker(self):
|
| 458 |
+
self._set_custom_marker(self._marker)
|
| 459 |
+
|
| 460 |
+
def _set_vertices(self):
|
| 461 |
+
self._set_custom_marker(Path(self._marker))
|
| 462 |
+
|
| 463 |
+
def _set_tuple_marker(self):
|
| 464 |
+
marker = self._marker
|
| 465 |
+
if len(marker) == 2:
|
| 466 |
+
numsides, rotation = marker[0], 0.0
|
| 467 |
+
elif len(marker) == 3:
|
| 468 |
+
numsides, rotation = marker[0], marker[2]
|
| 469 |
+
symstyle = marker[1]
|
| 470 |
+
if symstyle == 0:
|
| 471 |
+
self._path = Path.unit_regular_polygon(numsides)
|
| 472 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 473 |
+
elif symstyle == 1:
|
| 474 |
+
self._path = Path.unit_regular_star(numsides)
|
| 475 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.bevel
|
| 476 |
+
elif symstyle == 2:
|
| 477 |
+
self._path = Path.unit_regular_asterisk(numsides)
|
| 478 |
+
self._filled = False
|
| 479 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.bevel
|
| 480 |
+
else:
|
| 481 |
+
raise ValueError(f"Unexpected tuple marker: {marker}")
|
| 482 |
+
self._transform = Affine2D().scale(0.5).rotate_deg(rotation)
|
| 483 |
+
|
| 484 |
+
def _set_mathtext_path(self):
|
| 485 |
+
"""
|
| 486 |
+
Draw mathtext markers '$...$' using `.TextPath` object.
|
| 487 |
+
|
| 488 |
+
Submitted by tcb
|
| 489 |
+
"""
|
| 490 |
+
from matplotlib.text import TextPath
|
| 491 |
+
|
| 492 |
+
# again, the properties could be initialised just once outside
|
| 493 |
+
# this function
|
| 494 |
+
text = TextPath(xy=(0, 0), s=self.get_marker(),
|
| 495 |
+
usetex=mpl.rcParams['text.usetex'])
|
| 496 |
+
if len(text.vertices) == 0:
|
| 497 |
+
return
|
| 498 |
+
|
| 499 |
+
bbox = text.get_extents()
|
| 500 |
+
max_dim = max(bbox.width, bbox.height)
|
| 501 |
+
self._transform = (
|
| 502 |
+
Affine2D()
|
| 503 |
+
.translate(-bbox.xmin + 0.5 * -bbox.width, -bbox.ymin + 0.5 * -bbox.height)
|
| 504 |
+
.scale(1.0 / max_dim))
|
| 505 |
+
self._path = text
|
| 506 |
+
self._snap = False
|
| 507 |
+
|
| 508 |
+
def _half_fill(self):
|
| 509 |
+
return self.get_fillstyle() in self._half_fillstyles
|
| 510 |
+
|
| 511 |
+
def _set_circle(self, size=1.0):
|
| 512 |
+
self._transform = Affine2D().scale(0.5 * size)
|
| 513 |
+
self._snap_threshold = np.inf
|
| 514 |
+
if not self._half_fill():
|
| 515 |
+
self._path = Path.unit_circle()
|
| 516 |
+
else:
|
| 517 |
+
self._path = self._alt_path = Path.unit_circle_righthalf()
|
| 518 |
+
fs = self.get_fillstyle()
|
| 519 |
+
self._transform.rotate_deg(
|
| 520 |
+
{'right': 0, 'top': 90, 'left': 180, 'bottom': 270}[fs])
|
| 521 |
+
self._alt_transform = self._transform.frozen().rotate_deg(180.)
|
| 522 |
+
|
| 523 |
+
def _set_point(self):
|
| 524 |
+
self._set_circle(size=0.5)
|
| 525 |
+
|
| 526 |
+
def _set_pixel(self):
|
| 527 |
+
self._path = Path.unit_rectangle()
|
| 528 |
+
# Ideally, you'd want -0.5, -0.5 here, but then the snapping
|
| 529 |
+
# algorithm in the Agg backend will round this to a 2x2
|
| 530 |
+
# rectangle from (-1, -1) to (1, 1). By offsetting it
|
| 531 |
+
# slightly, we can force it to be (0, 0) to (1, 1), which both
|
| 532 |
+
# makes it only be a single pixel and places it correctly
|
| 533 |
+
# aligned to 1-width stroking (i.e. the ticks). This hack is
|
| 534 |
+
# the best of a number of bad alternatives, mainly because the
|
| 535 |
+
# backends are not aware of what marker is actually being used
|
| 536 |
+
# beyond just its path data.
|
| 537 |
+
self._transform = Affine2D().translate(-0.49999, -0.49999)
|
| 538 |
+
self._snap_threshold = None
|
| 539 |
+
|
| 540 |
+
_triangle_path = Path._create_closed([[0, 1], [-1, -1], [1, -1]])
|
| 541 |
+
# Going down halfway looks to small. Golden ratio is too far.
|
| 542 |
+
_triangle_path_u = Path._create_closed([[0, 1], [-3/5, -1/5], [3/5, -1/5]])
|
| 543 |
+
_triangle_path_d = Path._create_closed(
|
| 544 |
+
[[-3/5, -1/5], [3/5, -1/5], [1, -1], [-1, -1]])
|
| 545 |
+
_triangle_path_l = Path._create_closed([[0, 1], [0, -1], [-1, -1]])
|
| 546 |
+
_triangle_path_r = Path._create_closed([[0, 1], [0, -1], [1, -1]])
|
| 547 |
+
|
| 548 |
+
def _set_triangle(self, rot, skip):
|
| 549 |
+
self._transform = Affine2D().scale(0.5).rotate_deg(rot)
|
| 550 |
+
self._snap_threshold = 5.0
|
| 551 |
+
|
| 552 |
+
if not self._half_fill():
|
| 553 |
+
self._path = self._triangle_path
|
| 554 |
+
else:
|
| 555 |
+
mpaths = [self._triangle_path_u,
|
| 556 |
+
self._triangle_path_l,
|
| 557 |
+
self._triangle_path_d,
|
| 558 |
+
self._triangle_path_r]
|
| 559 |
+
|
| 560 |
+
fs = self.get_fillstyle()
|
| 561 |
+
if fs == 'top':
|
| 562 |
+
self._path = mpaths[(0 + skip) % 4]
|
| 563 |
+
self._alt_path = mpaths[(2 + skip) % 4]
|
| 564 |
+
elif fs == 'bottom':
|
| 565 |
+
self._path = mpaths[(2 + skip) % 4]
|
| 566 |
+
self._alt_path = mpaths[(0 + skip) % 4]
|
| 567 |
+
elif fs == 'left':
|
| 568 |
+
self._path = mpaths[(1 + skip) % 4]
|
| 569 |
+
self._alt_path = mpaths[(3 + skip) % 4]
|
| 570 |
+
else:
|
| 571 |
+
self._path = mpaths[(3 + skip) % 4]
|
| 572 |
+
self._alt_path = mpaths[(1 + skip) % 4]
|
| 573 |
+
|
| 574 |
+
self._alt_transform = self._transform
|
| 575 |
+
|
| 576 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 577 |
+
|
| 578 |
+
def _set_triangle_up(self):
|
| 579 |
+
return self._set_triangle(0.0, 0)
|
| 580 |
+
|
| 581 |
+
def _set_triangle_down(self):
|
| 582 |
+
return self._set_triangle(180.0, 2)
|
| 583 |
+
|
| 584 |
+
def _set_triangle_left(self):
|
| 585 |
+
return self._set_triangle(90.0, 3)
|
| 586 |
+
|
| 587 |
+
def _set_triangle_right(self):
|
| 588 |
+
return self._set_triangle(270.0, 1)
|
| 589 |
+
|
| 590 |
+
def _set_square(self):
|
| 591 |
+
self._transform = Affine2D().translate(-0.5, -0.5)
|
| 592 |
+
self._snap_threshold = 2.0
|
| 593 |
+
if not self._half_fill():
|
| 594 |
+
self._path = Path.unit_rectangle()
|
| 595 |
+
else:
|
| 596 |
+
# Build a bottom filled square out of two rectangles, one filled.
|
| 597 |
+
self._path = Path([[0.0, 0.0], [1.0, 0.0], [1.0, 0.5],
|
| 598 |
+
[0.0, 0.5], [0.0, 0.0]])
|
| 599 |
+
self._alt_path = Path([[0.0, 0.5], [1.0, 0.5], [1.0, 1.0],
|
| 600 |
+
[0.0, 1.0], [0.0, 0.5]])
|
| 601 |
+
fs = self.get_fillstyle()
|
| 602 |
+
rotate = {'bottom': 0, 'right': 90, 'top': 180, 'left': 270}[fs]
|
| 603 |
+
self._transform.rotate_deg(rotate)
|
| 604 |
+
self._alt_transform = self._transform
|
| 605 |
+
|
| 606 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 607 |
+
|
| 608 |
+
def _set_diamond(self):
|
| 609 |
+
self._transform = Affine2D().translate(-0.5, -0.5).rotate_deg(45)
|
| 610 |
+
self._snap_threshold = 5.0
|
| 611 |
+
if not self._half_fill():
|
| 612 |
+
self._path = Path.unit_rectangle()
|
| 613 |
+
else:
|
| 614 |
+
self._path = Path([[0, 0], [1, 0], [1, 1], [0, 0]])
|
| 615 |
+
self._alt_path = Path([[0, 0], [0, 1], [1, 1], [0, 0]])
|
| 616 |
+
fs = self.get_fillstyle()
|
| 617 |
+
rotate = {'right': 0, 'top': 90, 'left': 180, 'bottom': 270}[fs]
|
| 618 |
+
self._transform.rotate_deg(rotate)
|
| 619 |
+
self._alt_transform = self._transform
|
| 620 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 621 |
+
|
| 622 |
+
def _set_thin_diamond(self):
|
| 623 |
+
self._set_diamond()
|
| 624 |
+
self._transform.scale(0.6, 1.0)
|
| 625 |
+
|
| 626 |
+
def _set_pentagon(self):
|
| 627 |
+
self._transform = Affine2D().scale(0.5)
|
| 628 |
+
self._snap_threshold = 5.0
|
| 629 |
+
|
| 630 |
+
polypath = Path.unit_regular_polygon(5)
|
| 631 |
+
|
| 632 |
+
if not self._half_fill():
|
| 633 |
+
self._path = polypath
|
| 634 |
+
else:
|
| 635 |
+
verts = polypath.vertices
|
| 636 |
+
y = (1 + np.sqrt(5)) / 4.
|
| 637 |
+
top = Path(verts[[0, 1, 4, 0]])
|
| 638 |
+
bottom = Path(verts[[1, 2, 3, 4, 1]])
|
| 639 |
+
left = Path([verts[0], verts[1], verts[2], [0, -y], verts[0]])
|
| 640 |
+
right = Path([verts[0], verts[4], verts[3], [0, -y], verts[0]])
|
| 641 |
+
self._path, self._alt_path = {
|
| 642 |
+
'top': (top, bottom), 'bottom': (bottom, top),
|
| 643 |
+
'left': (left, right), 'right': (right, left),
|
| 644 |
+
}[self.get_fillstyle()]
|
| 645 |
+
self._alt_transform = self._transform
|
| 646 |
+
|
| 647 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 648 |
+
|
| 649 |
+
def _set_star(self):
|
| 650 |
+
self._transform = Affine2D().scale(0.5)
|
| 651 |
+
self._snap_threshold = 5.0
|
| 652 |
+
|
| 653 |
+
polypath = Path.unit_regular_star(5, innerCircle=0.381966)
|
| 654 |
+
|
| 655 |
+
if not self._half_fill():
|
| 656 |
+
self._path = polypath
|
| 657 |
+
else:
|
| 658 |
+
verts = polypath.vertices
|
| 659 |
+
top = Path(np.concatenate([verts[0:4], verts[7:10], verts[0:1]]))
|
| 660 |
+
bottom = Path(np.concatenate([verts[3:8], verts[3:4]]))
|
| 661 |
+
left = Path(np.concatenate([verts[0:6], verts[0:1]]))
|
| 662 |
+
right = Path(np.concatenate([verts[0:1], verts[5:10], verts[0:1]]))
|
| 663 |
+
self._path, self._alt_path = {
|
| 664 |
+
'top': (top, bottom), 'bottom': (bottom, top),
|
| 665 |
+
'left': (left, right), 'right': (right, left),
|
| 666 |
+
}[self.get_fillstyle()]
|
| 667 |
+
self._alt_transform = self._transform
|
| 668 |
+
|
| 669 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.bevel
|
| 670 |
+
|
| 671 |
+
def _set_hexagon1(self):
|
| 672 |
+
self._transform = Affine2D().scale(0.5)
|
| 673 |
+
self._snap_threshold = None
|
| 674 |
+
|
| 675 |
+
polypath = Path.unit_regular_polygon(6)
|
| 676 |
+
|
| 677 |
+
if not self._half_fill():
|
| 678 |
+
self._path = polypath
|
| 679 |
+
else:
|
| 680 |
+
verts = polypath.vertices
|
| 681 |
+
# not drawing inside lines
|
| 682 |
+
x = np.abs(np.cos(5 * np.pi / 6.))
|
| 683 |
+
top = Path(np.concatenate([[(-x, 0)], verts[[1, 0, 5]], [(x, 0)]]))
|
| 684 |
+
bottom = Path(np.concatenate([[(-x, 0)], verts[2:5], [(x, 0)]]))
|
| 685 |
+
left = Path(verts[0:4])
|
| 686 |
+
right = Path(verts[[0, 5, 4, 3]])
|
| 687 |
+
self._path, self._alt_path = {
|
| 688 |
+
'top': (top, bottom), 'bottom': (bottom, top),
|
| 689 |
+
'left': (left, right), 'right': (right, left),
|
| 690 |
+
}[self.get_fillstyle()]
|
| 691 |
+
self._alt_transform = self._transform
|
| 692 |
+
|
| 693 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 694 |
+
|
| 695 |
+
def _set_hexagon2(self):
|
| 696 |
+
self._transform = Affine2D().scale(0.5).rotate_deg(30)
|
| 697 |
+
self._snap_threshold = None
|
| 698 |
+
|
| 699 |
+
polypath = Path.unit_regular_polygon(6)
|
| 700 |
+
|
| 701 |
+
if not self._half_fill():
|
| 702 |
+
self._path = polypath
|
| 703 |
+
else:
|
| 704 |
+
verts = polypath.vertices
|
| 705 |
+
# not drawing inside lines
|
| 706 |
+
x, y = np.sqrt(3) / 4, 3 / 4.
|
| 707 |
+
top = Path(verts[[1, 0, 5, 4, 1]])
|
| 708 |
+
bottom = Path(verts[1:5])
|
| 709 |
+
left = Path(np.concatenate([
|
| 710 |
+
[(x, y)], verts[:3], [(-x, -y), (x, y)]]))
|
| 711 |
+
right = Path(np.concatenate([
|
| 712 |
+
[(x, y)], verts[5:2:-1], [(-x, -y)]]))
|
| 713 |
+
self._path, self._alt_path = {
|
| 714 |
+
'top': (top, bottom), 'bottom': (bottom, top),
|
| 715 |
+
'left': (left, right), 'right': (right, left),
|
| 716 |
+
}[self.get_fillstyle()]
|
| 717 |
+
self._alt_transform = self._transform
|
| 718 |
+
|
| 719 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 720 |
+
|
| 721 |
+
def _set_octagon(self):
|
| 722 |
+
self._transform = Affine2D().scale(0.5)
|
| 723 |
+
self._snap_threshold = 5.0
|
| 724 |
+
|
| 725 |
+
polypath = Path.unit_regular_polygon(8)
|
| 726 |
+
|
| 727 |
+
if not self._half_fill():
|
| 728 |
+
self._transform.rotate_deg(22.5)
|
| 729 |
+
self._path = polypath
|
| 730 |
+
else:
|
| 731 |
+
x = np.sqrt(2.) / 4.
|
| 732 |
+
self._path = self._alt_path = Path(
|
| 733 |
+
[[0, -1], [0, 1], [-x, 1], [-1, x],
|
| 734 |
+
[-1, -x], [-x, -1], [0, -1]])
|
| 735 |
+
fs = self.get_fillstyle()
|
| 736 |
+
self._transform.rotate_deg(
|
| 737 |
+
{'left': 0, 'bottom': 90, 'right': 180, 'top': 270}[fs])
|
| 738 |
+
self._alt_transform = self._transform.frozen().rotate_deg(180.0)
|
| 739 |
+
|
| 740 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 741 |
+
|
| 742 |
+
_line_marker_path = Path([[0.0, -1.0], [0.0, 1.0]])
|
| 743 |
+
|
| 744 |
+
def _set_vline(self):
|
| 745 |
+
self._transform = Affine2D().scale(0.5)
|
| 746 |
+
self._snap_threshold = 1.0
|
| 747 |
+
self._filled = False
|
| 748 |
+
self._path = self._line_marker_path
|
| 749 |
+
|
| 750 |
+
def _set_hline(self):
|
| 751 |
+
self._set_vline()
|
| 752 |
+
self._transform = self._transform.rotate_deg(90)
|
| 753 |
+
|
| 754 |
+
_tickhoriz_path = Path([[0.0, 0.0], [1.0, 0.0]])
|
| 755 |
+
|
| 756 |
+
def _set_tickleft(self):
|
| 757 |
+
self._transform = Affine2D().scale(-1.0, 1.0)
|
| 758 |
+
self._snap_threshold = 1.0
|
| 759 |
+
self._filled = False
|
| 760 |
+
self._path = self._tickhoriz_path
|
| 761 |
+
|
| 762 |
+
def _set_tickright(self):
|
| 763 |
+
self._transform = Affine2D().scale(1.0, 1.0)
|
| 764 |
+
self._snap_threshold = 1.0
|
| 765 |
+
self._filled = False
|
| 766 |
+
self._path = self._tickhoriz_path
|
| 767 |
+
|
| 768 |
+
_tickvert_path = Path([[-0.0, 0.0], [-0.0, 1.0]])
|
| 769 |
+
|
| 770 |
+
def _set_tickup(self):
|
| 771 |
+
self._transform = Affine2D().scale(1.0, 1.0)
|
| 772 |
+
self._snap_threshold = 1.0
|
| 773 |
+
self._filled = False
|
| 774 |
+
self._path = self._tickvert_path
|
| 775 |
+
|
| 776 |
+
def _set_tickdown(self):
|
| 777 |
+
self._transform = Affine2D().scale(1.0, -1.0)
|
| 778 |
+
self._snap_threshold = 1.0
|
| 779 |
+
self._filled = False
|
| 780 |
+
self._path = self._tickvert_path
|
| 781 |
+
|
| 782 |
+
_tri_path = Path([[0.0, 0.0], [0.0, -1.0],
|
| 783 |
+
[0.0, 0.0], [0.8, 0.5],
|
| 784 |
+
[0.0, 0.0], [-0.8, 0.5]],
|
| 785 |
+
[Path.MOVETO, Path.LINETO,
|
| 786 |
+
Path.MOVETO, Path.LINETO,
|
| 787 |
+
Path.MOVETO, Path.LINETO])
|
| 788 |
+
|
| 789 |
+
def _set_tri_down(self):
|
| 790 |
+
self._transform = Affine2D().scale(0.5)
|
| 791 |
+
self._snap_threshold = 5.0
|
| 792 |
+
self._filled = False
|
| 793 |
+
self._path = self._tri_path
|
| 794 |
+
|
| 795 |
+
def _set_tri_up(self):
|
| 796 |
+
self._set_tri_down()
|
| 797 |
+
self._transform = self._transform.rotate_deg(180)
|
| 798 |
+
|
| 799 |
+
def _set_tri_left(self):
|
| 800 |
+
self._set_tri_down()
|
| 801 |
+
self._transform = self._transform.rotate_deg(270)
|
| 802 |
+
|
| 803 |
+
def _set_tri_right(self):
|
| 804 |
+
self._set_tri_down()
|
| 805 |
+
self._transform = self._transform.rotate_deg(90)
|
| 806 |
+
|
| 807 |
+
_caret_path = Path([[-1.0, 1.5], [0.0, 0.0], [1.0, 1.5]])
|
| 808 |
+
|
| 809 |
+
def _set_caretdown(self):
|
| 810 |
+
self._transform = Affine2D().scale(0.5)
|
| 811 |
+
self._snap_threshold = 3.0
|
| 812 |
+
self._filled = False
|
| 813 |
+
self._path = self._caret_path
|
| 814 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 815 |
+
|
| 816 |
+
def _set_caretup(self):
|
| 817 |
+
self._set_caretdown()
|
| 818 |
+
self._transform = self._transform.rotate_deg(180)
|
| 819 |
+
|
| 820 |
+
def _set_caretleft(self):
|
| 821 |
+
self._set_caretdown()
|
| 822 |
+
self._transform = self._transform.rotate_deg(270)
|
| 823 |
+
|
| 824 |
+
def _set_caretright(self):
|
| 825 |
+
self._set_caretdown()
|
| 826 |
+
self._transform = self._transform.rotate_deg(90)
|
| 827 |
+
|
| 828 |
+
_caret_path_base = Path([[-1.0, 0.0], [0.0, -1.5], [1.0, 0]])
|
| 829 |
+
|
| 830 |
+
def _set_caretdownbase(self):
|
| 831 |
+
self._set_caretdown()
|
| 832 |
+
self._path = self._caret_path_base
|
| 833 |
+
|
| 834 |
+
def _set_caretupbase(self):
|
| 835 |
+
self._set_caretdownbase()
|
| 836 |
+
self._transform = self._transform.rotate_deg(180)
|
| 837 |
+
|
| 838 |
+
def _set_caretleftbase(self):
|
| 839 |
+
self._set_caretdownbase()
|
| 840 |
+
self._transform = self._transform.rotate_deg(270)
|
| 841 |
+
|
| 842 |
+
def _set_caretrightbase(self):
|
| 843 |
+
self._set_caretdownbase()
|
| 844 |
+
self._transform = self._transform.rotate_deg(90)
|
| 845 |
+
|
| 846 |
+
_plus_path = Path([[-1.0, 0.0], [1.0, 0.0],
|
| 847 |
+
[0.0, -1.0], [0.0, 1.0]],
|
| 848 |
+
[Path.MOVETO, Path.LINETO,
|
| 849 |
+
Path.MOVETO, Path.LINETO])
|
| 850 |
+
|
| 851 |
+
def _set_plus(self):
|
| 852 |
+
self._transform = Affine2D().scale(0.5)
|
| 853 |
+
self._snap_threshold = 1.0
|
| 854 |
+
self._filled = False
|
| 855 |
+
self._path = self._plus_path
|
| 856 |
+
|
| 857 |
+
_x_path = Path([[-1.0, -1.0], [1.0, 1.0],
|
| 858 |
+
[-1.0, 1.0], [1.0, -1.0]],
|
| 859 |
+
[Path.MOVETO, Path.LINETO,
|
| 860 |
+
Path.MOVETO, Path.LINETO])
|
| 861 |
+
|
| 862 |
+
def _set_x(self):
|
| 863 |
+
self._transform = Affine2D().scale(0.5)
|
| 864 |
+
self._snap_threshold = 3.0
|
| 865 |
+
self._filled = False
|
| 866 |
+
self._path = self._x_path
|
| 867 |
+
|
| 868 |
+
_plus_filled_path = Path._create_closed(np.array([
|
| 869 |
+
(-1, -3), (+1, -3), (+1, -1), (+3, -1), (+3, +1), (+1, +1),
|
| 870 |
+
(+1, +3), (-1, +3), (-1, +1), (-3, +1), (-3, -1), (-1, -1)]) / 6)
|
| 871 |
+
_plus_filled_path_t = Path._create_closed(np.array([
|
| 872 |
+
(+3, 0), (+3, +1), (+1, +1), (+1, +3),
|
| 873 |
+
(-1, +3), (-1, +1), (-3, +1), (-3, 0)]) / 6)
|
| 874 |
+
|
| 875 |
+
def _set_plus_filled(self):
|
| 876 |
+
self._transform = Affine2D()
|
| 877 |
+
self._snap_threshold = 5.0
|
| 878 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 879 |
+
if not self._half_fill():
|
| 880 |
+
self._path = self._plus_filled_path
|
| 881 |
+
else:
|
| 882 |
+
# Rotate top half path to support all partitions
|
| 883 |
+
self._path = self._alt_path = self._plus_filled_path_t
|
| 884 |
+
fs = self.get_fillstyle()
|
| 885 |
+
self._transform.rotate_deg(
|
| 886 |
+
{'top': 0, 'left': 90, 'bottom': 180, 'right': 270}[fs])
|
| 887 |
+
self._alt_transform = self._transform.frozen().rotate_deg(180)
|
| 888 |
+
|
| 889 |
+
_x_filled_path = Path._create_closed(np.array([
|
| 890 |
+
(-1, -2), (0, -1), (+1, -2), (+2, -1), (+1, 0), (+2, +1),
|
| 891 |
+
(+1, +2), (0, +1), (-1, +2), (-2, +1), (-1, 0), (-2, -1)]) / 4)
|
| 892 |
+
_x_filled_path_t = Path._create_closed(np.array([
|
| 893 |
+
(+1, 0), (+2, +1), (+1, +2), (0, +1),
|
| 894 |
+
(-1, +2), (-2, +1), (-1, 0)]) / 4)
|
| 895 |
+
|
| 896 |
+
def _set_x_filled(self):
|
| 897 |
+
self._transform = Affine2D()
|
| 898 |
+
self._snap_threshold = 5.0
|
| 899 |
+
self._joinstyle = self._user_joinstyle or JoinStyle.miter
|
| 900 |
+
if not self._half_fill():
|
| 901 |
+
self._path = self._x_filled_path
|
| 902 |
+
else:
|
| 903 |
+
# Rotate top half path to support all partitions
|
| 904 |
+
self._path = self._alt_path = self._x_filled_path_t
|
| 905 |
+
fs = self.get_fillstyle()
|
| 906 |
+
self._transform.rotate_deg(
|
| 907 |
+
{'top': 0, 'left': 90, 'bottom': 180, 'right': 270}[fs])
|
| 908 |
+
self._alt_transform = self._transform.frozen().rotate_deg(180)
|
infer_4_30_0/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: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/mathtext.py
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
r"""
|
| 2 |
+
A module for parsing a subset of the TeX math syntax and rendering it to a
|
| 3 |
+
Matplotlib backend.
|
| 4 |
+
|
| 5 |
+
For a tutorial of its usage, see :ref:`mathtext`. This
|
| 6 |
+
document is primarily concerned with implementation details.
|
| 7 |
+
|
| 8 |
+
The module uses pyparsing_ to parse the TeX expression.
|
| 9 |
+
|
| 10 |
+
.. _pyparsing: https://pypi.org/project/pyparsing/
|
| 11 |
+
|
| 12 |
+
The Bakoma distribution of the TeX Computer Modern fonts, and STIX
|
| 13 |
+
fonts are supported. There is experimental support for using
|
| 14 |
+
arbitrary fonts, but results may vary without proper tweaking and
|
| 15 |
+
metrics for those fonts.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
import functools
|
| 19 |
+
import logging
|
| 20 |
+
|
| 21 |
+
import matplotlib as mpl
|
| 22 |
+
from matplotlib import _api, _mathtext
|
| 23 |
+
from matplotlib.ft2font import LoadFlags
|
| 24 |
+
from matplotlib.font_manager import FontProperties
|
| 25 |
+
from ._mathtext import ( # noqa: F401, reexported API
|
| 26 |
+
RasterParse, VectorParse, get_unicode_index)
|
| 27 |
+
|
| 28 |
+
_log = logging.getLogger(__name__)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
get_unicode_index.__module__ = __name__
|
| 32 |
+
|
| 33 |
+
##############################################################################
|
| 34 |
+
# MAIN
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class MathTextParser:
|
| 38 |
+
_parser = None
|
| 39 |
+
_font_type_mapping = {
|
| 40 |
+
'cm': _mathtext.BakomaFonts,
|
| 41 |
+
'dejavuserif': _mathtext.DejaVuSerifFonts,
|
| 42 |
+
'dejavusans': _mathtext.DejaVuSansFonts,
|
| 43 |
+
'stix': _mathtext.StixFonts,
|
| 44 |
+
'stixsans': _mathtext.StixSansFonts,
|
| 45 |
+
'custom': _mathtext.UnicodeFonts,
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
def __init__(self, output):
|
| 49 |
+
"""
|
| 50 |
+
Create a MathTextParser for the given backend *output*.
|
| 51 |
+
|
| 52 |
+
Parameters
|
| 53 |
+
----------
|
| 54 |
+
output : {"path", "agg"}
|
| 55 |
+
Whether to return a `VectorParse` ("path") or a
|
| 56 |
+
`RasterParse` ("agg", or its synonym "macosx").
|
| 57 |
+
"""
|
| 58 |
+
self._output_type = _api.check_getitem(
|
| 59 |
+
{"path": "vector", "agg": "raster", "macosx": "raster"},
|
| 60 |
+
output=output.lower())
|
| 61 |
+
|
| 62 |
+
def parse(self, s, dpi=72, prop=None, *, antialiased=None):
|
| 63 |
+
"""
|
| 64 |
+
Parse the given math expression *s* at the given *dpi*. If *prop* is
|
| 65 |
+
provided, it is a `.FontProperties` object specifying the "default"
|
| 66 |
+
font to use in the math expression, used for all non-math text.
|
| 67 |
+
|
| 68 |
+
The results are cached, so multiple calls to `parse`
|
| 69 |
+
with the same expression should be fast.
|
| 70 |
+
|
| 71 |
+
Depending on the *output* type, this returns either a `VectorParse` or
|
| 72 |
+
a `RasterParse`.
|
| 73 |
+
"""
|
| 74 |
+
# lru_cache can't decorate parse() directly because prop is
|
| 75 |
+
# mutable, so we key the cache using an internal copy (see
|
| 76 |
+
# Text._get_text_metrics_with_cache for a similar case); likewise,
|
| 77 |
+
# we need to check the mutable state of the text.antialiased and
|
| 78 |
+
# text.hinting rcParams.
|
| 79 |
+
prop = prop.copy() if prop is not None else None
|
| 80 |
+
antialiased = mpl._val_or_rc(antialiased, 'text.antialiased')
|
| 81 |
+
from matplotlib.backends import backend_agg
|
| 82 |
+
load_glyph_flags = {
|
| 83 |
+
"vector": LoadFlags.NO_HINTING,
|
| 84 |
+
"raster": backend_agg.get_hinting_flag(),
|
| 85 |
+
}[self._output_type]
|
| 86 |
+
return self._parse_cached(s, dpi, prop, antialiased, load_glyph_flags)
|
| 87 |
+
|
| 88 |
+
@functools.lru_cache(50)
|
| 89 |
+
def _parse_cached(self, s, dpi, prop, antialiased, load_glyph_flags):
|
| 90 |
+
if prop is None:
|
| 91 |
+
prop = FontProperties()
|
| 92 |
+
fontset_class = _api.check_getitem(
|
| 93 |
+
self._font_type_mapping, fontset=prop.get_math_fontfamily())
|
| 94 |
+
fontset = fontset_class(prop, load_glyph_flags)
|
| 95 |
+
fontsize = prop.get_size_in_points()
|
| 96 |
+
|
| 97 |
+
if self._parser is None: # Cache the parser globally.
|
| 98 |
+
self.__class__._parser = _mathtext.Parser()
|
| 99 |
+
|
| 100 |
+
box = self._parser.parse(s, fontset, fontsize, dpi)
|
| 101 |
+
output = _mathtext.ship(box)
|
| 102 |
+
if self._output_type == "vector":
|
| 103 |
+
return output.to_vector()
|
| 104 |
+
elif self._output_type == "raster":
|
| 105 |
+
return output.to_raster(antialiased=antialiased)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def math_to_image(s, filename_or_obj, prop=None, dpi=None, format=None,
|
| 109 |
+
*, color=None):
|
| 110 |
+
"""
|
| 111 |
+
Given a math expression, renders it in a closely-clipped bounding
|
| 112 |
+
box to an image file.
|
| 113 |
+
|
| 114 |
+
Parameters
|
| 115 |
+
----------
|
| 116 |
+
s : str
|
| 117 |
+
A math expression. The math portion must be enclosed in dollar signs.
|
| 118 |
+
filename_or_obj : str or path-like or file-like
|
| 119 |
+
Where to write the image data.
|
| 120 |
+
prop : `.FontProperties`, optional
|
| 121 |
+
The size and style of the text.
|
| 122 |
+
dpi : float, optional
|
| 123 |
+
The output dpi. If not set, the dpi is determined as for
|
| 124 |
+
`.Figure.savefig`.
|
| 125 |
+
format : str, optional
|
| 126 |
+
The output format, e.g., 'svg', 'pdf', 'ps' or 'png'. If not set, the
|
| 127 |
+
format is determined as for `.Figure.savefig`.
|
| 128 |
+
color : str, optional
|
| 129 |
+
Foreground color, defaults to :rc:`text.color`.
|
| 130 |
+
"""
|
| 131 |
+
from matplotlib import figure
|
| 132 |
+
|
| 133 |
+
parser = MathTextParser('path')
|
| 134 |
+
width, height, depth, _, _ = parser.parse(s, dpi=72, prop=prop)
|
| 135 |
+
|
| 136 |
+
fig = figure.Figure(figsize=(width / 72.0, height / 72.0))
|
| 137 |
+
fig.text(0, depth/height, s, fontproperties=prop, color=color)
|
| 138 |
+
fig.savefig(filename_or_obj, dpi=dpi, format=format)
|
| 139 |
+
|
| 140 |
+
return depth
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/mathtext.pyi
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from typing import Generic, IO, Literal, TypeVar, overload
|
| 3 |
+
|
| 4 |
+
from matplotlib.font_manager import FontProperties
|
| 5 |
+
from matplotlib.typing import ColorType
|
| 6 |
+
|
| 7 |
+
# Re-exported API from _mathtext.
|
| 8 |
+
from ._mathtext import (
|
| 9 |
+
RasterParse as RasterParse,
|
| 10 |
+
VectorParse as VectorParse,
|
| 11 |
+
get_unicode_index as get_unicode_index,
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
_ParseType = TypeVar("_ParseType", RasterParse, VectorParse)
|
| 15 |
+
|
| 16 |
+
class MathTextParser(Generic[_ParseType]):
|
| 17 |
+
@overload
|
| 18 |
+
def __init__(self: MathTextParser[VectorParse], output: Literal["path"]) -> None: ...
|
| 19 |
+
@overload
|
| 20 |
+
def __init__(self: MathTextParser[RasterParse], output: Literal["agg", "raster", "macosx"]) -> None: ...
|
| 21 |
+
def parse(
|
| 22 |
+
self, s: str, dpi: float = ..., prop: FontProperties | None = ..., *, antialiased: bool | None = ...
|
| 23 |
+
) -> _ParseType: ...
|
| 24 |
+
|
| 25 |
+
def math_to_image(
|
| 26 |
+
s: str,
|
| 27 |
+
filename_or_obj: str | os.PathLike | IO,
|
| 28 |
+
prop: FontProperties | None = ...,
|
| 29 |
+
dpi: float | None = ...,
|
| 30 |
+
format: str | None = ...,
|
| 31 |
+
*,
|
| 32 |
+
color: ColorType | None = ...
|
| 33 |
+
) -> float: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/offsetbox.py
ADDED
|
@@ -0,0 +1,1607 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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`, `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 |
+
.. code-block:: none
|
| 441 |
+
|
| 442 |
+
+---------+
|
| 443 |
+
| Child 1 |
|
| 444 |
+
| Child 2 |
|
| 445 |
+
| Child 3 |
|
| 446 |
+
+---------+
|
| 447 |
+
"""
|
| 448 |
+
|
| 449 |
+
def _get_bbox_and_child_offsets(self, renderer):
|
| 450 |
+
# docstring inherited
|
| 451 |
+
dpicor = renderer.points_to_pixels(1.)
|
| 452 |
+
pad = self.pad * dpicor
|
| 453 |
+
sep = self.sep * dpicor
|
| 454 |
+
|
| 455 |
+
if self.width is not None:
|
| 456 |
+
for c in self.get_visible_children():
|
| 457 |
+
if isinstance(c, PackerBase) and c.mode == "expand":
|
| 458 |
+
c.set_width(self.width)
|
| 459 |
+
|
| 460 |
+
bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
|
| 461 |
+
(x0, x1), xoffsets = _get_aligned_offsets(
|
| 462 |
+
[bbox.intervalx for bbox in bboxes], self.width, self.align)
|
| 463 |
+
height, yoffsets = _get_packed_offsets(
|
| 464 |
+
[bbox.height for bbox in bboxes], self.height, sep, self.mode)
|
| 465 |
+
|
| 466 |
+
yoffsets = height - (yoffsets + [bbox.y1 for bbox in bboxes])
|
| 467 |
+
ydescent = yoffsets[0]
|
| 468 |
+
yoffsets = yoffsets - ydescent
|
| 469 |
+
|
| 470 |
+
return (
|
| 471 |
+
Bbox.from_bounds(x0, -ydescent, x1 - x0, height).padded(pad),
|
| 472 |
+
[*zip(xoffsets, yoffsets)])
|
| 473 |
+
|
| 474 |
+
|
| 475 |
+
class HPacker(PackerBase):
|
| 476 |
+
"""
|
| 477 |
+
HPacker packs its children horizontally, automatically adjusting their
|
| 478 |
+
relative positions at draw time.
|
| 479 |
+
|
| 480 |
+
.. code-block:: none
|
| 481 |
+
|
| 482 |
+
+-------------------------------+
|
| 483 |
+
| Child 1 Child 2 Child 3 |
|
| 484 |
+
+-------------------------------+
|
| 485 |
+
"""
|
| 486 |
+
|
| 487 |
+
def _get_bbox_and_child_offsets(self, renderer):
|
| 488 |
+
# docstring inherited
|
| 489 |
+
dpicor = renderer.points_to_pixels(1.)
|
| 490 |
+
pad = self.pad * dpicor
|
| 491 |
+
sep = self.sep * dpicor
|
| 492 |
+
|
| 493 |
+
bboxes = [c.get_bbox(renderer) for c in self.get_visible_children()]
|
| 494 |
+
if not bboxes:
|
| 495 |
+
return Bbox.from_bounds(0, 0, 0, 0).padded(pad), []
|
| 496 |
+
|
| 497 |
+
(y0, y1), yoffsets = _get_aligned_offsets(
|
| 498 |
+
[bbox.intervaly for bbox in bboxes], self.height, self.align)
|
| 499 |
+
width, xoffsets = _get_packed_offsets(
|
| 500 |
+
[bbox.width for bbox in bboxes], self.width, sep, self.mode)
|
| 501 |
+
|
| 502 |
+
x0 = bboxes[0].x0
|
| 503 |
+
xoffsets -= ([bbox.x0 for bbox in bboxes] - x0)
|
| 504 |
+
|
| 505 |
+
return (Bbox.from_bounds(x0, y0, width, y1 - y0).padded(pad),
|
| 506 |
+
[*zip(xoffsets, yoffsets)])
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
class PaddedBox(OffsetBox):
|
| 510 |
+
"""
|
| 511 |
+
A container to add a padding around an `.Artist`.
|
| 512 |
+
|
| 513 |
+
The `.PaddedBox` contains a `.FancyBboxPatch` that is used to visualize
|
| 514 |
+
it when rendering.
|
| 515 |
+
|
| 516 |
+
.. code-block:: none
|
| 517 |
+
|
| 518 |
+
+----------------------------+
|
| 519 |
+
| |
|
| 520 |
+
| |
|
| 521 |
+
| |
|
| 522 |
+
| <--pad--> Artist |
|
| 523 |
+
| ^ |
|
| 524 |
+
| pad |
|
| 525 |
+
| v |
|
| 526 |
+
+----------------------------+
|
| 527 |
+
|
| 528 |
+
Attributes
|
| 529 |
+
----------
|
| 530 |
+
pad : float
|
| 531 |
+
The padding in points.
|
| 532 |
+
patch : `.FancyBboxPatch`
|
| 533 |
+
When *draw_frame* is True, this `.FancyBboxPatch` is made visible and
|
| 534 |
+
creates a border around the box.
|
| 535 |
+
"""
|
| 536 |
+
|
| 537 |
+
def __init__(self, child, pad=0., *, draw_frame=False, patch_attrs=None):
|
| 538 |
+
"""
|
| 539 |
+
Parameters
|
| 540 |
+
----------
|
| 541 |
+
child : `~matplotlib.artist.Artist`
|
| 542 |
+
The contained `.Artist`.
|
| 543 |
+
pad : float, default: 0.0
|
| 544 |
+
The padding in points. This will be scaled with the renderer dpi.
|
| 545 |
+
In contrast, *width* and *height* are in *pixels* and thus not
|
| 546 |
+
scaled.
|
| 547 |
+
draw_frame : bool
|
| 548 |
+
Whether to draw the contained `.FancyBboxPatch`.
|
| 549 |
+
patch_attrs : dict or None
|
| 550 |
+
Additional parameters passed to the contained `.FancyBboxPatch`.
|
| 551 |
+
"""
|
| 552 |
+
super().__init__()
|
| 553 |
+
self.pad = pad
|
| 554 |
+
self._children = [child]
|
| 555 |
+
self.patch = FancyBboxPatch(
|
| 556 |
+
xy=(0.0, 0.0), width=1., height=1.,
|
| 557 |
+
facecolor='w', edgecolor='k',
|
| 558 |
+
mutation_scale=1, # self.prop.get_size_in_points(),
|
| 559 |
+
snap=True,
|
| 560 |
+
visible=draw_frame,
|
| 561 |
+
boxstyle="square,pad=0",
|
| 562 |
+
)
|
| 563 |
+
if patch_attrs is not None:
|
| 564 |
+
self.patch.update(patch_attrs)
|
| 565 |
+
|
| 566 |
+
def _get_bbox_and_child_offsets(self, renderer):
|
| 567 |
+
# docstring inherited.
|
| 568 |
+
pad = self.pad * renderer.points_to_pixels(1.)
|
| 569 |
+
return (self._children[0].get_bbox(renderer).padded(pad), [(0, 0)])
|
| 570 |
+
|
| 571 |
+
def draw(self, renderer):
|
| 572 |
+
# docstring inherited
|
| 573 |
+
bbox, offsets = self._get_bbox_and_child_offsets(renderer)
|
| 574 |
+
px, py = self.get_offset(bbox, renderer)
|
| 575 |
+
for c, (ox, oy) in zip(self.get_visible_children(), offsets):
|
| 576 |
+
c.set_offset((px + ox, py + oy))
|
| 577 |
+
|
| 578 |
+
self.draw_frame(renderer)
|
| 579 |
+
|
| 580 |
+
for c in self.get_visible_children():
|
| 581 |
+
c.draw(renderer)
|
| 582 |
+
|
| 583 |
+
self.stale = False
|
| 584 |
+
|
| 585 |
+
def update_frame(self, bbox, fontsize=None):
|
| 586 |
+
self.patch.set_bounds(bbox.bounds)
|
| 587 |
+
if fontsize:
|
| 588 |
+
self.patch.set_mutation_scale(fontsize)
|
| 589 |
+
self.stale = True
|
| 590 |
+
|
| 591 |
+
def draw_frame(self, renderer):
|
| 592 |
+
# update the location and size of the legend
|
| 593 |
+
self.update_frame(self.get_window_extent(renderer))
|
| 594 |
+
self.patch.draw(renderer)
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
class DrawingArea(OffsetBox):
|
| 598 |
+
"""
|
| 599 |
+
The DrawingArea can contain any Artist as a child. The DrawingArea
|
| 600 |
+
has a fixed width and height. The position of children relative to
|
| 601 |
+
the parent is fixed. The children can be clipped at the
|
| 602 |
+
boundaries of the parent.
|
| 603 |
+
"""
|
| 604 |
+
|
| 605 |
+
def __init__(self, width, height, xdescent=0., ydescent=0., clip=False):
|
| 606 |
+
"""
|
| 607 |
+
Parameters
|
| 608 |
+
----------
|
| 609 |
+
width, height : float
|
| 610 |
+
Width and height of the container box.
|
| 611 |
+
xdescent, ydescent : float
|
| 612 |
+
Descent of the box in x- and y-direction.
|
| 613 |
+
clip : bool
|
| 614 |
+
Whether to clip the children to the box.
|
| 615 |
+
"""
|
| 616 |
+
super().__init__()
|
| 617 |
+
self.width = width
|
| 618 |
+
self.height = height
|
| 619 |
+
self.xdescent = xdescent
|
| 620 |
+
self.ydescent = ydescent
|
| 621 |
+
self._clip_children = clip
|
| 622 |
+
self.offset_transform = mtransforms.Affine2D()
|
| 623 |
+
self.dpi_transform = mtransforms.Affine2D()
|
| 624 |
+
|
| 625 |
+
@property
|
| 626 |
+
def clip_children(self):
|
| 627 |
+
"""
|
| 628 |
+
If the children of this DrawingArea should be clipped
|
| 629 |
+
by DrawingArea bounding box.
|
| 630 |
+
"""
|
| 631 |
+
return self._clip_children
|
| 632 |
+
|
| 633 |
+
@clip_children.setter
|
| 634 |
+
def clip_children(self, val):
|
| 635 |
+
self._clip_children = bool(val)
|
| 636 |
+
self.stale = True
|
| 637 |
+
|
| 638 |
+
def get_transform(self):
|
| 639 |
+
"""
|
| 640 |
+
Return the `~matplotlib.transforms.Transform` applied to the children.
|
| 641 |
+
"""
|
| 642 |
+
return self.dpi_transform + self.offset_transform
|
| 643 |
+
|
| 644 |
+
def set_transform(self, t):
|
| 645 |
+
"""
|
| 646 |
+
set_transform is ignored.
|
| 647 |
+
"""
|
| 648 |
+
|
| 649 |
+
def set_offset(self, xy):
|
| 650 |
+
"""
|
| 651 |
+
Set the offset of the container.
|
| 652 |
+
|
| 653 |
+
Parameters
|
| 654 |
+
----------
|
| 655 |
+
xy : (float, float)
|
| 656 |
+
The (x, y) coordinates of the offset in display units.
|
| 657 |
+
"""
|
| 658 |
+
self._offset = xy
|
| 659 |
+
self.offset_transform.clear()
|
| 660 |
+
self.offset_transform.translate(xy[0], xy[1])
|
| 661 |
+
self.stale = True
|
| 662 |
+
|
| 663 |
+
def get_offset(self):
|
| 664 |
+
"""Return offset of the container."""
|
| 665 |
+
return self._offset
|
| 666 |
+
|
| 667 |
+
def get_bbox(self, renderer):
|
| 668 |
+
# docstring inherited
|
| 669 |
+
dpi_cor = renderer.points_to_pixels(1.)
|
| 670 |
+
return Bbox.from_bounds(
|
| 671 |
+
-self.xdescent * dpi_cor, -self.ydescent * dpi_cor,
|
| 672 |
+
self.width * dpi_cor, self.height * dpi_cor)
|
| 673 |
+
|
| 674 |
+
def add_artist(self, a):
|
| 675 |
+
"""Add an `.Artist` to the container box."""
|
| 676 |
+
self._children.append(a)
|
| 677 |
+
if not a.is_transform_set():
|
| 678 |
+
a.set_transform(self.get_transform())
|
| 679 |
+
if self.axes is not None:
|
| 680 |
+
a.axes = self.axes
|
| 681 |
+
fig = self.get_figure(root=False)
|
| 682 |
+
if fig is not None:
|
| 683 |
+
a.set_figure(fig)
|
| 684 |
+
|
| 685 |
+
def draw(self, renderer):
|
| 686 |
+
# docstring inherited
|
| 687 |
+
|
| 688 |
+
dpi_cor = renderer.points_to_pixels(1.)
|
| 689 |
+
self.dpi_transform.clear()
|
| 690 |
+
self.dpi_transform.scale(dpi_cor)
|
| 691 |
+
|
| 692 |
+
# At this point the DrawingArea has a transform
|
| 693 |
+
# to the display space so the path created is
|
| 694 |
+
# good for clipping children
|
| 695 |
+
tpath = mtransforms.TransformedPath(
|
| 696 |
+
mpath.Path([[0, 0], [0, self.height],
|
| 697 |
+
[self.width, self.height],
|
| 698 |
+
[self.width, 0]]),
|
| 699 |
+
self.get_transform())
|
| 700 |
+
for c in self._children:
|
| 701 |
+
if self._clip_children and not (c.clipbox or c._clippath):
|
| 702 |
+
c.set_clip_path(tpath)
|
| 703 |
+
c.draw(renderer)
|
| 704 |
+
|
| 705 |
+
_bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 706 |
+
self.stale = False
|
| 707 |
+
|
| 708 |
+
|
| 709 |
+
class TextArea(OffsetBox):
|
| 710 |
+
"""
|
| 711 |
+
The TextArea is a container artist for a single Text instance.
|
| 712 |
+
|
| 713 |
+
The text is placed at (0, 0) with baseline+left alignment, by default. The
|
| 714 |
+
width and height of the TextArea instance is the width and height of its
|
| 715 |
+
child text.
|
| 716 |
+
"""
|
| 717 |
+
|
| 718 |
+
def __init__(self, s,
|
| 719 |
+
*,
|
| 720 |
+
textprops=None,
|
| 721 |
+
multilinebaseline=False,
|
| 722 |
+
):
|
| 723 |
+
"""
|
| 724 |
+
Parameters
|
| 725 |
+
----------
|
| 726 |
+
s : str
|
| 727 |
+
The text to be displayed.
|
| 728 |
+
textprops : dict, default: {}
|
| 729 |
+
Dictionary of keyword parameters to be passed to the `.Text`
|
| 730 |
+
instance in the TextArea.
|
| 731 |
+
multilinebaseline : bool, default: False
|
| 732 |
+
Whether the baseline for multiline text is adjusted so that it
|
| 733 |
+
is (approximately) center-aligned with single-line text.
|
| 734 |
+
"""
|
| 735 |
+
if textprops is None:
|
| 736 |
+
textprops = {}
|
| 737 |
+
self._text = mtext.Text(0, 0, s, **textprops)
|
| 738 |
+
super().__init__()
|
| 739 |
+
self._children = [self._text]
|
| 740 |
+
self.offset_transform = mtransforms.Affine2D()
|
| 741 |
+
self._baseline_transform = mtransforms.Affine2D()
|
| 742 |
+
self._text.set_transform(self.offset_transform +
|
| 743 |
+
self._baseline_transform)
|
| 744 |
+
self._multilinebaseline = multilinebaseline
|
| 745 |
+
|
| 746 |
+
def set_text(self, s):
|
| 747 |
+
"""Set the text of this area as a string."""
|
| 748 |
+
self._text.set_text(s)
|
| 749 |
+
self.stale = True
|
| 750 |
+
|
| 751 |
+
def get_text(self):
|
| 752 |
+
"""Return the string representation of this area's text."""
|
| 753 |
+
return self._text.get_text()
|
| 754 |
+
|
| 755 |
+
def set_multilinebaseline(self, t):
|
| 756 |
+
"""
|
| 757 |
+
Set multilinebaseline.
|
| 758 |
+
|
| 759 |
+
If True, the baseline for multiline text is adjusted so that it is
|
| 760 |
+
(approximately) center-aligned with single-line text. This is used
|
| 761 |
+
e.g. by the legend implementation so that single-line labels are
|
| 762 |
+
baseline-aligned, but multiline labels are "center"-aligned with them.
|
| 763 |
+
"""
|
| 764 |
+
self._multilinebaseline = t
|
| 765 |
+
self.stale = True
|
| 766 |
+
|
| 767 |
+
def get_multilinebaseline(self):
|
| 768 |
+
"""
|
| 769 |
+
Get multilinebaseline.
|
| 770 |
+
"""
|
| 771 |
+
return self._multilinebaseline
|
| 772 |
+
|
| 773 |
+
def set_transform(self, t):
|
| 774 |
+
"""
|
| 775 |
+
set_transform is ignored.
|
| 776 |
+
"""
|
| 777 |
+
|
| 778 |
+
def set_offset(self, xy):
|
| 779 |
+
"""
|
| 780 |
+
Set the offset of the container.
|
| 781 |
+
|
| 782 |
+
Parameters
|
| 783 |
+
----------
|
| 784 |
+
xy : (float, float)
|
| 785 |
+
The (x, y) coordinates of the offset in display units.
|
| 786 |
+
"""
|
| 787 |
+
self._offset = xy
|
| 788 |
+
self.offset_transform.clear()
|
| 789 |
+
self.offset_transform.translate(xy[0], xy[1])
|
| 790 |
+
self.stale = True
|
| 791 |
+
|
| 792 |
+
def get_offset(self):
|
| 793 |
+
"""Return offset of the container."""
|
| 794 |
+
return self._offset
|
| 795 |
+
|
| 796 |
+
def get_bbox(self, renderer):
|
| 797 |
+
_, h_, d_ = renderer.get_text_width_height_descent(
|
| 798 |
+
"lp", self._text._fontproperties,
|
| 799 |
+
ismath="TeX" if self._text.get_usetex() else False)
|
| 800 |
+
|
| 801 |
+
bbox, info, yd = self._text._get_layout(renderer)
|
| 802 |
+
w, h = bbox.size
|
| 803 |
+
|
| 804 |
+
self._baseline_transform.clear()
|
| 805 |
+
|
| 806 |
+
if len(info) > 1 and self._multilinebaseline:
|
| 807 |
+
yd_new = 0.5 * h - 0.5 * (h_ - d_)
|
| 808 |
+
self._baseline_transform.translate(0, yd - yd_new)
|
| 809 |
+
yd = yd_new
|
| 810 |
+
else: # single line
|
| 811 |
+
h_d = max(h_ - d_, h - yd)
|
| 812 |
+
h = h_d + yd
|
| 813 |
+
|
| 814 |
+
ha = self._text.get_horizontalalignment()
|
| 815 |
+
x0 = {"left": 0, "center": -w / 2, "right": -w}[ha]
|
| 816 |
+
|
| 817 |
+
return Bbox.from_bounds(x0, -yd, w, h)
|
| 818 |
+
|
| 819 |
+
def draw(self, renderer):
|
| 820 |
+
# docstring inherited
|
| 821 |
+
self._text.draw(renderer)
|
| 822 |
+
_bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 823 |
+
self.stale = False
|
| 824 |
+
|
| 825 |
+
|
| 826 |
+
class AuxTransformBox(OffsetBox):
|
| 827 |
+
"""
|
| 828 |
+
Offset Box with the aux_transform. Its children will be
|
| 829 |
+
transformed with the aux_transform first then will be
|
| 830 |
+
offsetted. The absolute coordinate of the aux_transform is meaning
|
| 831 |
+
as it will be automatically adjust so that the left-lower corner
|
| 832 |
+
of the bounding box of children will be set to (0, 0) before the
|
| 833 |
+
offset transform.
|
| 834 |
+
|
| 835 |
+
It is similar to drawing area, except that the extent of the box
|
| 836 |
+
is not predetermined but calculated from the window extent of its
|
| 837 |
+
children. Furthermore, the extent of the children will be
|
| 838 |
+
calculated in the transformed coordinate.
|
| 839 |
+
"""
|
| 840 |
+
def __init__(self, aux_transform):
|
| 841 |
+
self.aux_transform = aux_transform
|
| 842 |
+
super().__init__()
|
| 843 |
+
self.offset_transform = mtransforms.Affine2D()
|
| 844 |
+
# ref_offset_transform makes offset_transform always relative to the
|
| 845 |
+
# lower-left corner of the bbox of its children.
|
| 846 |
+
self.ref_offset_transform = mtransforms.Affine2D()
|
| 847 |
+
|
| 848 |
+
def add_artist(self, a):
|
| 849 |
+
"""Add an `.Artist` to the container box."""
|
| 850 |
+
self._children.append(a)
|
| 851 |
+
a.set_transform(self.get_transform())
|
| 852 |
+
self.stale = True
|
| 853 |
+
|
| 854 |
+
def get_transform(self):
|
| 855 |
+
"""
|
| 856 |
+
Return the :class:`~matplotlib.transforms.Transform` applied
|
| 857 |
+
to the children
|
| 858 |
+
"""
|
| 859 |
+
return (self.aux_transform
|
| 860 |
+
+ self.ref_offset_transform
|
| 861 |
+
+ self.offset_transform)
|
| 862 |
+
|
| 863 |
+
def set_transform(self, t):
|
| 864 |
+
"""
|
| 865 |
+
set_transform is ignored.
|
| 866 |
+
"""
|
| 867 |
+
|
| 868 |
+
def set_offset(self, xy):
|
| 869 |
+
"""
|
| 870 |
+
Set the offset of the container.
|
| 871 |
+
|
| 872 |
+
Parameters
|
| 873 |
+
----------
|
| 874 |
+
xy : (float, float)
|
| 875 |
+
The (x, y) coordinates of the offset in display units.
|
| 876 |
+
"""
|
| 877 |
+
self._offset = xy
|
| 878 |
+
self.offset_transform.clear()
|
| 879 |
+
self.offset_transform.translate(xy[0], xy[1])
|
| 880 |
+
self.stale = True
|
| 881 |
+
|
| 882 |
+
def get_offset(self):
|
| 883 |
+
"""Return offset of the container."""
|
| 884 |
+
return self._offset
|
| 885 |
+
|
| 886 |
+
def get_bbox(self, renderer):
|
| 887 |
+
# clear the offset transforms
|
| 888 |
+
_off = self.offset_transform.get_matrix() # to be restored later
|
| 889 |
+
self.ref_offset_transform.clear()
|
| 890 |
+
self.offset_transform.clear()
|
| 891 |
+
# calculate the extent
|
| 892 |
+
bboxes = [c.get_window_extent(renderer) for c in self._children]
|
| 893 |
+
ub = Bbox.union(bboxes)
|
| 894 |
+
# adjust ref_offset_transform
|
| 895 |
+
self.ref_offset_transform.translate(-ub.x0, -ub.y0)
|
| 896 |
+
# restore offset transform
|
| 897 |
+
self.offset_transform.set_matrix(_off)
|
| 898 |
+
return Bbox.from_bounds(0, 0, ub.width, ub.height)
|
| 899 |
+
|
| 900 |
+
def draw(self, renderer):
|
| 901 |
+
# docstring inherited
|
| 902 |
+
for c in self._children:
|
| 903 |
+
c.draw(renderer)
|
| 904 |
+
_bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 905 |
+
self.stale = False
|
| 906 |
+
|
| 907 |
+
|
| 908 |
+
class AnchoredOffsetbox(OffsetBox):
|
| 909 |
+
"""
|
| 910 |
+
An offset box placed according to location *loc*.
|
| 911 |
+
|
| 912 |
+
AnchoredOffsetbox has a single child. When multiple children are needed,
|
| 913 |
+
use an extra OffsetBox to enclose them. By default, the offset box is
|
| 914 |
+
anchored against its parent Axes. You may explicitly specify the
|
| 915 |
+
*bbox_to_anchor*.
|
| 916 |
+
"""
|
| 917 |
+
zorder = 5 # zorder of the legend
|
| 918 |
+
|
| 919 |
+
# Location codes
|
| 920 |
+
codes = {'upper right': 1,
|
| 921 |
+
'upper left': 2,
|
| 922 |
+
'lower left': 3,
|
| 923 |
+
'lower right': 4,
|
| 924 |
+
'right': 5,
|
| 925 |
+
'center left': 6,
|
| 926 |
+
'center right': 7,
|
| 927 |
+
'lower center': 8,
|
| 928 |
+
'upper center': 9,
|
| 929 |
+
'center': 10,
|
| 930 |
+
}
|
| 931 |
+
|
| 932 |
+
def __init__(self, loc, *,
|
| 933 |
+
pad=0.4, borderpad=0.5,
|
| 934 |
+
child=None, prop=None, frameon=True,
|
| 935 |
+
bbox_to_anchor=None,
|
| 936 |
+
bbox_transform=None,
|
| 937 |
+
**kwargs):
|
| 938 |
+
"""
|
| 939 |
+
Parameters
|
| 940 |
+
----------
|
| 941 |
+
loc : str
|
| 942 |
+
The box location. Valid locations are
|
| 943 |
+
'upper left', 'upper center', 'upper right',
|
| 944 |
+
'center left', 'center', 'center right',
|
| 945 |
+
'lower left', 'lower center', 'lower right'.
|
| 946 |
+
For backward compatibility, numeric values are accepted as well.
|
| 947 |
+
See the parameter *loc* of `.Legend` for details.
|
| 948 |
+
pad : float, default: 0.4
|
| 949 |
+
Padding around the child as fraction of the fontsize.
|
| 950 |
+
borderpad : float, default: 0.5
|
| 951 |
+
Padding between the offsetbox frame and the *bbox_to_anchor*.
|
| 952 |
+
child : `.OffsetBox`
|
| 953 |
+
The box that will be anchored.
|
| 954 |
+
prop : `.FontProperties`
|
| 955 |
+
This is only used as a reference for paddings. If not given,
|
| 956 |
+
:rc:`legend.fontsize` is used.
|
| 957 |
+
frameon : bool
|
| 958 |
+
Whether to draw a frame around the box.
|
| 959 |
+
bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
|
| 960 |
+
Box that is used to position the legend in conjunction with *loc*.
|
| 961 |
+
bbox_transform : None or :class:`matplotlib.transforms.Transform`
|
| 962 |
+
The transform for the bounding box (*bbox_to_anchor*).
|
| 963 |
+
**kwargs
|
| 964 |
+
All other parameters are passed on to `.OffsetBox`.
|
| 965 |
+
|
| 966 |
+
Notes
|
| 967 |
+
-----
|
| 968 |
+
See `.Legend` for a detailed description of the anchoring mechanism.
|
| 969 |
+
"""
|
| 970 |
+
super().__init__(**kwargs)
|
| 971 |
+
|
| 972 |
+
self.set_bbox_to_anchor(bbox_to_anchor, bbox_transform)
|
| 973 |
+
self.set_child(child)
|
| 974 |
+
|
| 975 |
+
if isinstance(loc, str):
|
| 976 |
+
loc = _api.check_getitem(self.codes, loc=loc)
|
| 977 |
+
|
| 978 |
+
self.loc = loc
|
| 979 |
+
self.borderpad = borderpad
|
| 980 |
+
self.pad = pad
|
| 981 |
+
|
| 982 |
+
if prop is None:
|
| 983 |
+
self.prop = FontProperties(size=mpl.rcParams["legend.fontsize"])
|
| 984 |
+
else:
|
| 985 |
+
self.prop = FontProperties._from_any(prop)
|
| 986 |
+
if isinstance(prop, dict) and "size" not in prop:
|
| 987 |
+
self.prop.set_size(mpl.rcParams["legend.fontsize"])
|
| 988 |
+
|
| 989 |
+
self.patch = FancyBboxPatch(
|
| 990 |
+
xy=(0.0, 0.0), width=1., height=1.,
|
| 991 |
+
facecolor='w', edgecolor='k',
|
| 992 |
+
mutation_scale=self.prop.get_size_in_points(),
|
| 993 |
+
snap=True,
|
| 994 |
+
visible=frameon,
|
| 995 |
+
boxstyle="square,pad=0",
|
| 996 |
+
)
|
| 997 |
+
|
| 998 |
+
def set_child(self, child):
|
| 999 |
+
"""Set the child to be anchored."""
|
| 1000 |
+
self._child = child
|
| 1001 |
+
if child is not None:
|
| 1002 |
+
child.axes = self.axes
|
| 1003 |
+
self.stale = True
|
| 1004 |
+
|
| 1005 |
+
def get_child(self):
|
| 1006 |
+
"""Return the child."""
|
| 1007 |
+
return self._child
|
| 1008 |
+
|
| 1009 |
+
def get_children(self):
|
| 1010 |
+
"""Return the list of children."""
|
| 1011 |
+
return [self._child]
|
| 1012 |
+
|
| 1013 |
+
def get_bbox(self, renderer):
|
| 1014 |
+
# docstring inherited
|
| 1015 |
+
fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
|
| 1016 |
+
pad = self.pad * fontsize
|
| 1017 |
+
return self.get_child().get_bbox(renderer).padded(pad)
|
| 1018 |
+
|
| 1019 |
+
def get_bbox_to_anchor(self):
|
| 1020 |
+
"""Return the bbox that the box is anchored to."""
|
| 1021 |
+
if self._bbox_to_anchor is None:
|
| 1022 |
+
return self.axes.bbox
|
| 1023 |
+
else:
|
| 1024 |
+
transform = self._bbox_to_anchor_transform
|
| 1025 |
+
if transform is None:
|
| 1026 |
+
return self._bbox_to_anchor
|
| 1027 |
+
else:
|
| 1028 |
+
return TransformedBbox(self._bbox_to_anchor, transform)
|
| 1029 |
+
|
| 1030 |
+
def set_bbox_to_anchor(self, bbox, transform=None):
|
| 1031 |
+
"""
|
| 1032 |
+
Set the bbox that the box is anchored to.
|
| 1033 |
+
|
| 1034 |
+
*bbox* can be a Bbox instance, a list of [left, bottom, width,
|
| 1035 |
+
height], or a list of [left, bottom] where the width and
|
| 1036 |
+
height will be assumed to be zero. The bbox will be
|
| 1037 |
+
transformed to display coordinate by the given transform.
|
| 1038 |
+
"""
|
| 1039 |
+
if bbox is None or isinstance(bbox, BboxBase):
|
| 1040 |
+
self._bbox_to_anchor = bbox
|
| 1041 |
+
else:
|
| 1042 |
+
try:
|
| 1043 |
+
l = len(bbox)
|
| 1044 |
+
except TypeError as err:
|
| 1045 |
+
raise ValueError(f"Invalid bbox: {bbox}") from err
|
| 1046 |
+
|
| 1047 |
+
if l == 2:
|
| 1048 |
+
bbox = [bbox[0], bbox[1], 0, 0]
|
| 1049 |
+
|
| 1050 |
+
self._bbox_to_anchor = Bbox.from_bounds(*bbox)
|
| 1051 |
+
|
| 1052 |
+
self._bbox_to_anchor_transform = transform
|
| 1053 |
+
self.stale = True
|
| 1054 |
+
|
| 1055 |
+
@_compat_get_offset
|
| 1056 |
+
def get_offset(self, bbox, renderer):
|
| 1057 |
+
# docstring inherited
|
| 1058 |
+
pad = (self.borderpad
|
| 1059 |
+
* renderer.points_to_pixels(self.prop.get_size_in_points()))
|
| 1060 |
+
bbox_to_anchor = self.get_bbox_to_anchor()
|
| 1061 |
+
x0, y0 = _get_anchored_bbox(
|
| 1062 |
+
self.loc, Bbox.from_bounds(0, 0, bbox.width, bbox.height),
|
| 1063 |
+
bbox_to_anchor, pad)
|
| 1064 |
+
return x0 - bbox.x0, y0 - bbox.y0
|
| 1065 |
+
|
| 1066 |
+
def update_frame(self, bbox, fontsize=None):
|
| 1067 |
+
self.patch.set_bounds(bbox.bounds)
|
| 1068 |
+
if fontsize:
|
| 1069 |
+
self.patch.set_mutation_scale(fontsize)
|
| 1070 |
+
|
| 1071 |
+
def draw(self, renderer):
|
| 1072 |
+
# docstring inherited
|
| 1073 |
+
if not self.get_visible():
|
| 1074 |
+
return
|
| 1075 |
+
|
| 1076 |
+
# update the location and size of the legend
|
| 1077 |
+
bbox = self.get_window_extent(renderer)
|
| 1078 |
+
fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
|
| 1079 |
+
self.update_frame(bbox, fontsize)
|
| 1080 |
+
self.patch.draw(renderer)
|
| 1081 |
+
|
| 1082 |
+
px, py = self.get_offset(self.get_bbox(renderer), renderer)
|
| 1083 |
+
self.get_child().set_offset((px, py))
|
| 1084 |
+
self.get_child().draw(renderer)
|
| 1085 |
+
self.stale = False
|
| 1086 |
+
|
| 1087 |
+
|
| 1088 |
+
def _get_anchored_bbox(loc, bbox, parentbbox, borderpad):
|
| 1089 |
+
"""
|
| 1090 |
+
Return the (x, y) position of the *bbox* anchored at the *parentbbox* with
|
| 1091 |
+
the *loc* code with the *borderpad*.
|
| 1092 |
+
"""
|
| 1093 |
+
# This is only called internally and *loc* should already have been
|
| 1094 |
+
# validated. If 0 (None), we just let ``bbox.anchored`` raise.
|
| 1095 |
+
c = [None, "NE", "NW", "SW", "SE", "E", "W", "E", "S", "N", "C"][loc]
|
| 1096 |
+
container = parentbbox.padded(-borderpad)
|
| 1097 |
+
return bbox.anchored(c, container=container).p0
|
| 1098 |
+
|
| 1099 |
+
|
| 1100 |
+
class AnchoredText(AnchoredOffsetbox):
|
| 1101 |
+
"""
|
| 1102 |
+
AnchoredOffsetbox with Text.
|
| 1103 |
+
"""
|
| 1104 |
+
|
| 1105 |
+
def __init__(self, s, loc, *, pad=0.4, borderpad=0.5, prop=None, **kwargs):
|
| 1106 |
+
"""
|
| 1107 |
+
Parameters
|
| 1108 |
+
----------
|
| 1109 |
+
s : str
|
| 1110 |
+
Text.
|
| 1111 |
+
|
| 1112 |
+
loc : str
|
| 1113 |
+
Location code. See `AnchoredOffsetbox`.
|
| 1114 |
+
|
| 1115 |
+
pad : float, default: 0.4
|
| 1116 |
+
Padding around the text as fraction of the fontsize.
|
| 1117 |
+
|
| 1118 |
+
borderpad : float, default: 0.5
|
| 1119 |
+
Spacing between the offsetbox frame and the *bbox_to_anchor*.
|
| 1120 |
+
|
| 1121 |
+
prop : dict, optional
|
| 1122 |
+
Dictionary of keyword parameters to be passed to the
|
| 1123 |
+
`~matplotlib.text.Text` instance contained inside AnchoredText.
|
| 1124 |
+
|
| 1125 |
+
**kwargs
|
| 1126 |
+
All other parameters are passed to `AnchoredOffsetbox`.
|
| 1127 |
+
"""
|
| 1128 |
+
|
| 1129 |
+
if prop is None:
|
| 1130 |
+
prop = {}
|
| 1131 |
+
badkwargs = {'va', 'verticalalignment'}
|
| 1132 |
+
if badkwargs & set(prop):
|
| 1133 |
+
raise ValueError(
|
| 1134 |
+
'Mixing verticalalignment with AnchoredText is not supported.')
|
| 1135 |
+
|
| 1136 |
+
self.txt = TextArea(s, textprops=prop)
|
| 1137 |
+
fp = self.txt._text.get_fontproperties()
|
| 1138 |
+
super().__init__(
|
| 1139 |
+
loc, pad=pad, borderpad=borderpad, child=self.txt, prop=fp,
|
| 1140 |
+
**kwargs)
|
| 1141 |
+
|
| 1142 |
+
|
| 1143 |
+
class OffsetImage(OffsetBox):
|
| 1144 |
+
|
| 1145 |
+
def __init__(self, arr, *,
|
| 1146 |
+
zoom=1,
|
| 1147 |
+
cmap=None,
|
| 1148 |
+
norm=None,
|
| 1149 |
+
interpolation=None,
|
| 1150 |
+
origin=None,
|
| 1151 |
+
filternorm=True,
|
| 1152 |
+
filterrad=4.0,
|
| 1153 |
+
resample=False,
|
| 1154 |
+
dpi_cor=True,
|
| 1155 |
+
**kwargs
|
| 1156 |
+
):
|
| 1157 |
+
|
| 1158 |
+
super().__init__()
|
| 1159 |
+
self._dpi_cor = dpi_cor
|
| 1160 |
+
|
| 1161 |
+
self.image = BboxImage(bbox=self.get_window_extent,
|
| 1162 |
+
cmap=cmap,
|
| 1163 |
+
norm=norm,
|
| 1164 |
+
interpolation=interpolation,
|
| 1165 |
+
origin=origin,
|
| 1166 |
+
filternorm=filternorm,
|
| 1167 |
+
filterrad=filterrad,
|
| 1168 |
+
resample=resample,
|
| 1169 |
+
**kwargs
|
| 1170 |
+
)
|
| 1171 |
+
|
| 1172 |
+
self._children = [self.image]
|
| 1173 |
+
|
| 1174 |
+
self.set_zoom(zoom)
|
| 1175 |
+
self.set_data(arr)
|
| 1176 |
+
|
| 1177 |
+
def set_data(self, arr):
|
| 1178 |
+
self._data = np.asarray(arr)
|
| 1179 |
+
self.image.set_data(self._data)
|
| 1180 |
+
self.stale = True
|
| 1181 |
+
|
| 1182 |
+
def get_data(self):
|
| 1183 |
+
return self._data
|
| 1184 |
+
|
| 1185 |
+
def set_zoom(self, zoom):
|
| 1186 |
+
self._zoom = zoom
|
| 1187 |
+
self.stale = True
|
| 1188 |
+
|
| 1189 |
+
def get_zoom(self):
|
| 1190 |
+
return self._zoom
|
| 1191 |
+
|
| 1192 |
+
def get_offset(self):
|
| 1193 |
+
"""Return offset of the container."""
|
| 1194 |
+
return self._offset
|
| 1195 |
+
|
| 1196 |
+
def get_children(self):
|
| 1197 |
+
return [self.image]
|
| 1198 |
+
|
| 1199 |
+
def get_bbox(self, renderer):
|
| 1200 |
+
dpi_cor = renderer.points_to_pixels(1.) if self._dpi_cor else 1.
|
| 1201 |
+
zoom = self.get_zoom()
|
| 1202 |
+
data = self.get_data()
|
| 1203 |
+
ny, nx = data.shape[:2]
|
| 1204 |
+
w, h = dpi_cor * nx * zoom, dpi_cor * ny * zoom
|
| 1205 |
+
return Bbox.from_bounds(0, 0, w, h)
|
| 1206 |
+
|
| 1207 |
+
def draw(self, renderer):
|
| 1208 |
+
# docstring inherited
|
| 1209 |
+
self.image.draw(renderer)
|
| 1210 |
+
# bbox_artist(self, renderer, fill=False, props=dict(pad=0.))
|
| 1211 |
+
self.stale = False
|
| 1212 |
+
|
| 1213 |
+
|
| 1214 |
+
class AnnotationBbox(martist.Artist, mtext._AnnotationBase):
|
| 1215 |
+
"""
|
| 1216 |
+
Container for an `OffsetBox` referring to a specific position *xy*.
|
| 1217 |
+
|
| 1218 |
+
Optionally an arrow pointing from the offsetbox to *xy* can be drawn.
|
| 1219 |
+
|
| 1220 |
+
This is like `.Annotation`, but with `OffsetBox` instead of `.Text`.
|
| 1221 |
+
"""
|
| 1222 |
+
|
| 1223 |
+
zorder = 3
|
| 1224 |
+
|
| 1225 |
+
def __str__(self):
|
| 1226 |
+
return f"AnnotationBbox({self.xy[0]:g},{self.xy[1]:g})"
|
| 1227 |
+
|
| 1228 |
+
@_docstring.interpd
|
| 1229 |
+
def __init__(self, offsetbox, xy, xybox=None, xycoords='data', boxcoords=None, *,
|
| 1230 |
+
frameon=True, pad=0.4, # FancyBboxPatch boxstyle.
|
| 1231 |
+
annotation_clip=None,
|
| 1232 |
+
box_alignment=(0.5, 0.5),
|
| 1233 |
+
bboxprops=None,
|
| 1234 |
+
arrowprops=None,
|
| 1235 |
+
fontsize=None,
|
| 1236 |
+
**kwargs):
|
| 1237 |
+
"""
|
| 1238 |
+
Parameters
|
| 1239 |
+
----------
|
| 1240 |
+
offsetbox : `OffsetBox`
|
| 1241 |
+
|
| 1242 |
+
xy : (float, float)
|
| 1243 |
+
The point *(x, y)* to annotate. The coordinate system is determined
|
| 1244 |
+
by *xycoords*.
|
| 1245 |
+
|
| 1246 |
+
xybox : (float, float), default: *xy*
|
| 1247 |
+
The position *(x, y)* to place the text at. The coordinate system
|
| 1248 |
+
is determined by *boxcoords*.
|
| 1249 |
+
|
| 1250 |
+
xycoords : single or two-tuple of str or `.Artist` or `.Transform` or \
|
| 1251 |
+
callable, default: 'data'
|
| 1252 |
+
The coordinate system that *xy* is given in. See the parameter
|
| 1253 |
+
*xycoords* in `.Annotation` for a detailed description.
|
| 1254 |
+
|
| 1255 |
+
boxcoords : single or two-tuple of str or `.Artist` or `.Transform` \
|
| 1256 |
+
or callable, default: value of *xycoords*
|
| 1257 |
+
The coordinate system that *xybox* is given in. See the parameter
|
| 1258 |
+
*textcoords* in `.Annotation` for a detailed description.
|
| 1259 |
+
|
| 1260 |
+
frameon : bool, default: True
|
| 1261 |
+
By default, the text is surrounded by a white `.FancyBboxPatch`
|
| 1262 |
+
(accessible as the ``patch`` attribute of the `.AnnotationBbox`).
|
| 1263 |
+
If *frameon* is set to False, this patch is made invisible.
|
| 1264 |
+
|
| 1265 |
+
annotation_clip: bool or None, default: None
|
| 1266 |
+
Whether to clip (i.e. not draw) the annotation when the annotation
|
| 1267 |
+
point *xy* is outside the Axes area.
|
| 1268 |
+
|
| 1269 |
+
- If *True*, the annotation will be clipped when *xy* is outside
|
| 1270 |
+
the Axes.
|
| 1271 |
+
- If *False*, the annotation will always be drawn.
|
| 1272 |
+
- If *None*, the annotation will be clipped when *xy* is outside
|
| 1273 |
+
the Axes and *xycoords* is 'data'.
|
| 1274 |
+
|
| 1275 |
+
pad : float, default: 0.4
|
| 1276 |
+
Padding around the offsetbox.
|
| 1277 |
+
|
| 1278 |
+
box_alignment : (float, float)
|
| 1279 |
+
A tuple of two floats for a vertical and horizontal alignment of
|
| 1280 |
+
the offset box w.r.t. the *boxcoords*.
|
| 1281 |
+
The lower-left corner is (0, 0) and upper-right corner is (1, 1).
|
| 1282 |
+
|
| 1283 |
+
bboxprops : dict, optional
|
| 1284 |
+
A dictionary of properties to set for the annotation bounding box,
|
| 1285 |
+
for example *boxstyle* and *alpha*. See `.FancyBboxPatch` for
|
| 1286 |
+
details.
|
| 1287 |
+
|
| 1288 |
+
arrowprops: dict, optional
|
| 1289 |
+
Arrow properties, see `.Annotation` for description.
|
| 1290 |
+
|
| 1291 |
+
fontsize: float or str, optional
|
| 1292 |
+
Translated to points and passed as *mutation_scale* into
|
| 1293 |
+
`.FancyBboxPatch` to scale attributes of the box style (e.g. pad
|
| 1294 |
+
or rounding_size). The name is chosen in analogy to `.Text` where
|
| 1295 |
+
*fontsize* defines the mutation scale as well. If not given,
|
| 1296 |
+
:rc:`legend.fontsize` is used. See `.Text.set_fontsize` for valid
|
| 1297 |
+
values.
|
| 1298 |
+
|
| 1299 |
+
**kwargs
|
| 1300 |
+
Other `AnnotationBbox` properties. See `.AnnotationBbox.set` for
|
| 1301 |
+
a list.
|
| 1302 |
+
"""
|
| 1303 |
+
|
| 1304 |
+
martist.Artist.__init__(self)
|
| 1305 |
+
mtext._AnnotationBase.__init__(
|
| 1306 |
+
self, xy, xycoords=xycoords, annotation_clip=annotation_clip)
|
| 1307 |
+
|
| 1308 |
+
self.offsetbox = offsetbox
|
| 1309 |
+
self.arrowprops = arrowprops.copy() if arrowprops is not None else None
|
| 1310 |
+
self.set_fontsize(fontsize)
|
| 1311 |
+
self.xybox = xybox if xybox is not None else xy
|
| 1312 |
+
self.boxcoords = boxcoords if boxcoords is not None else xycoords
|
| 1313 |
+
self._box_alignment = box_alignment
|
| 1314 |
+
|
| 1315 |
+
if arrowprops is not None:
|
| 1316 |
+
self._arrow_relpos = self.arrowprops.pop("relpos", (0.5, 0.5))
|
| 1317 |
+
self.arrow_patch = FancyArrowPatch((0, 0), (1, 1),
|
| 1318 |
+
**self.arrowprops)
|
| 1319 |
+
else:
|
| 1320 |
+
self._arrow_relpos = None
|
| 1321 |
+
self.arrow_patch = None
|
| 1322 |
+
|
| 1323 |
+
self.patch = FancyBboxPatch( # frame
|
| 1324 |
+
xy=(0.0, 0.0), width=1., height=1.,
|
| 1325 |
+
facecolor='w', edgecolor='k',
|
| 1326 |
+
mutation_scale=self.prop.get_size_in_points(),
|
| 1327 |
+
snap=True,
|
| 1328 |
+
visible=frameon,
|
| 1329 |
+
)
|
| 1330 |
+
self.patch.set_boxstyle("square", pad=pad)
|
| 1331 |
+
if bboxprops:
|
| 1332 |
+
self.patch.set(**bboxprops)
|
| 1333 |
+
|
| 1334 |
+
self._internal_update(kwargs)
|
| 1335 |
+
|
| 1336 |
+
@property
|
| 1337 |
+
def xyann(self):
|
| 1338 |
+
return self.xybox
|
| 1339 |
+
|
| 1340 |
+
@xyann.setter
|
| 1341 |
+
def xyann(self, xyann):
|
| 1342 |
+
self.xybox = xyann
|
| 1343 |
+
self.stale = True
|
| 1344 |
+
|
| 1345 |
+
@property
|
| 1346 |
+
def anncoords(self):
|
| 1347 |
+
return self.boxcoords
|
| 1348 |
+
|
| 1349 |
+
@anncoords.setter
|
| 1350 |
+
def anncoords(self, coords):
|
| 1351 |
+
self.boxcoords = coords
|
| 1352 |
+
self.stale = True
|
| 1353 |
+
|
| 1354 |
+
def contains(self, mouseevent):
|
| 1355 |
+
if self._different_canvas(mouseevent):
|
| 1356 |
+
return False, {}
|
| 1357 |
+
if not self._check_xy(None):
|
| 1358 |
+
return False, {}
|
| 1359 |
+
return self.offsetbox.contains(mouseevent)
|
| 1360 |
+
# self.arrow_patch is currently not checked as this can be a line - JJ
|
| 1361 |
+
|
| 1362 |
+
def get_children(self):
|
| 1363 |
+
children = [self.offsetbox, self.patch]
|
| 1364 |
+
if self.arrow_patch:
|
| 1365 |
+
children.append(self.arrow_patch)
|
| 1366 |
+
return children
|
| 1367 |
+
|
| 1368 |
+
def set_figure(self, fig):
|
| 1369 |
+
if self.arrow_patch is not None:
|
| 1370 |
+
self.arrow_patch.set_figure(fig)
|
| 1371 |
+
self.offsetbox.set_figure(fig)
|
| 1372 |
+
martist.Artist.set_figure(self, fig)
|
| 1373 |
+
|
| 1374 |
+
def set_fontsize(self, s=None):
|
| 1375 |
+
"""
|
| 1376 |
+
Set the fontsize in points.
|
| 1377 |
+
|
| 1378 |
+
If *s* is not given, reset to :rc:`legend.fontsize`.
|
| 1379 |
+
"""
|
| 1380 |
+
if s is None:
|
| 1381 |
+
s = mpl.rcParams["legend.fontsize"]
|
| 1382 |
+
|
| 1383 |
+
self.prop = FontProperties(size=s)
|
| 1384 |
+
self.stale = True
|
| 1385 |
+
|
| 1386 |
+
def get_fontsize(self):
|
| 1387 |
+
"""Return the fontsize in points."""
|
| 1388 |
+
return self.prop.get_size_in_points()
|
| 1389 |
+
|
| 1390 |
+
def get_window_extent(self, renderer=None):
|
| 1391 |
+
# docstring inherited
|
| 1392 |
+
if renderer is None:
|
| 1393 |
+
renderer = self.get_figure(root=True)._get_renderer()
|
| 1394 |
+
self.update_positions(renderer)
|
| 1395 |
+
return Bbox.union([child.get_window_extent(renderer)
|
| 1396 |
+
for child in self.get_children()])
|
| 1397 |
+
|
| 1398 |
+
def get_tightbbox(self, renderer=None):
|
| 1399 |
+
# docstring inherited
|
| 1400 |
+
if renderer is None:
|
| 1401 |
+
renderer = self.get_figure(root=True)._get_renderer()
|
| 1402 |
+
self.update_positions(renderer)
|
| 1403 |
+
return Bbox.union([child.get_tightbbox(renderer)
|
| 1404 |
+
for child in self.get_children()])
|
| 1405 |
+
|
| 1406 |
+
def update_positions(self, renderer):
|
| 1407 |
+
"""Update pixel positions for the annotated point, the text, and the arrow."""
|
| 1408 |
+
|
| 1409 |
+
ox0, oy0 = self._get_xy(renderer, self.xybox, self.boxcoords)
|
| 1410 |
+
bbox = self.offsetbox.get_bbox(renderer)
|
| 1411 |
+
fw, fh = self._box_alignment
|
| 1412 |
+
self.offsetbox.set_offset(
|
| 1413 |
+
(ox0 - fw*bbox.width - bbox.x0, oy0 - fh*bbox.height - bbox.y0))
|
| 1414 |
+
|
| 1415 |
+
bbox = self.offsetbox.get_window_extent(renderer)
|
| 1416 |
+
self.patch.set_bounds(bbox.bounds)
|
| 1417 |
+
|
| 1418 |
+
mutation_scale = renderer.points_to_pixels(self.get_fontsize())
|
| 1419 |
+
self.patch.set_mutation_scale(mutation_scale)
|
| 1420 |
+
|
| 1421 |
+
if self.arrowprops:
|
| 1422 |
+
# Use FancyArrowPatch if self.arrowprops has "arrowstyle" key.
|
| 1423 |
+
|
| 1424 |
+
# Adjust the starting point of the arrow relative to the textbox.
|
| 1425 |
+
# TODO: Rotation needs to be accounted.
|
| 1426 |
+
arrow_begin = bbox.p0 + bbox.size * self._arrow_relpos
|
| 1427 |
+
arrow_end = self._get_position_xy(renderer)
|
| 1428 |
+
# The arrow (from arrow_begin to arrow_end) will be first clipped
|
| 1429 |
+
# by patchA and patchB, then shrunk by shrinkA and shrinkB (in
|
| 1430 |
+
# points). If patch A is not set, self.bbox_patch is used.
|
| 1431 |
+
self.arrow_patch.set_positions(arrow_begin, arrow_end)
|
| 1432 |
+
|
| 1433 |
+
if "mutation_scale" in self.arrowprops:
|
| 1434 |
+
mutation_scale = renderer.points_to_pixels(
|
| 1435 |
+
self.arrowprops["mutation_scale"])
|
| 1436 |
+
# Else, use fontsize-based mutation_scale defined above.
|
| 1437 |
+
self.arrow_patch.set_mutation_scale(mutation_scale)
|
| 1438 |
+
|
| 1439 |
+
patchA = self.arrowprops.get("patchA", self.patch)
|
| 1440 |
+
self.arrow_patch.set_patchA(patchA)
|
| 1441 |
+
|
| 1442 |
+
def draw(self, renderer):
|
| 1443 |
+
# docstring inherited
|
| 1444 |
+
if not self.get_visible() or not self._check_xy(renderer):
|
| 1445 |
+
return
|
| 1446 |
+
renderer.open_group(self.__class__.__name__, gid=self.get_gid())
|
| 1447 |
+
self.update_positions(renderer)
|
| 1448 |
+
if self.arrow_patch is not None:
|
| 1449 |
+
if (self.arrow_patch.get_figure(root=False) is None and
|
| 1450 |
+
(fig := self.get_figure(root=False)) is not None):
|
| 1451 |
+
self.arrow_patch.set_figure(fig)
|
| 1452 |
+
self.arrow_patch.draw(renderer)
|
| 1453 |
+
self.patch.draw(renderer)
|
| 1454 |
+
self.offsetbox.draw(renderer)
|
| 1455 |
+
renderer.close_group(self.__class__.__name__)
|
| 1456 |
+
self.stale = False
|
| 1457 |
+
|
| 1458 |
+
|
| 1459 |
+
class DraggableBase:
|
| 1460 |
+
"""
|
| 1461 |
+
Helper base class for a draggable artist (legend, offsetbox).
|
| 1462 |
+
|
| 1463 |
+
Derived classes must override the following methods::
|
| 1464 |
+
|
| 1465 |
+
def save_offset(self):
|
| 1466 |
+
'''
|
| 1467 |
+
Called when the object is picked for dragging; should save the
|
| 1468 |
+
reference position of the artist.
|
| 1469 |
+
'''
|
| 1470 |
+
|
| 1471 |
+
def update_offset(self, dx, dy):
|
| 1472 |
+
'''
|
| 1473 |
+
Called during the dragging; (*dx*, *dy*) is the pixel offset from
|
| 1474 |
+
the point where the mouse drag started.
|
| 1475 |
+
'''
|
| 1476 |
+
|
| 1477 |
+
Optionally, you may override the following method::
|
| 1478 |
+
|
| 1479 |
+
def finalize_offset(self):
|
| 1480 |
+
'''Called when the mouse is released.'''
|
| 1481 |
+
|
| 1482 |
+
In the current implementation of `.DraggableLegend` and
|
| 1483 |
+
`DraggableAnnotation`, `update_offset` places the artists in display
|
| 1484 |
+
coordinates, and `finalize_offset` recalculates their position in axes
|
| 1485 |
+
coordinate and set a relevant attribute.
|
| 1486 |
+
"""
|
| 1487 |
+
|
| 1488 |
+
def __init__(self, ref_artist, use_blit=False):
|
| 1489 |
+
self.ref_artist = ref_artist
|
| 1490 |
+
if not ref_artist.pickable():
|
| 1491 |
+
ref_artist.set_picker(True)
|
| 1492 |
+
self.got_artist = False
|
| 1493 |
+
self._use_blit = use_blit and self.canvas.supports_blit
|
| 1494 |
+
callbacks = self.canvas.callbacks
|
| 1495 |
+
self._disconnectors = [
|
| 1496 |
+
functools.partial(
|
| 1497 |
+
callbacks.disconnect, callbacks._connect_picklable(name, func))
|
| 1498 |
+
for name, func in [
|
| 1499 |
+
("pick_event", self.on_pick),
|
| 1500 |
+
("button_release_event", self.on_release),
|
| 1501 |
+
("motion_notify_event", self.on_motion),
|
| 1502 |
+
]
|
| 1503 |
+
]
|
| 1504 |
+
|
| 1505 |
+
# A property, not an attribute, to maintain picklability.
|
| 1506 |
+
canvas = property(lambda self: self.ref_artist.get_figure(root=True).canvas)
|
| 1507 |
+
cids = property(lambda self: [
|
| 1508 |
+
disconnect.args[0] for disconnect in self._disconnectors[:2]])
|
| 1509 |
+
|
| 1510 |
+
def on_motion(self, evt):
|
| 1511 |
+
if self._check_still_parented() and self.got_artist:
|
| 1512 |
+
dx = evt.x - self.mouse_x
|
| 1513 |
+
dy = evt.y - self.mouse_y
|
| 1514 |
+
self.update_offset(dx, dy)
|
| 1515 |
+
if self._use_blit:
|
| 1516 |
+
self.canvas.restore_region(self.background)
|
| 1517 |
+
self.ref_artist.draw(
|
| 1518 |
+
self.ref_artist.get_figure(root=True)._get_renderer())
|
| 1519 |
+
self.canvas.blit()
|
| 1520 |
+
else:
|
| 1521 |
+
self.canvas.draw()
|
| 1522 |
+
|
| 1523 |
+
def on_pick(self, evt):
|
| 1524 |
+
if self._check_still_parented():
|
| 1525 |
+
if evt.artist == self.ref_artist:
|
| 1526 |
+
self.mouse_x = evt.mouseevent.x
|
| 1527 |
+
self.mouse_y = evt.mouseevent.y
|
| 1528 |
+
self.save_offset()
|
| 1529 |
+
self.got_artist = True
|
| 1530 |
+
if self.got_artist and self._use_blit:
|
| 1531 |
+
self.ref_artist.set_animated(True)
|
| 1532 |
+
self.canvas.draw()
|
| 1533 |
+
fig = self.ref_artist.get_figure(root=False)
|
| 1534 |
+
self.background = self.canvas.copy_from_bbox(fig.bbox)
|
| 1535 |
+
self.ref_artist.draw(fig._get_renderer())
|
| 1536 |
+
self.canvas.blit()
|
| 1537 |
+
|
| 1538 |
+
def on_release(self, event):
|
| 1539 |
+
if self._check_still_parented() and self.got_artist:
|
| 1540 |
+
self.finalize_offset()
|
| 1541 |
+
self.got_artist = False
|
| 1542 |
+
if self._use_blit:
|
| 1543 |
+
self.canvas.restore_region(self.background)
|
| 1544 |
+
self.ref_artist.draw(self.ref_artist.figure._get_renderer())
|
| 1545 |
+
self.canvas.blit()
|
| 1546 |
+
self.ref_artist.set_animated(False)
|
| 1547 |
+
|
| 1548 |
+
def _check_still_parented(self):
|
| 1549 |
+
if self.ref_artist.get_figure(root=False) is None:
|
| 1550 |
+
self.disconnect()
|
| 1551 |
+
return False
|
| 1552 |
+
else:
|
| 1553 |
+
return True
|
| 1554 |
+
|
| 1555 |
+
def disconnect(self):
|
| 1556 |
+
"""Disconnect the callbacks."""
|
| 1557 |
+
for disconnector in self._disconnectors:
|
| 1558 |
+
disconnector()
|
| 1559 |
+
|
| 1560 |
+
def save_offset(self):
|
| 1561 |
+
pass
|
| 1562 |
+
|
| 1563 |
+
def update_offset(self, dx, dy):
|
| 1564 |
+
pass
|
| 1565 |
+
|
| 1566 |
+
def finalize_offset(self):
|
| 1567 |
+
pass
|
| 1568 |
+
|
| 1569 |
+
|
| 1570 |
+
class DraggableOffsetBox(DraggableBase):
|
| 1571 |
+
def __init__(self, ref_artist, offsetbox, use_blit=False):
|
| 1572 |
+
super().__init__(ref_artist, use_blit=use_blit)
|
| 1573 |
+
self.offsetbox = offsetbox
|
| 1574 |
+
|
| 1575 |
+
def save_offset(self):
|
| 1576 |
+
offsetbox = self.offsetbox
|
| 1577 |
+
renderer = offsetbox.get_figure(root=True)._get_renderer()
|
| 1578 |
+
offset = offsetbox.get_offset(offsetbox.get_bbox(renderer), renderer)
|
| 1579 |
+
self.offsetbox_x, self.offsetbox_y = offset
|
| 1580 |
+
self.offsetbox.set_offset(offset)
|
| 1581 |
+
|
| 1582 |
+
def update_offset(self, dx, dy):
|
| 1583 |
+
loc_in_canvas = self.offsetbox_x + dx, self.offsetbox_y + dy
|
| 1584 |
+
self.offsetbox.set_offset(loc_in_canvas)
|
| 1585 |
+
|
| 1586 |
+
def get_loc_in_canvas(self):
|
| 1587 |
+
offsetbox = self.offsetbox
|
| 1588 |
+
renderer = offsetbox.get_figure(root=True)._get_renderer()
|
| 1589 |
+
bbox = offsetbox.get_bbox(renderer)
|
| 1590 |
+
ox, oy = offsetbox._offset
|
| 1591 |
+
loc_in_canvas = (ox + bbox.x0, oy + bbox.y0)
|
| 1592 |
+
return loc_in_canvas
|
| 1593 |
+
|
| 1594 |
+
|
| 1595 |
+
class DraggableAnnotation(DraggableBase):
|
| 1596 |
+
def __init__(self, annotation, use_blit=False):
|
| 1597 |
+
super().__init__(annotation, use_blit=use_blit)
|
| 1598 |
+
self.annotation = annotation
|
| 1599 |
+
|
| 1600 |
+
def save_offset(self):
|
| 1601 |
+
ann = self.annotation
|
| 1602 |
+
self.ox, self.oy = ann.get_transform().transform(ann.xyann)
|
| 1603 |
+
|
| 1604 |
+
def update_offset(self, dx, dy):
|
| 1605 |
+
ann = self.annotation
|
| 1606 |
+
ann.xyann = ann.get_transform().inverted().transform(
|
| 1607 |
+
(self.ox + dx, self.oy + dy))
|
infer_4_30_0/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: ...
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/patheffects.py
ADDED
|
@@ -0,0 +1,511 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Defines classes for path effects. The path effects are supported in `.Text`,
|
| 3 |
+
`.Line2D` and `.Patch`.
|
| 4 |
+
|
| 5 |
+
.. seealso::
|
| 6 |
+
:ref:`patheffects_guide`
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
from matplotlib.backend_bases import RendererBase
|
| 10 |
+
from matplotlib import colors as mcolors
|
| 11 |
+
from matplotlib import patches as mpatches
|
| 12 |
+
from matplotlib import transforms as mtransforms
|
| 13 |
+
from matplotlib.path import Path
|
| 14 |
+
import numpy as np
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
class AbstractPathEffect:
|
| 18 |
+
"""
|
| 19 |
+
A base class for path effects.
|
| 20 |
+
|
| 21 |
+
Subclasses should override the ``draw_path`` method to add effect
|
| 22 |
+
functionality.
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
def __init__(self, offset=(0., 0.)):
|
| 26 |
+
"""
|
| 27 |
+
Parameters
|
| 28 |
+
----------
|
| 29 |
+
offset : (float, float), default: (0, 0)
|
| 30 |
+
The (x, y) offset to apply to the path, measured in points.
|
| 31 |
+
"""
|
| 32 |
+
self._offset = offset
|
| 33 |
+
|
| 34 |
+
def _offset_transform(self, renderer):
|
| 35 |
+
"""Apply the offset to the given transform."""
|
| 36 |
+
return mtransforms.Affine2D().translate(
|
| 37 |
+
*map(renderer.points_to_pixels, self._offset))
|
| 38 |
+
|
| 39 |
+
def _update_gc(self, gc, new_gc_dict):
|
| 40 |
+
"""
|
| 41 |
+
Update the given GraphicsContext with the given dict of properties.
|
| 42 |
+
|
| 43 |
+
The keys in the dictionary are used to identify the appropriate
|
| 44 |
+
``set_`` method on the *gc*.
|
| 45 |
+
"""
|
| 46 |
+
new_gc_dict = new_gc_dict.copy()
|
| 47 |
+
|
| 48 |
+
dashes = new_gc_dict.pop("dashes", None)
|
| 49 |
+
if dashes:
|
| 50 |
+
gc.set_dashes(**dashes)
|
| 51 |
+
|
| 52 |
+
for k, v in new_gc_dict.items():
|
| 53 |
+
set_method = getattr(gc, 'set_' + k, None)
|
| 54 |
+
if not callable(set_method):
|
| 55 |
+
raise AttributeError(f'Unknown property {k}')
|
| 56 |
+
set_method(v)
|
| 57 |
+
return gc
|
| 58 |
+
|
| 59 |
+
def draw_path(self, renderer, gc, tpath, affine, rgbFace=None):
|
| 60 |
+
"""
|
| 61 |
+
Derived should override this method. The arguments are the same
|
| 62 |
+
as :meth:`matplotlib.backend_bases.RendererBase.draw_path`
|
| 63 |
+
except the first argument is a renderer.
|
| 64 |
+
"""
|
| 65 |
+
# Get the real renderer, not a PathEffectRenderer.
|
| 66 |
+
if isinstance(renderer, PathEffectRenderer):
|
| 67 |
+
renderer = renderer._renderer
|
| 68 |
+
return renderer.draw_path(gc, tpath, affine, rgbFace)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
class PathEffectRenderer(RendererBase):
|
| 72 |
+
"""
|
| 73 |
+
Implements a Renderer which contains another renderer.
|
| 74 |
+
|
| 75 |
+
This proxy then intercepts draw calls, calling the appropriate
|
| 76 |
+
:class:`AbstractPathEffect` draw method.
|
| 77 |
+
|
| 78 |
+
.. note::
|
| 79 |
+
Not all methods have been overridden on this RendererBase subclass.
|
| 80 |
+
It may be necessary to add further methods to extend the PathEffects
|
| 81 |
+
capabilities further.
|
| 82 |
+
"""
|
| 83 |
+
|
| 84 |
+
def __init__(self, path_effects, renderer):
|
| 85 |
+
"""
|
| 86 |
+
Parameters
|
| 87 |
+
----------
|
| 88 |
+
path_effects : iterable of :class:`AbstractPathEffect`
|
| 89 |
+
The path effects which this renderer represents.
|
| 90 |
+
renderer : `~matplotlib.backend_bases.RendererBase` subclass
|
| 91 |
+
|
| 92 |
+
"""
|
| 93 |
+
self._path_effects = path_effects
|
| 94 |
+
self._renderer = renderer
|
| 95 |
+
|
| 96 |
+
def copy_with_path_effect(self, path_effects):
|
| 97 |
+
return self.__class__(path_effects, self._renderer)
|
| 98 |
+
|
| 99 |
+
def __getattribute__(self, name):
|
| 100 |
+
if name in ['flipy', 'get_canvas_width_height', 'new_gc',
|
| 101 |
+
'points_to_pixels', '_text2path', 'height', 'width']:
|
| 102 |
+
return getattr(self._renderer, name)
|
| 103 |
+
else:
|
| 104 |
+
return object.__getattribute__(self, name)
|
| 105 |
+
|
| 106 |
+
def draw_path(self, gc, tpath, affine, rgbFace=None):
|
| 107 |
+
for path_effect in self._path_effects:
|
| 108 |
+
path_effect.draw_path(self._renderer, gc, tpath, affine,
|
| 109 |
+
rgbFace)
|
| 110 |
+
|
| 111 |
+
def draw_markers(
|
| 112 |
+
self, gc, marker_path, marker_trans, path, *args, **kwargs):
|
| 113 |
+
# We do a little shimmy so that all markers are drawn for each path
|
| 114 |
+
# effect in turn. Essentially, we induce recursion (depth 1) which is
|
| 115 |
+
# terminated once we have just a single path effect to work with.
|
| 116 |
+
if len(self._path_effects) == 1:
|
| 117 |
+
# Call the base path effect function - this uses the unoptimised
|
| 118 |
+
# approach of calling "draw_path" multiple times.
|
| 119 |
+
return super().draw_markers(gc, marker_path, marker_trans, path,
|
| 120 |
+
*args, **kwargs)
|
| 121 |
+
|
| 122 |
+
for path_effect in self._path_effects:
|
| 123 |
+
renderer = self.copy_with_path_effect([path_effect])
|
| 124 |
+
# Recursively call this method, only next time we will only have
|
| 125 |
+
# one path effect.
|
| 126 |
+
renderer.draw_markers(gc, marker_path, marker_trans, path,
|
| 127 |
+
*args, **kwargs)
|
| 128 |
+
|
| 129 |
+
def draw_path_collection(self, gc, master_transform, paths, *args,
|
| 130 |
+
**kwargs):
|
| 131 |
+
# We do a little shimmy so that all paths are drawn for each path
|
| 132 |
+
# effect in turn. Essentially, we induce recursion (depth 1) which is
|
| 133 |
+
# terminated once we have just a single path effect to work with.
|
| 134 |
+
if len(self._path_effects) == 1:
|
| 135 |
+
# Call the base path effect function - this uses the unoptimised
|
| 136 |
+
# approach of calling "draw_path" multiple times.
|
| 137 |
+
return super().draw_path_collection(gc, master_transform, paths,
|
| 138 |
+
*args, **kwargs)
|
| 139 |
+
|
| 140 |
+
for path_effect in self._path_effects:
|
| 141 |
+
renderer = self.copy_with_path_effect([path_effect])
|
| 142 |
+
# Recursively call this method, only next time we will only have
|
| 143 |
+
# one path effect.
|
| 144 |
+
renderer.draw_path_collection(gc, master_transform, paths,
|
| 145 |
+
*args, **kwargs)
|
| 146 |
+
|
| 147 |
+
def open_group(self, s, gid=None):
|
| 148 |
+
return self._renderer.open_group(s, gid)
|
| 149 |
+
|
| 150 |
+
def close_group(self, s):
|
| 151 |
+
return self._renderer.close_group(s)
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
class Normal(AbstractPathEffect):
|
| 155 |
+
"""
|
| 156 |
+
The "identity" PathEffect.
|
| 157 |
+
|
| 158 |
+
The Normal PathEffect's sole purpose is to draw the original artist with
|
| 159 |
+
no special path effect.
|
| 160 |
+
"""
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def _subclass_with_normal(effect_class):
|
| 164 |
+
"""
|
| 165 |
+
Create a PathEffect class combining *effect_class* and a normal draw.
|
| 166 |
+
"""
|
| 167 |
+
|
| 168 |
+
class withEffect(effect_class):
|
| 169 |
+
def draw_path(self, renderer, gc, tpath, affine, rgbFace):
|
| 170 |
+
super().draw_path(renderer, gc, tpath, affine, rgbFace)
|
| 171 |
+
renderer.draw_path(gc, tpath, affine, rgbFace)
|
| 172 |
+
|
| 173 |
+
withEffect.__name__ = f"with{effect_class.__name__}"
|
| 174 |
+
withEffect.__qualname__ = f"with{effect_class.__name__}"
|
| 175 |
+
withEffect.__doc__ = f"""
|
| 176 |
+
A shortcut PathEffect for applying `.{effect_class.__name__}` and then
|
| 177 |
+
drawing the original Artist.
|
| 178 |
+
|
| 179 |
+
With this class you can use ::
|
| 180 |
+
|
| 181 |
+
artist.set_path_effects([patheffects.with{effect_class.__name__}()])
|
| 182 |
+
|
| 183 |
+
as a shortcut for ::
|
| 184 |
+
|
| 185 |
+
artist.set_path_effects([patheffects.{effect_class.__name__}(),
|
| 186 |
+
patheffects.Normal()])
|
| 187 |
+
"""
|
| 188 |
+
# Docstring inheritance doesn't work for locally-defined subclasses.
|
| 189 |
+
withEffect.draw_path.__doc__ = effect_class.draw_path.__doc__
|
| 190 |
+
return withEffect
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
class Stroke(AbstractPathEffect):
|
| 194 |
+
"""A line based PathEffect which re-draws a stroke."""
|
| 195 |
+
|
| 196 |
+
def __init__(self, offset=(0, 0), **kwargs):
|
| 197 |
+
"""
|
| 198 |
+
The path will be stroked with its gc updated with the given
|
| 199 |
+
keyword arguments, i.e., the keyword arguments should be valid
|
| 200 |
+
gc parameter values.
|
| 201 |
+
"""
|
| 202 |
+
super().__init__(offset)
|
| 203 |
+
self._gc = kwargs
|
| 204 |
+
|
| 205 |
+
def draw_path(self, renderer, gc, tpath, affine, rgbFace):
|
| 206 |
+
"""Draw the path with updated gc."""
|
| 207 |
+
gc0 = renderer.new_gc() # Don't modify gc, but a copy!
|
| 208 |
+
gc0.copy_properties(gc)
|
| 209 |
+
gc0 = self._update_gc(gc0, self._gc)
|
| 210 |
+
renderer.draw_path(
|
| 211 |
+
gc0, tpath, affine + self._offset_transform(renderer), rgbFace)
|
| 212 |
+
gc0.restore()
|
| 213 |
+
|
| 214 |
+
|
| 215 |
+
withStroke = _subclass_with_normal(effect_class=Stroke)
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
class SimplePatchShadow(AbstractPathEffect):
|
| 219 |
+
"""A simple shadow via a filled patch."""
|
| 220 |
+
|
| 221 |
+
def __init__(self, offset=(2, -2),
|
| 222 |
+
shadow_rgbFace=None, alpha=None,
|
| 223 |
+
rho=0.3, **kwargs):
|
| 224 |
+
"""
|
| 225 |
+
Parameters
|
| 226 |
+
----------
|
| 227 |
+
offset : (float, float), default: (2, -2)
|
| 228 |
+
The (x, y) offset of the shadow in points.
|
| 229 |
+
shadow_rgbFace : :mpltype:`color`
|
| 230 |
+
The shadow color.
|
| 231 |
+
alpha : float, default: 0.3
|
| 232 |
+
The alpha transparency of the created shadow patch.
|
| 233 |
+
rho : float, default: 0.3
|
| 234 |
+
A scale factor to apply to the rgbFace color if *shadow_rgbFace*
|
| 235 |
+
is not specified.
|
| 236 |
+
**kwargs
|
| 237 |
+
Extra keywords are stored and passed through to
|
| 238 |
+
:meth:`AbstractPathEffect._update_gc`.
|
| 239 |
+
|
| 240 |
+
"""
|
| 241 |
+
super().__init__(offset)
|
| 242 |
+
|
| 243 |
+
if shadow_rgbFace is None:
|
| 244 |
+
self._shadow_rgbFace = shadow_rgbFace
|
| 245 |
+
else:
|
| 246 |
+
self._shadow_rgbFace = mcolors.to_rgba(shadow_rgbFace)
|
| 247 |
+
|
| 248 |
+
if alpha is None:
|
| 249 |
+
alpha = 0.3
|
| 250 |
+
|
| 251 |
+
self._alpha = alpha
|
| 252 |
+
self._rho = rho
|
| 253 |
+
|
| 254 |
+
#: The dictionary of keywords to update the graphics collection with.
|
| 255 |
+
self._gc = kwargs
|
| 256 |
+
|
| 257 |
+
def draw_path(self, renderer, gc, tpath, affine, rgbFace):
|
| 258 |
+
"""
|
| 259 |
+
Overrides the standard draw_path to add the shadow offset and
|
| 260 |
+
necessary color changes for the shadow.
|
| 261 |
+
"""
|
| 262 |
+
gc0 = renderer.new_gc() # Don't modify gc, but a copy!
|
| 263 |
+
gc0.copy_properties(gc)
|
| 264 |
+
|
| 265 |
+
if self._shadow_rgbFace is None:
|
| 266 |
+
r, g, b = (rgbFace or (1., 1., 1.))[:3]
|
| 267 |
+
# Scale the colors by a factor to improve the shadow effect.
|
| 268 |
+
shadow_rgbFace = (r * self._rho, g * self._rho, b * self._rho)
|
| 269 |
+
else:
|
| 270 |
+
shadow_rgbFace = self._shadow_rgbFace
|
| 271 |
+
|
| 272 |
+
gc0.set_foreground("none")
|
| 273 |
+
gc0.set_alpha(self._alpha)
|
| 274 |
+
gc0.set_linewidth(0)
|
| 275 |
+
|
| 276 |
+
gc0 = self._update_gc(gc0, self._gc)
|
| 277 |
+
renderer.draw_path(
|
| 278 |
+
gc0, tpath, affine + self._offset_transform(renderer),
|
| 279 |
+
shadow_rgbFace)
|
| 280 |
+
gc0.restore()
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
withSimplePatchShadow = _subclass_with_normal(effect_class=SimplePatchShadow)
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
class SimpleLineShadow(AbstractPathEffect):
|
| 287 |
+
"""A simple shadow via a line."""
|
| 288 |
+
|
| 289 |
+
def __init__(self, offset=(2, -2),
|
| 290 |
+
shadow_color='k', alpha=0.3, rho=0.3, **kwargs):
|
| 291 |
+
"""
|
| 292 |
+
Parameters
|
| 293 |
+
----------
|
| 294 |
+
offset : (float, float), default: (2, -2)
|
| 295 |
+
The (x, y) offset to apply to the path, in points.
|
| 296 |
+
shadow_color : :mpltype:`color`, default: 'black'
|
| 297 |
+
The shadow color.
|
| 298 |
+
A value of ``None`` takes the original artist's color
|
| 299 |
+
with a scale factor of *rho*.
|
| 300 |
+
alpha : float, default: 0.3
|
| 301 |
+
The alpha transparency of the created shadow patch.
|
| 302 |
+
rho : float, default: 0.3
|
| 303 |
+
A scale factor to apply to the rgbFace color if *shadow_color*
|
| 304 |
+
is ``None``.
|
| 305 |
+
**kwargs
|
| 306 |
+
Extra keywords are stored and passed through to
|
| 307 |
+
:meth:`AbstractPathEffect._update_gc`.
|
| 308 |
+
"""
|
| 309 |
+
super().__init__(offset)
|
| 310 |
+
if shadow_color is None:
|
| 311 |
+
self._shadow_color = shadow_color
|
| 312 |
+
else:
|
| 313 |
+
self._shadow_color = mcolors.to_rgba(shadow_color)
|
| 314 |
+
self._alpha = alpha
|
| 315 |
+
self._rho = rho
|
| 316 |
+
#: The dictionary of keywords to update the graphics collection with.
|
| 317 |
+
self._gc = kwargs
|
| 318 |
+
|
| 319 |
+
def draw_path(self, renderer, gc, tpath, affine, rgbFace):
|
| 320 |
+
"""
|
| 321 |
+
Overrides the standard draw_path to add the shadow offset and
|
| 322 |
+
necessary color changes for the shadow.
|
| 323 |
+
"""
|
| 324 |
+
gc0 = renderer.new_gc() # Don't modify gc, but a copy!
|
| 325 |
+
gc0.copy_properties(gc)
|
| 326 |
+
|
| 327 |
+
if self._shadow_color is None:
|
| 328 |
+
r, g, b = (gc0.get_foreground() or (1., 1., 1.))[:3]
|
| 329 |
+
# Scale the colors by a factor to improve the shadow effect.
|
| 330 |
+
shadow_rgbFace = (r * self._rho, g * self._rho, b * self._rho)
|
| 331 |
+
else:
|
| 332 |
+
shadow_rgbFace = self._shadow_color
|
| 333 |
+
|
| 334 |
+
gc0.set_foreground(shadow_rgbFace)
|
| 335 |
+
gc0.set_alpha(self._alpha)
|
| 336 |
+
|
| 337 |
+
gc0 = self._update_gc(gc0, self._gc)
|
| 338 |
+
renderer.draw_path(
|
| 339 |
+
gc0, tpath, affine + self._offset_transform(renderer))
|
| 340 |
+
gc0.restore()
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
class PathPatchEffect(AbstractPathEffect):
|
| 344 |
+
"""
|
| 345 |
+
Draws a `.PathPatch` instance whose Path comes from the original
|
| 346 |
+
PathEffect artist.
|
| 347 |
+
"""
|
| 348 |
+
|
| 349 |
+
def __init__(self, offset=(0, 0), **kwargs):
|
| 350 |
+
"""
|
| 351 |
+
Parameters
|
| 352 |
+
----------
|
| 353 |
+
offset : (float, float), default: (0, 0)
|
| 354 |
+
The (x, y) offset to apply to the path, in points.
|
| 355 |
+
**kwargs
|
| 356 |
+
All keyword arguments are passed through to the
|
| 357 |
+
:class:`~matplotlib.patches.PathPatch` constructor. The
|
| 358 |
+
properties which cannot be overridden are "path", "clip_box"
|
| 359 |
+
"transform" and "clip_path".
|
| 360 |
+
"""
|
| 361 |
+
super().__init__(offset=offset)
|
| 362 |
+
self.patch = mpatches.PathPatch([], **kwargs)
|
| 363 |
+
|
| 364 |
+
def draw_path(self, renderer, gc, tpath, affine, rgbFace):
|
| 365 |
+
self.patch._path = tpath
|
| 366 |
+
self.patch.set_transform(affine + self._offset_transform(renderer))
|
| 367 |
+
self.patch.set_clip_box(gc.get_clip_rectangle())
|
| 368 |
+
clip_path = gc.get_clip_path()
|
| 369 |
+
if clip_path and self.patch.get_clip_path() is None:
|
| 370 |
+
self.patch.set_clip_path(*clip_path)
|
| 371 |
+
self.patch.draw(renderer)
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
class TickedStroke(AbstractPathEffect):
|
| 375 |
+
"""
|
| 376 |
+
A line-based PathEffect which draws a path with a ticked style.
|
| 377 |
+
|
| 378 |
+
This line style is frequently used to represent constraints in
|
| 379 |
+
optimization. The ticks may be used to indicate that one side
|
| 380 |
+
of the line is invalid or to represent a closed boundary of a
|
| 381 |
+
domain (i.e. a wall or the edge of a pipe).
|
| 382 |
+
|
| 383 |
+
The spacing, length, and angle of ticks can be controlled.
|
| 384 |
+
|
| 385 |
+
This line style is sometimes referred to as a hatched line.
|
| 386 |
+
|
| 387 |
+
See also the :doc:`/gallery/misc/tickedstroke_demo` example.
|
| 388 |
+
"""
|
| 389 |
+
|
| 390 |
+
def __init__(self, offset=(0, 0),
|
| 391 |
+
spacing=10.0, angle=45.0, length=np.sqrt(2),
|
| 392 |
+
**kwargs):
|
| 393 |
+
"""
|
| 394 |
+
Parameters
|
| 395 |
+
----------
|
| 396 |
+
offset : (float, float), default: (0, 0)
|
| 397 |
+
The (x, y) offset to apply to the path, in points.
|
| 398 |
+
spacing : float, default: 10.0
|
| 399 |
+
The spacing between ticks in points.
|
| 400 |
+
angle : float, default: 45.0
|
| 401 |
+
The angle between the path and the tick in degrees. The angle
|
| 402 |
+
is measured as if you were an ant walking along the curve, with
|
| 403 |
+
zero degrees pointing directly ahead, 90 to your left, -90
|
| 404 |
+
to your right, and 180 behind you. To change side of the ticks,
|
| 405 |
+
change sign of the angle.
|
| 406 |
+
length : float, default: 1.414
|
| 407 |
+
The length of the tick relative to spacing.
|
| 408 |
+
Recommended length = 1.414 (sqrt(2)) when angle=45, length=1.0
|
| 409 |
+
when angle=90 and length=2.0 when angle=60.
|
| 410 |
+
**kwargs
|
| 411 |
+
Extra keywords are stored and passed through to
|
| 412 |
+
:meth:`AbstractPathEffect._update_gc`.
|
| 413 |
+
|
| 414 |
+
Examples
|
| 415 |
+
--------
|
| 416 |
+
See :doc:`/gallery/misc/tickedstroke_demo`.
|
| 417 |
+
"""
|
| 418 |
+
super().__init__(offset)
|
| 419 |
+
|
| 420 |
+
self._spacing = spacing
|
| 421 |
+
self._angle = angle
|
| 422 |
+
self._length = length
|
| 423 |
+
self._gc = kwargs
|
| 424 |
+
|
| 425 |
+
def draw_path(self, renderer, gc, tpath, affine, rgbFace):
|
| 426 |
+
"""Draw the path with updated gc."""
|
| 427 |
+
# Do not modify the input! Use copy instead.
|
| 428 |
+
gc0 = renderer.new_gc()
|
| 429 |
+
gc0.copy_properties(gc)
|
| 430 |
+
|
| 431 |
+
gc0 = self._update_gc(gc0, self._gc)
|
| 432 |
+
trans = affine + self._offset_transform(renderer)
|
| 433 |
+
|
| 434 |
+
theta = -np.radians(self._angle)
|
| 435 |
+
trans_matrix = np.array([[np.cos(theta), -np.sin(theta)],
|
| 436 |
+
[np.sin(theta), np.cos(theta)]])
|
| 437 |
+
|
| 438 |
+
# Convert spacing parameter to pixels.
|
| 439 |
+
spacing_px = renderer.points_to_pixels(self._spacing)
|
| 440 |
+
|
| 441 |
+
# Transform before evaluation because to_polygons works at resolution
|
| 442 |
+
# of one -- assuming it is working in pixel space.
|
| 443 |
+
transpath = affine.transform_path(tpath)
|
| 444 |
+
|
| 445 |
+
# Evaluate path to straight line segments that can be used to
|
| 446 |
+
# construct line ticks.
|
| 447 |
+
polys = transpath.to_polygons(closed_only=False)
|
| 448 |
+
|
| 449 |
+
for p in polys:
|
| 450 |
+
x = p[:, 0]
|
| 451 |
+
y = p[:, 1]
|
| 452 |
+
|
| 453 |
+
# Can not interpolate points or draw line if only one point in
|
| 454 |
+
# polyline.
|
| 455 |
+
if x.size < 2:
|
| 456 |
+
continue
|
| 457 |
+
|
| 458 |
+
# Find distance between points on the line
|
| 459 |
+
ds = np.hypot(x[1:] - x[:-1], y[1:] - y[:-1])
|
| 460 |
+
|
| 461 |
+
# Build parametric coordinate along curve
|
| 462 |
+
s = np.concatenate(([0.0], np.cumsum(ds)))
|
| 463 |
+
s_total = s[-1]
|
| 464 |
+
|
| 465 |
+
num = int(np.ceil(s_total / spacing_px)) - 1
|
| 466 |
+
# Pick parameter values for ticks.
|
| 467 |
+
s_tick = np.linspace(spacing_px/2, s_total - spacing_px/2, num)
|
| 468 |
+
|
| 469 |
+
# Find points along the parameterized curve
|
| 470 |
+
x_tick = np.interp(s_tick, s, x)
|
| 471 |
+
y_tick = np.interp(s_tick, s, y)
|
| 472 |
+
|
| 473 |
+
# Find unit vectors in local direction of curve
|
| 474 |
+
delta_s = self._spacing * .001
|
| 475 |
+
u = (np.interp(s_tick + delta_s, s, x) - x_tick) / delta_s
|
| 476 |
+
v = (np.interp(s_tick + delta_s, s, y) - y_tick) / delta_s
|
| 477 |
+
|
| 478 |
+
# Normalize slope into unit slope vector.
|
| 479 |
+
n = np.hypot(u, v)
|
| 480 |
+
mask = n == 0
|
| 481 |
+
n[mask] = 1.0
|
| 482 |
+
|
| 483 |
+
uv = np.array([u / n, v / n]).T
|
| 484 |
+
uv[mask] = np.array([0, 0]).T
|
| 485 |
+
|
| 486 |
+
# Rotate and scale unit vector into tick vector
|
| 487 |
+
dxy = np.dot(uv, trans_matrix) * self._length * spacing_px
|
| 488 |
+
|
| 489 |
+
# Build tick endpoints
|
| 490 |
+
x_end = x_tick + dxy[:, 0]
|
| 491 |
+
y_end = y_tick + dxy[:, 1]
|
| 492 |
+
|
| 493 |
+
# Interleave ticks to form Path vertices
|
| 494 |
+
xyt = np.empty((2 * num, 2), dtype=x_tick.dtype)
|
| 495 |
+
xyt[0::2, 0] = x_tick
|
| 496 |
+
xyt[1::2, 0] = x_end
|
| 497 |
+
xyt[0::2, 1] = y_tick
|
| 498 |
+
xyt[1::2, 1] = y_end
|
| 499 |
+
|
| 500 |
+
# Build up vector of Path codes
|
| 501 |
+
codes = np.tile([Path.MOVETO, Path.LINETO], num)
|
| 502 |
+
|
| 503 |
+
# Construct and draw resulting path
|
| 504 |
+
h = Path(xyt, codes)
|
| 505 |
+
# Transform back to data space during render
|
| 506 |
+
renderer.draw_path(gc0, h, affine.inverted() + trans, rgbFace)
|
| 507 |
+
|
| 508 |
+
gc0.restore()
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
withTickedStroke = _subclass_with_normal(effect_class=TickedStroke)
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/py.typed
ADDED
|
File without changes
|
infer_4_30_0/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: ...
|
infer_4_30_0/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()}
|
infer_4_30_0/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
|
infer_4_30_0/lib/python3.10/site-packages/matplotlib/sankey.pyi
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from matplotlib.axes import Axes
|
| 2 |
+
|
| 3 |
+
from collections.abc import Callable, Iterable
|
| 4 |
+
from typing import Any
|
| 5 |
+
from typing_extensions import Self # < Py 3.11
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
__license__: str
|
| 10 |
+
__credits__: list[str]
|
| 11 |
+
__author__: str
|
| 12 |
+
__version__: str
|
| 13 |
+
|
| 14 |
+
RIGHT: int
|
| 15 |
+
UP: int
|
| 16 |
+
DOWN: int
|
| 17 |
+
|
| 18 |
+
# TODO typing units
|
| 19 |
+
class Sankey:
|
| 20 |
+
diagrams: list[Any]
|
| 21 |
+
ax: Axes
|
| 22 |
+
unit: Any
|
| 23 |
+
format: str | Callable[[float], str]
|
| 24 |
+
scale: float
|
| 25 |
+
gap: float
|
| 26 |
+
radius: float
|
| 27 |
+
shoulder: float
|
| 28 |
+
offset: float
|
| 29 |
+
margin: float
|
| 30 |
+
pitch: float
|
| 31 |
+
tolerance: float
|
| 32 |
+
extent: np.ndarray
|
| 33 |
+
def __init__(
|
| 34 |
+
self,
|
| 35 |
+
ax: Axes | None = ...,
|
| 36 |
+
scale: float = ...,
|
| 37 |
+
unit: Any = ...,
|
| 38 |
+
format: str | Callable[[float], str] = ...,
|
| 39 |
+
gap: float = ...,
|
| 40 |
+
radius: float = ...,
|
| 41 |
+
shoulder: float = ...,
|
| 42 |
+
offset: float = ...,
|
| 43 |
+
head_angle: float = ...,
|
| 44 |
+
margin: float = ...,
|
| 45 |
+
tolerance: float = ...,
|
| 46 |
+
**kwargs
|
| 47 |
+
) -> None: ...
|
| 48 |
+
def add(
|
| 49 |
+
self,
|
| 50 |
+
patchlabel: str = ...,
|
| 51 |
+
flows: Iterable[float] | None = ...,
|
| 52 |
+
orientations: Iterable[int] | None = ...,
|
| 53 |
+
labels: str | Iterable[str | None] = ...,
|
| 54 |
+
trunklength: float = ...,
|
| 55 |
+
pathlengths: float | Iterable[float] = ...,
|
| 56 |
+
prior: int | None = ...,
|
| 57 |
+
connect: tuple[int, int] = ...,
|
| 58 |
+
rotation: float = ...,
|
| 59 |
+
**kwargs
|
| 60 |
+
) -> Self: ...
|
| 61 |
+
def finish(self) -> list[Any]: ...
|