Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Introducing Spectral Colors#29517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Sven-J-Steinert wants to merge3 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromSven-J-Steinert:Introduce-Scientific-Spectral-Colors
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletionsdoc/api/colors_api.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,3 +96,5 @@ as dictionaries that map color names to hex strings.
.. py:data:: CSS4_COLORS

.. py:data:: XKCD_COLORS

.. py:data:: SPECTRAL_COLORS
13 changes: 12 additions & 1 deletiongalleries/examples/color/named_colors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,16 @@
from matplotlib.patches import Rectangle


def plot_colortable(colors, *, ncols=4, sort_colors=True):
def plot_colortable(colors, *, ncols=4, sort_colors=True, sample=False):

cell_width = 212
cell_height = 22
swatch_width = 48
margin = 12

if sample:
colors = dict(list(colors.items())[::10])

# Sort colors by hue, saturation, value and name.
if sort_colors is True:
names = sorted(
Expand DownExpand Up@@ -97,6 +100,14 @@ def plot_colortable(colors, *, ncols=4, sort_colors=True):
plot_colortable(mcolors.CSS4_COLORS)
plt.show()

# %%
# ---------------
# Spectral Colors
# ---------------
# The full visible spectrum from 390nm to 780nm is supported in integers
# e.g. ``"405nm"``. A sub sample of the defined colors by wavelength is shown below.
plot_colortable(mcolors.SPECTRAL_COLORS, ncols=4, sort_colors=False, sample=True)

# %%
# -----------
# XKCD Colors
Expand Down
4 changes: 4 additions & 0 deletionsgalleries/users_explain/colors/colors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,6 +48,10 @@
| `xkcd color survey`_ with ``'xkcd:'``| - ``'xkcd:eggshell'`` |
| prefix. | |
+--------------------------------------+--------------------------------------+
| Case-insensitive spectral colors | - ``'405nm'`` |
| specified by wavelength in nano | - ``'525nm'`` |
| meters (supported range 390..780) | - ``'650nm'`` |
+--------------------------------------+--------------------------------------+
| Case-insensitive Tableau Colors from | - ``'tab:blue'`` |
| 'T10' categorical palette. | - ``'tab:orange'`` |
| | - ``'tab:green'`` |
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp