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

Visually more uniform colortable#27924

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

Draft
timhoffm wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromtimhoffm:colortable-sort
Draft
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
15 changes: 12 additions & 3 deletionsgalleries/examples/color/named_colors.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,10 +32,19 @@ def plot_colortable(colors, *, ncols=4, sort_colors=True):
swatch_width = 48
margin = 12

# Sort colors by hue, saturation, value and name.
if sort_colors is True:
names = sorted(
colors, key=lambda c: tuple(mcolors.rgb_to_hsv(mcolors.to_rgb(c))))
# Sort colors: To make the visual perception more smooth, we split
# into two groups with low-saturation / high-saturation, and sort
# by hue, saturation and value within these groups.
by_hsv = sorted((tuple(mcolors.rgb_to_hsv(mcolors.to_rgb(color))),
name)
for name, color in colors.items())

non_sat = [(hsv, name) for hsv, name in by_hsv if hsv[1] < 0.2]
sat = [(hsv, name) for hsv, name in by_hsv if hsv[1] >= 0.2]
by_hsv = non_sat + sat

names = [name for hsv, name in by_hsv]
else:
names = list(colors)

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp