[Python] How to extract RGB values for LinearSegmentedColormap

Discussão em 'Python' iniciado por Stack, Maio 11, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to find the RGB values for the different matplotlib colormaps. This is relatively straightforward when the colormap is a ListedColorMap using the colors attribute:

    for idd in range(0, 255, 1):
    value1 = int(255*col_map.colors[idd][0])
    value2 = int(255*col_map.colors[idd][1])
    value3 = int(255*col_map.colors[idd][2])


    However, several colormaps (e.g. PiYG or hsv) are objects created from the class 'matplotlib.colors.LinearSegmentedColormap' that doesn't have the colors attribute. My question is whether there is any specific attribute or method able to extract the sought RGBs.

    Continue reading...

Compartilhe esta Página