matplotlib-multicolored-line 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,116 @@
1
+ CC0 1.0 Universal
2
+
3
+ Statement of Purpose
4
+
5
+ The laws of most jurisdictions throughout the world automatically confer
6
+ exclusive Copyright and Related Rights (defined below) upon the creator and
7
+ subsequent owner(s) (each and all, an "owner") of an original work of
8
+ authorship and/or a database (each, a "Work").
9
+
10
+ Certain owners wish to permanently relinquish those rights to a Work for the
11
+ purpose of contributing to a commons of creative, cultural and scientific
12
+ works ("Commons") that the public can reliably and without fear of later
13
+ claims of infringement build upon, modify, incorporate in other works, reuse
14
+ and redistribute as freely as possible in any form whatsoever and for any
15
+ purposes, including without limitation commercial purposes. These owners may
16
+ contribute to the Commons to promote the ideal of a free culture and the
17
+ further production of creative, cultural and scientific works, or to gain
18
+ reputation or greater distribution for their Work in part through the use and
19
+ efforts of others.
20
+
21
+ For these and/or other purposes and motivations, and without any expectation
22
+ of additional consideration or compensation, the person associating CC0 with a
23
+ Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
+ and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
+ and publicly distribute the Work under its terms, with knowledge of his or her
26
+ Copyright and Related Rights in the Work and the meaning and intended legal
27
+ effect of CC0 on those rights.
28
+
29
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
30
+ protected by copyright and related or neighboring rights ("Copyright and
31
+ Related Rights"). Copyright and Related Rights include, but are not limited
32
+ to, the following:
33
+
34
+ i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
+ and translate a Work;
36
+
37
+ ii. moral rights retained by the original author(s) and/or performer(s);
38
+
39
+ iii. publicity and privacy rights pertaining to a person's image or likeness
40
+ depicted in a Work;
41
+
42
+ iv. rights protecting against unfair competition in regards to a Work,
43
+ subject to the limitations in paragraph 4(a), below;
44
+
45
+ v. rights protecting the extraction, dissemination, use and reuse of data in
46
+ a Work;
47
+
48
+ vi. database rights (such as those arising under Directive 96/9/EC of the
49
+ European Parliament and of the Council of 11 March 1996 on the legal
50
+ protection of databases, and under any national implementation thereof,
51
+ including any amended or successor version of such directive); and
52
+
53
+ vii. other similar, equivalent or corresponding rights throughout the world
54
+ based on applicable law or treaty, and any national implementations thereof.
55
+
56
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57
+ applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58
+ unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59
+ and Related Rights and associated claims and causes of action, whether now
60
+ known or unknown (including existing as well as future claims and causes of
61
+ action), in the Work (i) in all territories worldwide, (ii) for the maximum
62
+ duration provided by applicable law or treaty (including future time
63
+ extensions), (iii) in any current or future medium and for any number of
64
+ copies, and (iv) for any purpose whatsoever, including without limitation
65
+ commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66
+ the Waiver for the benefit of each member of the public at large and to the
67
+ detriment of Affirmer's heirs and successors, fully intending that such Waiver
68
+ shall not be subject to revocation, rescission, cancellation, termination, or
69
+ any other legal or equitable action to disrupt the quiet enjoyment of the Work
70
+ by the public as contemplated by Affirmer's express Statement of Purpose.
71
+
72
+ 3. Public License Fallback. Should any part of the Waiver for any reason be
73
+ judged legally invalid or ineffective under applicable law, then the Waiver
74
+ shall be preserved to the maximum extent permitted taking into account
75
+ Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76
+ is so judged Affirmer hereby grants to each affected person a royalty-free,
77
+ non transferable, non sublicensable, non exclusive, irrevocable and
78
+ unconditional license to exercise Affirmer's Copyright and Related Rights in
79
+ the Work (i) in all territories worldwide, (ii) for the maximum duration
80
+ provided by applicable law or treaty (including future time extensions), (iii)
81
+ in any current or future medium and for any number of copies, and (iv) for any
82
+ purpose whatsoever, including without limitation commercial, advertising or
83
+ promotional purposes (the "License"). The License shall be deemed effective as
84
+ of the date CC0 was applied by Affirmer to the Work. Should any part of the
85
+ License for any reason be judged legally invalid or ineffective under
86
+ applicable law, such partial invalidity or ineffectiveness shall not
87
+ invalidate the remainder of the License, and in such case Affirmer hereby
88
+ affirms that he or she will not (i) exercise any of his or her remaining
89
+ Copyright and Related Rights in the Work or (ii) assert any associated claims
90
+ and causes of action with respect to the Work, in either case contrary to
91
+ Affirmer's express Statement of Purpose.
92
+
93
+ 4. Limitations and Disclaimers.
94
+
95
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
96
+ surrendered, licensed or otherwise affected by this document.
97
+
98
+ b. Affirmer offers the Work as-is and makes no representations or warranties
99
+ of any kind concerning the Work, express, implied, statutory or otherwise,
100
+ including without limitation warranties of title, merchantability, fitness
101
+ for a particular purpose, non infringement, or the absence of latent or
102
+ other defects, accuracy, or the present or absence of errors, whether or not
103
+ discoverable, all to the greatest extent permissible under applicable law.
104
+
105
+ c. Affirmer disclaims responsibility for clearing rights of other persons
106
+ that may apply to the Work or any use thereof, including without limitation
107
+ any person's Copyright and Related Rights in the Work. Further, Affirmer
108
+ disclaims responsibility for obtaining any necessary consents, permissions
109
+ or other rights required for any use of the Work.
110
+
111
+ d. Affirmer understands and acknowledges that Creative Commons is not a
112
+ party to this document and has no duty or obligation with respect to this
113
+ CC0 or use of the Work.
114
+
115
+ For more information, please see
116
+ <http://creativecommons.org/publicdomain/zero/1.0/>
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: matplotlib-multicolored-line
3
+ Version: 0.1.1
4
+ Summary: Plot multicolored lines in Matplotlib
5
+ Author-email: 34j <34j.95a2p@simplelogin.com>
6
+ License-Expression: CC0-1.0
7
+ Project-URL: Bug Tracker, https://github.com/34j/matplotlib-multicolored-line/issues
8
+ Project-URL: Changelog, https://github.com/34j/matplotlib-multicolored-line/blob/main/CHANGELOG.md
9
+ Project-URL: documentation, https://matplotlib-multicolored-line.readthedocs.io
10
+ Project-URL: repository, https://github.com/34j/matplotlib-multicolored-line
11
+ Classifier: Development Status :: 2 - Pre-Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: matplotlib>=3.9.4
25
+ Dynamic: license-file
26
+
27
+ # Matplotlib Multicolored Line
28
+
29
+ <p align="center">
30
+ <a href="https://github.com/34j/matplotlib-multicolored-line/actions/workflows/ci.yml?query=branch%3Amain">
31
+ <img src="https://img.shields.io/github/actions/workflow/status/34j/matplotlib-multicolored-line/ci.yml?branch=main&label=CI&logo=github&style=flat-square" alt="CI Status" >
32
+ </a>
33
+ <a href="https://matplotlib-multicolored-line.readthedocs.io">
34
+ <img src="https://img.shields.io/readthedocs/matplotlib-multicolored-line.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
35
+ </a>
36
+ <a href="https://codecov.io/gh/34j/matplotlib-multicolored-line">
37
+ <img src="https://img.shields.io/codecov/c/github/34j/matplotlib-multicolored-line.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
38
+ </a>
39
+ </p>
40
+ <p align="center">
41
+ <a href="https://github.com/astral-sh/uv">
42
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
43
+ </a>
44
+ <a href="https://github.com/astral-sh/ruff">
45
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
46
+ </a>
47
+ <a href="https://github.com/pre-commit/pre-commit">
48
+ <img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
49
+ </a>
50
+ </p>
51
+ <p align="center">
52
+ <a href="https://pypi.org/project/matplotlib-multicolored-line/">
53
+ <img src="https://img.shields.io/pypi/v/matplotlib-multicolored-line.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
54
+ </a>
55
+ <img src="https://img.shields.io/pypi/pyversions/matplotlib-multicolored-line.svg?style=flat-square&logo=python&amp;logoColor=fff" alt="Supported Python versions">
56
+ <img src="https://img.shields.io/pypi/l/matplotlib-multicolored-line.svg?style=flat-square" alt="License">
57
+ </p>
58
+
59
+ ---
60
+
61
+ **Documentation**: <a href="https://matplotlib-multicolored-line.readthedocs.io" target="_blank">https://matplotlib-multicolored-line.readthedocs.io </a>
62
+
63
+ **Source Code**: <a href="https://github.com/34j/matplotlib-multicolored-line" target="_blank">https://github.com/34j/matplotlib-multicolored-line </a>
64
+
65
+ ---
66
+
67
+ Plot multicolored lines in Matplotlib. Port of [Multicolored lines — Matplotlib 3.10.1 documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/multicolored_line.html) with slight improvements.
68
+
69
+ ## Installation
70
+
71
+ Install this via pip (or your favourite package manager):
72
+
73
+ ```shell
74
+ pip install matplotlib-multicolored-line
75
+ ```
76
+
77
+ ## Usage
78
+
79
+ ```python
80
+ import matplotlib.pyplot as plt
81
+ import numpy as np
82
+
83
+ from matplotlib_multicolored_line import colored_line
84
+
85
+
86
+ t = np.linspace(-7.4, -0.5, 200)
87
+ x = 0.9 * np.sin(t)
88
+ y = 0.9 * np.cos(1.6 * t)
89
+
90
+ fig, ax = plt.subplots()
91
+ lc = colored_line(x, y, t, ax, linewidth=5)
92
+ fig.colorbar(lc)
93
+ ```
94
+
95
+ ![Result](https://raw.githubusercontent.com/34j/matplotlib-multicolored-line/main/example.jpg)
96
+
97
+ ![Result 2](https://raw.githubusercontent.com/34j/matplotlib-multicolored-line/main/example_small.jpg)
98
+
99
+ ## Contributors ✨
100
+
101
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
102
+
103
+ <!-- prettier-ignore-start -->
104
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
105
+ <!-- prettier-ignore-start -->
106
+ <!-- markdownlint-disable -->
107
+ <table>
108
+ <tbody>
109
+ <tr>
110
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/34j"><img src="https://avatars.githubusercontent.com/u/55338215?v=4?s=80" width="80px;" alt="34j"/><br /><sub><b>34j</b></sub></a><br /><a href="https://github.com/34j/matplotlib-multicolored-line/commits?author=34j" title="Code">💻</a> <a href="#ideas-34j" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/34j/matplotlib-multicolored-line/commits?author=34j" title="Documentation">📖</a></td>
111
+ </tr>
112
+ </tbody>
113
+ </table>
114
+
115
+ <!-- markdownlint-restore -->
116
+ <!-- prettier-ignore-end -->
117
+
118
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
119
+ <!-- prettier-ignore-end -->
120
+
121
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
122
+
123
+ ## Credits
124
+
125
+ [![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)
126
+
127
+ This package was created with
128
+ [Copier](https://copier.readthedocs.io/) and the
129
+ [browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
130
+ project template.
@@ -0,0 +1,104 @@
1
+ # Matplotlib Multicolored Line
2
+
3
+ <p align="center">
4
+ <a href="https://github.com/34j/matplotlib-multicolored-line/actions/workflows/ci.yml?query=branch%3Amain">
5
+ <img src="https://img.shields.io/github/actions/workflow/status/34j/matplotlib-multicolored-line/ci.yml?branch=main&label=CI&logo=github&style=flat-square" alt="CI Status" >
6
+ </a>
7
+ <a href="https://matplotlib-multicolored-line.readthedocs.io">
8
+ <img src="https://img.shields.io/readthedocs/matplotlib-multicolored-line.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
9
+ </a>
10
+ <a href="https://codecov.io/gh/34j/matplotlib-multicolored-line">
11
+ <img src="https://img.shields.io/codecov/c/github/34j/matplotlib-multicolored-line.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
12
+ </a>
13
+ </p>
14
+ <p align="center">
15
+ <a href="https://github.com/astral-sh/uv">
16
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
17
+ </a>
18
+ <a href="https://github.com/astral-sh/ruff">
19
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
20
+ </a>
21
+ <a href="https://github.com/pre-commit/pre-commit">
22
+ <img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
23
+ </a>
24
+ </p>
25
+ <p align="center">
26
+ <a href="https://pypi.org/project/matplotlib-multicolored-line/">
27
+ <img src="https://img.shields.io/pypi/v/matplotlib-multicolored-line.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
28
+ </a>
29
+ <img src="https://img.shields.io/pypi/pyversions/matplotlib-multicolored-line.svg?style=flat-square&logo=python&amp;logoColor=fff" alt="Supported Python versions">
30
+ <img src="https://img.shields.io/pypi/l/matplotlib-multicolored-line.svg?style=flat-square" alt="License">
31
+ </p>
32
+
33
+ ---
34
+
35
+ **Documentation**: <a href="https://matplotlib-multicolored-line.readthedocs.io" target="_blank">https://matplotlib-multicolored-line.readthedocs.io </a>
36
+
37
+ **Source Code**: <a href="https://github.com/34j/matplotlib-multicolored-line" target="_blank">https://github.com/34j/matplotlib-multicolored-line </a>
38
+
39
+ ---
40
+
41
+ Plot multicolored lines in Matplotlib. Port of [Multicolored lines — Matplotlib 3.10.1 documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/multicolored_line.html) with slight improvements.
42
+
43
+ ## Installation
44
+
45
+ Install this via pip (or your favourite package manager):
46
+
47
+ ```shell
48
+ pip install matplotlib-multicolored-line
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ ```python
54
+ import matplotlib.pyplot as plt
55
+ import numpy as np
56
+
57
+ from matplotlib_multicolored_line import colored_line
58
+
59
+
60
+ t = np.linspace(-7.4, -0.5, 200)
61
+ x = 0.9 * np.sin(t)
62
+ y = 0.9 * np.cos(1.6 * t)
63
+
64
+ fig, ax = plt.subplots()
65
+ lc = colored_line(x, y, t, ax, linewidth=5)
66
+ fig.colorbar(lc)
67
+ ```
68
+
69
+ ![Result](https://raw.githubusercontent.com/34j/matplotlib-multicolored-line/main/example.jpg)
70
+
71
+ ![Result 2](https://raw.githubusercontent.com/34j/matplotlib-multicolored-line/main/example_small.jpg)
72
+
73
+ ## Contributors ✨
74
+
75
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
76
+
77
+ <!-- prettier-ignore-start -->
78
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
79
+ <!-- prettier-ignore-start -->
80
+ <!-- markdownlint-disable -->
81
+ <table>
82
+ <tbody>
83
+ <tr>
84
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/34j"><img src="https://avatars.githubusercontent.com/u/55338215?v=4?s=80" width="80px;" alt="34j"/><br /><sub><b>34j</b></sub></a><br /><a href="https://github.com/34j/matplotlib-multicolored-line/commits?author=34j" title="Code">💻</a> <a href="#ideas-34j" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/34j/matplotlib-multicolored-line/commits?author=34j" title="Documentation">📖</a></td>
85
+ </tr>
86
+ </tbody>
87
+ </table>
88
+
89
+ <!-- markdownlint-restore -->
90
+ <!-- prettier-ignore-end -->
91
+
92
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
93
+ <!-- prettier-ignore-end -->
94
+
95
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
96
+
97
+ ## Credits
98
+
99
+ [![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)
100
+
101
+ This package was created with
102
+ [Copier](https://copier.readthedocs.io/) and the
103
+ [browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
104
+ project template.
@@ -0,0 +1,161 @@
1
+ [build-system]
2
+ build-backend = "setuptools.build_meta"
3
+ requires = [ "setuptools" ]
4
+
5
+ [project]
6
+ name = "matplotlib-multicolored-line"
7
+ version = "0.1.1"
8
+ description = "Plot multicolored lines in Matplotlib"
9
+ readme = "README.md"
10
+ license = "CC0-1.0"
11
+ authors = [
12
+ { name = "34j", email = "34j.95a2p@simplelogin.com" },
13
+ ]
14
+ requires-python = ">=3.9"
15
+ classifiers = [
16
+ "Development Status :: 2 - Pre-Alpha",
17
+ "Intended Audience :: Developers",
18
+ "Natural Language :: English",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3.9",
21
+ "Programming Language :: Python :: 3.10",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.12",
24
+ "Programming Language :: Python :: 3.13",
25
+ "Topic :: Software Development :: Libraries",
26
+ ]
27
+
28
+ dependencies = [
29
+ "matplotlib>=3.9.4",
30
+ ]
31
+ urls."Bug Tracker" = "https://github.com/34j/matplotlib-multicolored-line/issues"
32
+ urls.Changelog = "https://github.com/34j/matplotlib-multicolored-line/blob/main/CHANGELOG.md"
33
+ urls.documentation = "https://matplotlib-multicolored-line.readthedocs.io"
34
+ urls.repository = "https://github.com/34j/matplotlib-multicolored-line"
35
+
36
+ [dependency-groups]
37
+ dev = [
38
+ "pytest>=8,<9",
39
+ "pytest-cov>=6,<7",
40
+ ]
41
+ docs = [
42
+ "furo>=2023.5.20; python_version>='3.11'",
43
+ "myst-parser>=0.16; python_version>='3.11'",
44
+ "sphinx>=4; python_version>='3.11'",
45
+ "sphinx-autobuild>=2024,<2025; python_version>='3.11'",
46
+ ]
47
+
48
+ [tool.ruff]
49
+ line-length = 100
50
+ lint.select = [
51
+ "B", # flake8-bugbear
52
+ "D", # flake8-docstrings
53
+ "C4", # flake8-comprehensions
54
+ "S", # flake8-bandit
55
+ "F", # pyflake
56
+ "E", # pycodestyle
57
+ "W", # pycodestyle
58
+ "UP", # pyupgrade
59
+ "I", # isort
60
+ "RUF", # ruff specific
61
+ ]
62
+ lint.ignore = [
63
+ "D203", # 1 blank line required before class docstring
64
+ "D212", # Multi-line docstring summary should start at the first line
65
+ "D100", # Missing docstring in public module
66
+ "D104", # Missing docstring in public package
67
+ "D107", # Missing docstring in `__init__`
68
+ "D401", # First line of docstring should be in imperative mood
69
+ ]
70
+ lint.per-file-ignores."conftest.py" = [ "D100" ]
71
+ lint.per-file-ignores."docs/conf.py" = [ "D100" ]
72
+ lint.per-file-ignores."setup.py" = [ "D100" ]
73
+ lint.per-file-ignores."tests/**/*" = [
74
+ "D100",
75
+ "D101",
76
+ "D102",
77
+ "D103",
78
+ "D104",
79
+ "S101",
80
+ ]
81
+ lint.isort.known-first-party = [ "matplotlib_multicolored_line", "tests" ]
82
+
83
+ [tool.pytest.ini_options]
84
+ addopts = """\
85
+ -v
86
+ -Wdefault
87
+ --cov=matplotlib_multicolored_line
88
+ --cov-report=term
89
+ --cov-report=xml
90
+ """
91
+ pythonpath = [ "src" ]
92
+
93
+ [tool.coverage.run]
94
+ branch = true
95
+
96
+ [tool.coverage.report]
97
+ exclude_lines = [
98
+ "pragma: no cover",
99
+ "@overload",
100
+ "if TYPE_CHECKING",
101
+ "raise NotImplementedError",
102
+ 'if __name__ == "__main__":',
103
+ ]
104
+
105
+ [tool.mypy]
106
+ check_untyped_defs = true
107
+ disallow_any_generics = true
108
+ disallow_incomplete_defs = true
109
+ disallow_untyped_defs = true
110
+ mypy_path = "src/"
111
+ no_implicit_optional = true
112
+ show_error_codes = true
113
+ warn_unreachable = true
114
+ warn_unused_ignores = true
115
+ exclude = [
116
+ 'docs/.*',
117
+ 'setup.py',
118
+ ]
119
+
120
+ [[tool.mypy.overrides]]
121
+ module = "tests.*"
122
+ allow_untyped_defs = true
123
+
124
+ [[tool.mypy.overrides]]
125
+ module = "docs.*"
126
+ ignore_errors = true
127
+
128
+ [tool.semantic_release]
129
+ version_toml = [ "pyproject.toml:project.version" ]
130
+ version_variables = [
131
+ "src/matplotlib_multicolored_line/__init__.py:__version__",
132
+ "docs/conf.py:release",
133
+ ]
134
+ build_command = """
135
+ pip install uv
136
+ uv lock
137
+ git add uv.lock
138
+ uv build
139
+ """
140
+
141
+ [tool.semantic_release.changelog]
142
+ exclude_commit_patterns = [
143
+ '''chore(?:\([^)]*?\))?: .+''',
144
+ '''ci(?:\([^)]*?\))?: .+''',
145
+ '''refactor(?:\([^)]*?\))?: .+''',
146
+ '''style(?:\([^)]*?\))?: .+''',
147
+ '''test(?:\([^)]*?\))?: .+''',
148
+ '''build\((?!deps\): .+)''',
149
+ '''Merged? .*''',
150
+ '''Initial [Cc]ommit.*''', # codespell:ignore
151
+ ]
152
+
153
+ [tool.semantic_release.changelog.environment]
154
+ keep_trailing_newline = true
155
+
156
+ [tool.semantic_release.branches.main]
157
+ match = "main"
158
+
159
+ [tool.semantic_release.branches.noop]
160
+ match = "(?!main$)"
161
+ prerelease = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python
2
+
3
+ # This is a shim to allow GitHub to detect the package, build is done with uv
4
+ # Taken from https://github.com/Textualize/rich
5
+
6
+ import setuptools
7
+
8
+ if __name__ == "__main__":
9
+ setuptools.setup(name="matplotlib-multicolored-line")
@@ -0,0 +1,4 @@
1
+ __version__ = "0.1.1"
2
+ from ._main import colored_line
3
+
4
+ __all__ = ["colored_line"]
@@ -0,0 +1,80 @@
1
+ from __future__ import annotations
2
+
3
+ import warnings
4
+ from typing import Any
5
+
6
+ import matplotlib.pyplot as plt
7
+ import numpy as np
8
+ from matplotlib.axes import Axes
9
+ from matplotlib.collections import LineCollection
10
+ from numpy.typing import ArrayLike
11
+
12
+
13
+ def colored_line(
14
+ x: ArrayLike,
15
+ y: ArrayLike,
16
+ c: ArrayLike,
17
+ ax: Axes | None = None,
18
+ scalex: bool = True,
19
+ scaley: bool = True,
20
+ **kwargs: Any,
21
+ ) -> LineCollection:
22
+ """
23
+ Plot a line with a color specified along the line by a third value.
24
+
25
+ It does this by creating a collection of line segments. Each line segment is
26
+ made up of two straight lines each connecting the current (x, y) point to the
27
+ midpoints of the lines connecting the current point with its two neighbors.
28
+ This creates a smooth line with no gaps between the line segments.
29
+
30
+ Parameters
31
+ ----------
32
+ x, y : array-like
33
+ The horizontal and vertical coordinates of the data points.
34
+ c : array-like
35
+ The color values, which should be the same size as x and y.
36
+ ax : matplotlib.axes.Axes, optional
37
+ The axes to plot on. If not provided, the current axes will be used.
38
+ scalex, scaley : bool
39
+ These parameters determine if the view limits are adapted to the data limits.
40
+ The values are passed on to autoscale_view.
41
+ **kwargs : Any
42
+ Any additional arguments to pass to matplotlib.collections.LineCollection
43
+ constructor. This should not include the array keyword argument because
44
+ that is set to the color argument. If provided, it will be overridden.
45
+
46
+ Returns
47
+ -------
48
+ matplotlib.collections.LineCollection
49
+ The generated line collection representing the colored line.
50
+
51
+ """
52
+ if "array" in kwargs:
53
+ warnings.warn(
54
+ 'The provided "array" keyword argument will be overridden',
55
+ UserWarning,
56
+ stacklevel=2,
57
+ )
58
+
59
+ xy = np.stack((x, y), axis=-1)
60
+ xy_mid = np.concat(
61
+ (xy[0, :][None, :], (xy[:-1, :] + xy[1:, :]) / 2, xy[-1, :][None, :]), axis=0
62
+ )
63
+ segments = np.stack((xy_mid[:-1, :], xy, xy_mid[1:, :]), axis=-2)
64
+ # Note that segments is [
65
+ # [[x[0], y[0]], [x[0], y[0]], [mean(x[0], x[1]), mean(y[0], y[1])]],
66
+ # [[mean(x[0], x[1]), mean(y[0], y[1])], [x[1], y[1]], [mean(x[1], x[2]), mean(y[1], y[2])]],
67
+ # ...
68
+ # [[mean(x[-2], x[-1]), mean(y[-2], y[-1])], [x[-1], y[-1]], [x[-1], y[-1]]]
69
+ # ]
70
+
71
+ kwargs["array"] = c
72
+ lc = LineCollection(segments, **kwargs)
73
+
74
+ # Plot the line collection to the axes
75
+ ax = ax or plt.gca()
76
+ ax.add_collection(lc)
77
+ ax.autoscale_view(scalex=scalex, scaley=scaley)
78
+
79
+ # Return the LineCollection object
80
+ return lc
@@ -0,0 +1,130 @@
1
+ Metadata-Version: 2.4
2
+ Name: matplotlib-multicolored-line
3
+ Version: 0.1.1
4
+ Summary: Plot multicolored lines in Matplotlib
5
+ Author-email: 34j <34j.95a2p@simplelogin.com>
6
+ License-Expression: CC0-1.0
7
+ Project-URL: Bug Tracker, https://github.com/34j/matplotlib-multicolored-line/issues
8
+ Project-URL: Changelog, https://github.com/34j/matplotlib-multicolored-line/blob/main/CHANGELOG.md
9
+ Project-URL: documentation, https://matplotlib-multicolored-line.readthedocs.io
10
+ Project-URL: repository, https://github.com/34j/matplotlib-multicolored-line
11
+ Classifier: Development Status :: 2 - Pre-Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Requires-Python: >=3.9
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: matplotlib>=3.9.4
25
+ Dynamic: license-file
26
+
27
+ # Matplotlib Multicolored Line
28
+
29
+ <p align="center">
30
+ <a href="https://github.com/34j/matplotlib-multicolored-line/actions/workflows/ci.yml?query=branch%3Amain">
31
+ <img src="https://img.shields.io/github/actions/workflow/status/34j/matplotlib-multicolored-line/ci.yml?branch=main&label=CI&logo=github&style=flat-square" alt="CI Status" >
32
+ </a>
33
+ <a href="https://matplotlib-multicolored-line.readthedocs.io">
34
+ <img src="https://img.shields.io/readthedocs/matplotlib-multicolored-line.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
35
+ </a>
36
+ <a href="https://codecov.io/gh/34j/matplotlib-multicolored-line">
37
+ <img src="https://img.shields.io/codecov/c/github/34j/matplotlib-multicolored-line.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
38
+ </a>
39
+ </p>
40
+ <p align="center">
41
+ <a href="https://github.com/astral-sh/uv">
42
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv">
43
+ </a>
44
+ <a href="https://github.com/astral-sh/ruff">
45
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
46
+ </a>
47
+ <a href="https://github.com/pre-commit/pre-commit">
48
+ <img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
49
+ </a>
50
+ </p>
51
+ <p align="center">
52
+ <a href="https://pypi.org/project/matplotlib-multicolored-line/">
53
+ <img src="https://img.shields.io/pypi/v/matplotlib-multicolored-line.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
54
+ </a>
55
+ <img src="https://img.shields.io/pypi/pyversions/matplotlib-multicolored-line.svg?style=flat-square&logo=python&amp;logoColor=fff" alt="Supported Python versions">
56
+ <img src="https://img.shields.io/pypi/l/matplotlib-multicolored-line.svg?style=flat-square" alt="License">
57
+ </p>
58
+
59
+ ---
60
+
61
+ **Documentation**: <a href="https://matplotlib-multicolored-line.readthedocs.io" target="_blank">https://matplotlib-multicolored-line.readthedocs.io </a>
62
+
63
+ **Source Code**: <a href="https://github.com/34j/matplotlib-multicolored-line" target="_blank">https://github.com/34j/matplotlib-multicolored-line </a>
64
+
65
+ ---
66
+
67
+ Plot multicolored lines in Matplotlib. Port of [Multicolored lines — Matplotlib 3.10.1 documentation](https://matplotlib.org/stable/gallery/lines_bars_and_markers/multicolored_line.html) with slight improvements.
68
+
69
+ ## Installation
70
+
71
+ Install this via pip (or your favourite package manager):
72
+
73
+ ```shell
74
+ pip install matplotlib-multicolored-line
75
+ ```
76
+
77
+ ## Usage
78
+
79
+ ```python
80
+ import matplotlib.pyplot as plt
81
+ import numpy as np
82
+
83
+ from matplotlib_multicolored_line import colored_line
84
+
85
+
86
+ t = np.linspace(-7.4, -0.5, 200)
87
+ x = 0.9 * np.sin(t)
88
+ y = 0.9 * np.cos(1.6 * t)
89
+
90
+ fig, ax = plt.subplots()
91
+ lc = colored_line(x, y, t, ax, linewidth=5)
92
+ fig.colorbar(lc)
93
+ ```
94
+
95
+ ![Result](https://raw.githubusercontent.com/34j/matplotlib-multicolored-line/main/example.jpg)
96
+
97
+ ![Result 2](https://raw.githubusercontent.com/34j/matplotlib-multicolored-line/main/example_small.jpg)
98
+
99
+ ## Contributors ✨
100
+
101
+ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
102
+
103
+ <!-- prettier-ignore-start -->
104
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
105
+ <!-- prettier-ignore-start -->
106
+ <!-- markdownlint-disable -->
107
+ <table>
108
+ <tbody>
109
+ <tr>
110
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/34j"><img src="https://avatars.githubusercontent.com/u/55338215?v=4?s=80" width="80px;" alt="34j"/><br /><sub><b>34j</b></sub></a><br /><a href="https://github.com/34j/matplotlib-multicolored-line/commits?author=34j" title="Code">💻</a> <a href="#ideas-34j" title="Ideas, Planning, & Feedback">🤔</a> <a href="https://github.com/34j/matplotlib-multicolored-line/commits?author=34j" title="Documentation">📖</a></td>
111
+ </tr>
112
+ </tbody>
113
+ </table>
114
+
115
+ <!-- markdownlint-restore -->
116
+ <!-- prettier-ignore-end -->
117
+
118
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
119
+ <!-- prettier-ignore-end -->
120
+
121
+ This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
122
+
123
+ ## Credits
124
+
125
+ [![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)
126
+
127
+ This package was created with
128
+ [Copier](https://copier.readthedocs.io/) and the
129
+ [browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
130
+ project template.
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ src/matplotlib_multicolored_line/__init__.py
6
+ src/matplotlib_multicolored_line/_main.py
7
+ src/matplotlib_multicolored_line/py.typed
8
+ src/matplotlib_multicolored_line.egg-info/PKG-INFO
9
+ src/matplotlib_multicolored_line.egg-info/SOURCES.txt
10
+ src/matplotlib_multicolored_line.egg-info/dependency_links.txt
11
+ src/matplotlib_multicolored_line.egg-info/requires.txt
12
+ src/matplotlib_multicolored_line.egg-info/top_level.txt
13
+ tests/test_main.py
@@ -0,0 +1,36 @@
1
+ from pathlib import Path
2
+
3
+ import matplotlib.pyplot as plt
4
+ import numpy as np
5
+ import pytest
6
+
7
+ from matplotlib_multicolored_line import colored_line
8
+
9
+ CACHE_PATH = Path(__file__).parent / ".cache"
10
+
11
+
12
+ @pytest.fixture(autouse=True)
13
+ def setup_cache() -> None:
14
+ CACHE_PATH.mkdir(parents=True, exist_ok=True)
15
+
16
+
17
+ def test_main() -> None:
18
+ t = np.linspace(-7.4, -0.5, 200)
19
+ x = 0.9 * np.sin(t)
20
+ y = 0.9 * np.cos(1.6 * t)
21
+
22
+ fig, ax = plt.subplots()
23
+ lc = colored_line(x, y, t, ax, linewidth=10)
24
+ fig.colorbar(lc)
25
+ fig.savefig(CACHE_PATH / "example.jpg")
26
+
27
+
28
+ def test_main_small() -> None:
29
+ x = [0, 1, 2, 3, 4]
30
+ y = [0, 1, 2, 1, 1]
31
+ c = [1, 2, 3, 4, 5]
32
+
33
+ fig, ax = plt.subplots()
34
+ lc = colored_line(x, y, c, ax, linewidth=10)
35
+ fig.colorbar(lc)
36
+ fig.savefig(CACHE_PATH / "example_small.jpg")