相关疑难解决方法(0)

来自tab10的matplotlib通用色彩映射

这个问题与SO中的这个问题有关(matplotlib-change-colormap-tab20-to-have-three-colors)

我想以一种方式调整tab10色彩图,我可以按照我想要的步骤更改每种颜色的alpha级别.下面是一个示例(对于具有3个alpha级别的9种颜色),它不会产生预期的输出.此外,它不够通用(因为if elif staements).

任何想法我怎么能这样做?

在这个例子中,我有3个组,有3个子组:

import pandas as pd
from matplotlib import pyplot as plt
import numpy as np

n_feature = 3
sub_feature = 3
col = []
for index in range(n_feature*sub_feature):
# loop over colors and change the last entry in descending order 3 times
        col.append(list(plt.cm.tab10(index)))

i = 0        
for item in col:
# loop over colors and change the last entry in descending order 3 times
    if i == 0:
        item[-1] = 0.9
        i+=1
    elif …
Run Code Online (Sandbox Code Playgroud)

python color-scheme colors matplotlib

7
推荐指数
1
解决办法
4584
查看次数

标签 统计

color-scheme ×1

colors ×1

matplotlib ×1

python ×1