我想从色彩图中删除前n个颜色,而不丢失原始颜色数

2024-06-13 09:27:51 发布

您现在位置:Python中文网/ 问答频道 /正文

from matplotlib import cm
import seaborn as sns
import matplotlib.pyplot as plt

这是原始颜色图

^{pr2}$

enter image description here

我最喜欢的结果是沿着下面显示的颜色图,除了带有原始颜色数的

cmap2 = [cm.inferno(x)[:3] for x in range(0,256)][100:]
sns.palplot(cmap2)

enter image description here


Tags: infromimportformatplotlib颜色ascm
1条回答
网友
1楼 · 发布于 2024-06-13 09:27:51

我相信“同样的分辨率”意味着你想要256种颜色。实际上,我认为这与原始调色板的分辨率不同,因为颜色空间中的值更接近。在任何情况下,我认为你可以通过以下方式得到你想要的:

import numpy as np
import seaborn as sns
from matplotlib import cm

x = np.linspace(.3, 1, 256)
pal = cm.inferno(x)
sns.palplot(pal)

enter image description here

相关问题 更多 >